[fonttools/fonttools] 7d0902: OS/2: fix setUnicodeRanges round-trip for reserved...

1 view
Skip to first unread message

Cosimo Lupo

unread,
May 13, 2026, 8:55:13 AM (3 days ago) May 13
to fontto...@googlegroups.com
Branch: refs/heads/fix-setUnicodeRanges-bits-123-127
Home: https://github.com/fonttools/fonttools
Commit: 7d0902b2e27ec1433b015b3b8a79391d7c8604cb
https://github.com/fonttools/fonttools/commit/7d0902b2e27ec1433b015b3b8a79391d7c8604cb
Author: Cosimo Lupo <cos...@anthrotype.com>
Date: 2026-05-13 (Wed, 13 May 2026)

Changed paths:
M Lib/fontTools/ttLib/tables/O_S_2f_2.py
M Tests/ttLib/tables/O_S_2f_2_test.py

Log Message:
-----------
OS/2: fix setUnicodeRanges round-trip for reserved bits 123-127

Bits 123-127 are reserved in the OpenType spec and not assigned to any
Unicode block, so the cap at 123 in setUnicodeRanges was intentional.
However, getUnicodeRanges reads all 128 raw bits, so a font with those
reserved bits already set (by another tool) will have them returned by
getUnicodeRanges but rejected by setUnicodeRanges -- causing a crash in
recalcUnicodeRanges(pruneOnly=True), which preserves bits it cannot
evaluate rather than clearing them.

Accept bits 0-127 to allow the round-trip, without assigning any
meaning to the reserved range.

Fixes #4087



To unsubscribe from these emails, change your notification settings at https://github.com/fonttools/fonttools/settings/notifications

Cosimo Lupo

unread,
May 14, 2026, 7:04:24 AM (2 days ago) May 14
to fontto...@googlegroups.com
Branch: refs/heads/main
Home: https://github.com/fonttools/fonttools
Commit: 7d0902b2e27ec1433b015b3b8a79391d7c8604cb
https://github.com/fonttools/fonttools/commit/7d0902b2e27ec1433b015b3b8a79391d7c8604cb
Author: Cosimo Lupo <cos...@anthrotype.com>
Date: 2026-05-13 (Wed, 13 May 2026)

Changed paths:
M Lib/fontTools/ttLib/tables/O_S_2f_2.py
M Tests/ttLib/tables/O_S_2f_2_test.py

Log Message:
-----------
OS/2: fix setUnicodeRanges round-trip for reserved bits 123-127

Bits 123-127 are reserved in the OpenType spec and not assigned to any
Unicode block, so the cap at 123 in setUnicodeRanges was intentional.
However, getUnicodeRanges reads all 128 raw bits, so a font with those
reserved bits already set (by another tool) will have them returned by
getUnicodeRanges but rejected by setUnicodeRanges -- causing a crash in
recalcUnicodeRanges(pruneOnly=True), which preserves bits it cannot
evaluate rather than clearing them.

Accept bits 0-127 to allow the round-trip, without assigning any
meaning to the reserved range.

Fixes #4087


Commit: e84db3ab426a251256ebec7904c03dc73e25932b
https://github.com/fonttools/fonttools/commit/e84db3ab426a251256ebec7904c03dc73e25932b
Author: Cosimo Lupo <cos...@anthrotype.com>
Date: 2026-05-14 (Thu, 14 May 2026)

Changed paths:
M Lib/fontTools/ttLib/tables/O_S_2f_2.py
M Tests/ttLib/tables/O_S_2f_2_test.py

Log Message:
-----------
Merge pull request #4088 from fonttools/fix-setUnicodeRanges-bits-123-127

[OS/2] fix setUnicodeRanges round-trip for reserved bits 123-127


Compare: https://github.com/fonttools/fonttools/compare/06e266ce70ec...e84db3ab426a
Reply all
Reply to author
Forward
0 new messages