Repository navigation
Fix SHX unifont code-7 subshape number endianness - #1482
Conversation
|
Thanks for merging, and sorry for the late reply to your question here. The concrete example case: in the stock txt.shx and isocp.shx, shape 0x80 is defined as the bytes A direct € in a TEXT entity doesn't show the bug, because that looks up shape 0x20AC directly instead of going through a code-7 reference, which is why the ISOCP test file rendered fine. A DXF that exercises it is one whose text uses a character mapped to a code-7-defined glyph, e.g. character 0x80 in a TXT/ISOCP style. The regression test added with this PR also builds a minimal unifont whose shape 0x80 is exactly |


Fixes #1468.
parse_shape_codes() reads the unifont code-7 subshape number little-endian, but compiled unifont SHX files store it big-endian. Shape 0x80 in txt.shx has raw bytes 07 20 AC 00: the current parser produces subshape 0xAC20, which does not exist in the font, so glyphs defined as subshape references render empty; the big-endian reading 0x20AC exists. I checked 37 stock unifont files: 826 code-7 references, all 826 resolve big-endian and none little-endian. (This is compatible with the € rendering observation in the issue: a direct lookup of glyph 0x20AC never exercises the code-7 path.)
The fix uses the existing DataReader.u16_big() for unifont code 7 only; non-unifont parsing is unchanged.
Tests: tests/test_05_tools/test_533_shapefiles.py + test_515b_fonts_shapefiles.py — 34 passed / 18 skipped before, 37 passed / 18 skipped after (3 new regression tests, including an end-to-end shx_load of a constructed unifont file). Broader run (test_05_tools + render shape tests): 1490 passed, 29 skipped.