@@ -87,7 +87,10 @@ def _parse_header(fh):
8787 'XHeight' : _to_float ,
8888 'Ascender' : _to_float ,
8989 'Descender' : _to_float ,
90+ 'StdHW' : _to_float ,
91+ 'StdVW' : _to_float ,
9092 'StartCharMetrics' : _to_int ,
93+ 'CharacterSet' : _to_str ,
9194 'Characters' : _to_int ,
9295 'Capheight' : _to_int ,
9396 }
@@ -111,7 +114,7 @@ def _parse_header(fh):
111114 print >> sys .stderr , 'Value error parsing header in AFM:' , key , val
112115 continue
113116 except KeyError :
114- print >> sys .stderr , 'Key error converting in AFM'
117+ print >> sys .stderr , 'Found an unknown keyword in AFM header (was %s)' % key
115118 continue
116119 if key == 'StartCharMetrics' : return d
117120 raise RuntimeError ('Bad parse' )
@@ -136,13 +139,17 @@ def _parse_char_metrics(fh):
136139 line = line .rstrip ()
137140 if line .startswith ('EndCharMetrics' ): return d
138141 vals = line .split (';' )[:4 ]
139- if len (vals )!= 4 : raise RuntimeError ('Bad char metrics line: %s' % line )
142+ if len (vals ) != 4 : raise RuntimeError ('Bad char metrics line: %s' % line )
140143 num = _to_int (vals [0 ].split ()[1 ])
141- if num == - 1 : continue
142144 wx = _to_float (vals [1 ].split ()[1 ])
143145 name = vals [2 ].split ()[1 ]
144146 bbox = _to_list_of_ints (vals [3 ][2 :])
145- d [num ] = (wx , name , bbox )
147+ # Workaround: If the character name is 'Euro', give it the corresponding
148+ # character code, according to WinAnsiEncoding (see PDF Reference).
149+ if name == 'Euro' :
150+ num = 128
151+ if num != - 1 :
152+ d [num ] = (wx , name , bbox )
146153 raise RuntimeError ('Bad parse' )
147154
148155def _parse_kern_pairs (fh ):
0 commit comments