mozman / ezdxf

Python interface to DXF
https://ezdxf.mozman.at
MIT License
937 stars 191 forks source link

KeyError: '.notdef' when initializing ttfonts #990

Closed jsimomaa closed 11 months ago

jsimomaa commented 11 months ago

Describe the bug Drawing a layout fails with the following traceback:

2 extra bytes in post.stringData array
Traceback (most recent call last):
  File "utils\render.py", line 44, in draw_layout
  File "ezdxf\addons\drawing\frontend.py", line 236, in draw_layout
  File "ezdxf\addons\drawing\frontend.py", line 270, in draw_entities
  File "ezdxf\addons\drawing\frontend.py", line 806, in _draw_entities
  File "ezdxf\addons\drawing\frontend.py", line 297, in draw_entity
  File "ezdxf\addons\drawing\frontend.py", line 377, in draw_mtext_entity
  File "ezdxf\addons\drawing\frontend.py", line 392, in draw_complex_mtext
  File "ezdxf\addons\drawing\mtext_complex.py", line 188, in complex_mtext_renderer
  File "ezdxf\tools\text_layout.py", line 778, in render
  File "ezdxf\tools\text_layout.py", line 788, in render_content
  File "ezdxf\tools\text_layout.py", line 778, in render
  File "ezdxf\tools\text_layout.py", line 788, in render_content
  File "ezdxf\tools\text_layout.py", line 778, in render
  File "ezdxf\tools\text_layout.py", line 788, in render_content
  File "ezdxf\tools\text_layout.py", line 1446, in render
  File "ezdxf\tools\text_layout.py", line 521, in render_cells
  File "ezdxf\tools\text_layout.py", line 487, in render
  File "ezdxf\addons\drawing\mtext_complex.py", line 175, in render
  File "ezdxf\addons\drawing\designer.py", line 359, in draw_text
  File "ezdxf\addons\drawing\unified_text_renderer.py", line 62, in get_text_glyph_paths
  File "ezdxf\addons\drawing\unified_text_renderer.py", line 39, in get_font
  File "ezdxf\fonts\fonts.py", line 687, in make_font
  File "ezdxf\fonts\fonts.py", line 665, in make_font
  File "ezdxf\fonts\fonts.py", line 485, in __init__
  File "ezdxf\fonts\fonts.py", line 555, in create_cache
  File "ezdxf\fonts\ttfonts.py", line 88, in __init__
  File "fontTools\ttLib\ttGlyphSet.py", line 99, in __getitem__
  File "fontTools\ttLib\ttGlyphSet.py", line 137, in __init__
KeyError: '.notdef'

Note: Does not reproduce on any other computer than one Windows 11 machine.

Therefore no DXF file to reproduce this. Seems to be somehow operating system / computer dependent ?

2 extra bytes in post.stringData array- this seems to come from here:

https://github.com/fonttools/fonttools/blob/d584daa8fdc71030f92ee665472d6c7cddd49283/Lib/fontTools/ttLib/tables/_p_o_s_t.py#L295-L296

ezdxf version 1.1.3
mozman commented 11 months ago

Try the added fix in current beta version 1.1.4b1.