Q:

unwanted space in custom font in php script

Hello i created kind of a custom font. Now I want to use it in my php script, everything is fine till i want use s letter with acute, because instead of just a letter i get letter+space. Here is my font.php :
<?php
$type='TrueType';
$name='TimesNewRomanPSMT';
$desc=array('Ascent'=>891,'Descent'=>-216,'CapHeight'=>7,'Flags'=>32,'FontBBox'=>'[-77 -226 936 886]','ItalicAngle'=>0,'StemV'=>70,'MissingWidth'=>778);
$up=-109;
$ut=49;
$cw=array(
0=>778,1=>778,2=>778,3=>778,4=>778,5=>778,6=>778,7=>778,8=>778,9=>778,
10=>778,11=>778,12=>778,13=>778,14=>778,15=>778,16=>778,17=>778,18=>778,19=>778,
20=>778,21=>778,22=>778,23=>778,24=>778,25=>778,26=>778,27=>778,28=>778,29=>778,
30=>778,31=>778,32=>250,33=>333,34=>408,35=>500,36=>500,37=>833,38=>778,39=>180,
40=>333,41=>333,42=>500,43=>564,44=>250,45=>333,46=>250,47=>278,48=>500,49=>500,
50=>500,51=>500,52=>500,53=>500,54=>500,55=>500,56=>500,57=>500,58=>278,59=>278,
60=>564,61=>564,62=>564,63=>444,64=>921,65=>722,66=>667,67=>667,68=>722,69=>611,
70=>556,71=>722,72=>722,73=>333,74=>389,75=>722,76=>611,77=>889,78=>722,79=>722,
80=>556,81=>722,82=>667,83=>556,84=>611,85=>722,86=>722,87=>944,88=>722,89=>722,
90=>611,91=>333,92=>278,93=>333,94=>469,95=>500,96=>333,97=>444,98=>500,99=>444,
100=>500,101=>444,102=>333,103=>500,104=>500,105=>278,106=>278,107=>500,108=>278,109=>778,
110=>500,111=>500,112=>500,113=>500,114=>333,115=>389,116=>278,117=>500,118=>500,119=>722,
120=>500,121=>500,122=>444,123=>480,124=>200,125=>480,126=>541,127=>778,128=>778,129=>778,
130=>778,131=>778,132=>778,133=>778,134=>778,135=>778,136=>778,137=>778,138=>778,139=>778,
140=>778,141=>778,142=>778,143=>778,144=>778,145=>778,146=>778,147=>778,148=>778,149=>778,
150=>778,151=>778,152=>778,153=>778,154=>778,155=>778,156=>778,157=>778,158=>778,159=>778,
160=>250,161=>722,162=>333,163=>611,164=>500,165=>611,166=>556,167=>500,168=>333,169=>556,
170=>556,171=>611,172=>611,173=>333,174=>611,175=>611,176=>400,177=>444,178=>333,179=>278,
180=>333,181=>406,182=>389,183=>333,184=>333,185=>389,186=>389,187=>427,188=>444,189=>333,
190=>444,191=>444,192=>667,193=>722,194=>722,195=>722,196=>722,197=>611,198=>667,199=>667,
200=>667,201=>611,202=>611,203=>611,204=>611,205=>333,206=>333,207=>722,208=>722,209=>722,
210=>722,211=>722,212=>722,213=>722,214=>722,215=>564,216=>667,217=>722,218=>722,219=>722,
220=>722,221=>722,222=>611,223=>500,224=>333,225=>444,226=>444,227=>444,228=>444,229=>278,
230=>444,231=>444,232=>444,233=>444,234=>444,235=>444,236=>444,237=>278,238=>278,239=>646,
240=>500,241=>500,242=>500,243=>500,244=>500,245=>500,246=>500,247=>549,248=>333,249=>500,
250=>500,251=>500,252=>500,253=>500,254=>278,255=>333);

$enc='iso-8859-2';
$diff='131 /.notdef 136 /.notdef 140 /Sacute /Tcaron 143 /Zacute 152 /.notdef 156 /sacute /tcaron 159 /zacute 161 /caron /breve /Lslash 165 /Aogonek 170 /Scedilla 175 /Zdot 178 /ogonek /lslash 185 /aogonek /scedilla 188 /Lcaron /hungarumlaut /lcaron /zdot /Racute 195 /Abreve 197 /Lacute /Cacute 200 /Ccaron 202 /Eogonek 204 /Ecaron 207 /Dcaron /Dslash /Nacute /Ncaron 213 /Odblacute 216 /Rcaron /Uring 219 /Udblacute 222 /Tcedilla 224 /racute 227 /abreve 229 /lacute /cacute 232 /ccaron 234 /eogonek 236 /ecaron 239 /dcaron /dmacron /nacute /ncaron 245 /odblacute 248 /rcaron /uring 251 /udblacute 254 /tcedilla /dotaccent';
$file='times.z';
$originalsize=409280;
// --- EOF ---

What should i do to get Ś instead of Ś with space?

A:

Assuming the Array $cw contains the character width of each character:

Character 0x53 (83) (S in ASCII) has a width of 556
Character 0x73 (115) (s in ASCII) has a width of 389
Character 0x8C (140) (&Sacute in cp1250) has a width of 778
Character 0x9C (156) (&sacute in cp1250) has a width of 778
Character 0xA6 (166) (&Sacute in iso-8859-2) has a width of 556
Character 0xB6 (182) (&sacute in iso-8859-2) has a width of 389

Now I do not know where those widths are really from, but it may be because you -- output? -- the font using the cp1250 code page (you wrote this in the comment), but set the encoding in your source code to iso-8859-2. You can look up the differences between the two code pages at Wikipedia Windows-1250
So you can either export that again with the iso-8859-2 code page, change the code page in your script, or alter the widths manually. Keep in mind that there are other characters that differ in those two code pages, so you probably want to change them too.

