Commit b2d171c 1 parent 512afb1 commit b2d171c Copy full SHA for b2d171c
File tree 1 file changed +10
-7
lines changed
1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -355,13 +355,16 @@ def from_element(fonttable: ET.Element) -> 'CDXFontTable':
355
355
fonts = []
356
356
357
357
for font in fonttable .iter (tag = "font" ):
358
- logger .debug (f"Reading font { font .attrib } ." )
359
- font_id = int (font .attrib ["id" ])
360
- if font .attrib ["charset" ] == "UTF-8" :
361
- font .attrib ["charset" ] = "utf8"
362
- charset = next (key for key , value in Font .CHARSETS .items () if value == font .attrib ["charset" ])
363
- font_name = font .attrib ["name" ]
364
- fonts .append (Font (font_id , charset , font_name ))
358
+ try :
359
+ logger .debug (f"Reading font { font .attrib } ." )
360
+ font_id = int (font .attrib ["id" ])
361
+ if font .attrib ["charset" ] == "UTF-8" :
362
+ font .attrib ["charset" ] = "utf8"
363
+ charset = next (key for key , value in Font .CHARSETS .items () if value == font .attrib ["charset" ])
364
+ font_name = font .attrib ["name" ]
365
+ fonts .append (Font (font_id , charset , font_name ))
366
+ except StopIteration :
367
+ logger .warning (f"Ignoring font with invalid charset { font .attrib ['charset' ]} ." )
365
368
366
369
if platform .system () == "Windows" :
367
370
os_type = CDXFontTable .PLATFORM_WINDOWS
You can’t perform that action at this time.
0 commit comments