@@ -194,20 +194,19 @@ def _parse_char_metrics(fh):
194194 line = fh .readline ()
195195 if not line :
196196 break
197- line = line .rstrip ()
198- if line .startswith (b 'EndCharMetrics' ):
197+ line = line .rstrip (). decode ( 'ascii' ) # Convert from byte-literal
198+ if line .startswith ('EndCharMetrics' ):
199199 return ascii_d , name_d
200- # Split metric line into dictonary keyed by the metric identifiers
201- vals = filter (lambda s : s != b'' , line .split (b ';' ))
202- vals = dict (map (lambda s : tuple (s .strip ().split (b ' ' , 1 )), vals ))
203- # check for the required metrics
204- if any ([id not in vals .keys () for id in (b 'C' , b 'WX' , b 'N' , b 'B' )]):
200+ # Split the metric line into a dictonary, keyed by metric identifiers
201+ vals = filter (lambda s : len ( s ) > 0 , line .split (';' ))
202+ vals = dict (map (lambda s : tuple (s .strip ().split (' ' , 1 )), vals ))
203+ # There may be other metrics present, but only these are needed
204+ if any ([id not in vals .keys () for id in ('C' , 'WX' , 'N' , 'B' )]):
205205 raise RuntimeError ('Bad char metrics line: %s' % line )
206- num = _to_int (vals [b'C' ])
207- wx = _to_float (vals [b'WX' ])
208- name = vals [b'N' ]
209- name = name .decode ('ascii' )
210- bbox = _to_list_of_floats (vals [b'B' ])
206+ num = _to_int (vals ['C' ])
207+ wx = _to_float (vals ['WX' ])
208+ name = vals ['N' ]
209+ bbox = _to_list_of_floats (vals ['B' ])
211210 bbox = list (map (int , bbox ))
212211 # Workaround: If the character name is 'Euro', give it the
213212 # corresponding character code, according to WinAnsiEncoding (see PDF
0 commit comments