question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cmap 4 idDelta is a signed short

See original GitHub issue

I just got sent a font file which fails MS fontval validation due to problems with the cmap table. It’s a CJK font and has lots of glyphs scattered around lots of codepoints. Debugging this, I noticed one immediate problem:

https://docs.microsoft.com/en-us/typography/opentype/spec/cmap#format-4-segment-mapping-to-delta-values :

int16 | idDelta[segCount] | Delta for all character codes in segment.

https://docs.python.org/3/library/struct.html:

Format C Type Python type Standard size Notes
h short integer 2 (2)
H unsigned short integer 2 (2)

https://github.com/fonttools/fonttools/blob/cace698bb029d58cdae00603140438fe4993bfa6/Lib/fontTools/ttLib/tables/_c_m_a_p.py#L907

That should be “h”, right?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
simoncozenscommented, Apr 5, 2022

Correct - I tried that.

1reaction
justvanrossumcommented, Apr 5, 2022

The Apple specification lists it as UInt16, so MS seems to have changed this.

https://docs.microsoft.com/en-us/typography/opentype/spec/cmap

Both specs say “The idDelta arithmetic is modulo 65536”. Not sure how this affects the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to correctly understand TrueType cmap's subtable ...
Can idDelta and idRangeOffset both be non zero in TrueType fonts? 1 · character encoding for TrueType format 0 cmap tables? 1 ·...
Read more >
fontbox/src/main/java/org/apache/fontbox/ttf/CmapSubtable ...
See the License for the specific language governing permissions and ... void initSubtable(CmapTable cmap, int numGlyphs, TTFDataStream data) throws ...
Read more >
cmap - Character To Glyph Index Mapping Table ...
Each segment is described by a startCode and endCode, along with an idDelta and an idRangeOffset, which are used for mapping the character...
Read more >
fonttools/_c_m_a_p.py at main
first determine the subtable format (if in doubt use format 4 for glyphs within ... idDelta is a short, and must be between...
Read more >
Implementing a Font Reader and Rasterizer from Scratch, ...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15. typedef unsigned char u8; typedef char i8; typedef...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found