File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -133,12 +133,22 @@ def _parse_header(fh):
133133 }
134134
135135 d = {}
136+ first_line = True
136137 for line in fh :
137138 line = line .rstrip ()
138139 if line .startswith (b'Comment' ):
139140 continue
140141 lst = line .split (b' ' , 1 )
141142 key = lst [0 ]
143+ if first_line :
144+ # AFM spec, Section 4: The StartFontMetrics keyword
145+ # [followed by a version number] must be the first line in
146+ # the file, and the EndFontMetrics keyword must be the
147+ # last non-empty line in the file. We just check the
148+ # first header entry.
149+ if key != b'StartFontMetrics' :
150+ raise RuntimeError ('Not an AFM file' )
151+ first_line = False
142152 if len (lst ) == 2 :
143153 val = lst [1 ]
144154 else :
@@ -157,12 +167,6 @@ def _parse_header(fh):
157167 break
158168 else :
159169 raise RuntimeError ('Bad parse' )
160- # AFM spec, Section 4: The StartFontMetrics keyword [followed by a version
161- # number] must be the first line in the file, and the EndFontMetrics
162- # keyword must be the last non-empty line in the file. We just check the
163- # first header entry.
164- if next (iter (d )) != b'StartFontMetrics' :
165- raise RuntimeError ('Not an AFM file' )
166170 return d
167171
168172
You can’t perform that action at this time.
0 commit comments