Skip to content

Commit

Permalink
ignore font with invalid charset
Browse files Browse the repository at this point in the history
  • Loading branch information
kienerj committed Mar 13, 2024
1 parent 512afb1 commit b2d171c
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions pycdxml/cdxml_converter/chemdraw_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,13 +355,16 @@ def from_element(fonttable: ET.Element) -> 'CDXFontTable':
fonts = []

for font in fonttable.iter(tag="font"):
logger.debug(f"Reading font {font.attrib}.")
font_id = int(font.attrib["id"])
if font.attrib["charset"] == "UTF-8":
font.attrib["charset"] = "utf8"
charset = next(key for key, value in Font.CHARSETS.items() if value == font.attrib["charset"])
font_name = font.attrib["name"]
fonts.append(Font(font_id, charset, font_name))
try:
logger.debug(f"Reading font {font.attrib}.")
font_id = int(font.attrib["id"])
if font.attrib["charset"] == "UTF-8":
font.attrib["charset"] = "utf8"
charset = next(key for key, value in Font.CHARSETS.items() if value == font.attrib["charset"])
font_name = font.attrib["name"]
fonts.append(Font(font_id, charset, font_name))
except StopIteration:
logger.warning(f"Ignoring font with invalid charset {font.attrib['charset']}.")

if platform.system() == "Windows":
os_type = CDXFontTable.PLATFORM_WINDOWS
Expand Down

0 comments on commit b2d171c

Please sign in to comment.