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.

Generated 'cmap' format 12.0/13.0 subtable lost the first map entry

See original GitHub issue

I tried generating a font with this snippet for the cmap table:

def generateCmapTable():
    cmap = table__c_m_a_p('cmap')
    cmap.tableVersion = 0
    cmapSubtable = CmapSubtable.newSubtable(12)
    cmapSubtable.format = 12
    cmapSubtable.reserved = 0
    cmapSubtable.platformID = 0
    cmapSubtable.platEncID = 4
    cmapSubtable.language = 0
    cmapSubtable.cmap = {0x1F44C: 'u1F44C', 0x1F44D: 'u1F44D'}
    cmap.tables = [cmapSubtable]
    cmapSubtable.length = 0
    cmapSubtable.nGroups = 0
    return cmap

The only And with the generated .ttf, I use ftxdumperfuser --table cmap --auto-dump test.ttf to dump the cmap table, and inside it I found only one entries of 0x1F44D, the 0x1F44C one is missing. I tested other codepoint as well, basically in all combinations, the first map entry is missing. I also used FTXViewer to lookup table content from the font directly, and observed the same thing. And the codepoint that is missing from the cmap table also cannot be shown when you use the font.

<ft:FTFontTable_cmap xmlns:ft="http://developer.apple.com/fonts/" versionMajor="1" versionMinor="0">
	<ft:cmapSubtable encodingID="0"
		format="12"
		platformID = "0" platformName="Unicode" scriptID="4" scriptName="3.1 or later (surrogates)" languageID="-1" >
		<ft:map charValue="0x1F44D" glyphRefID="1"/>
	</ft:cmapSubtable>
</ft:FTFontTable_cmap>

However, the test._c_m_a_p.ttx file I generated by using ttx -s test.font can output all map entries correctly.

<?xml version="1.0" encoding="UTF-8"?>
<ttFont ttLibVersion="3.0">

  <cmap>
    <tableVersion version="0"/>
    <cmap_format_12 platformID="0" platEncID="4" format="12" reserved="0" length="28" language="0" nGroups="1">
      <map code="0x1f44c" name="u1F44C"/><!-- ???? -->
      <map code="0x1f44d" name="u1F44D"/><!-- ???? -->
    </cmap_format_12>
  </cmap>

</ttFont>

Here is the test font I generated: Test 64.ttf.zip

I also tested format 13.0, get the same results. I’m not sure if it’s an issue on FontToolbox.framework and Apple Font Tool Suite, or an issue from fonttools 😢

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
khaledhosnycommented, Mar 3, 2019

I guess nothing to be done here.

0reactions
behdadcommented, Feb 18, 2017

I take this was intentional, wasn’t it?

Yes. It is implied in OpenType that glyph0 is notdef. Some of the cmap subtables explicitly use this property; ie. they encode a gid=0 when a character is not covered. My change simply uniformly applied that to all subtables. I’m not 100% happy about it, but happy enough to let it be the way it is now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

cmap - Character To Glyph Index Mapping Table (OpenType ...
The table header indicates the character encodings for which subtables are present. Each subtable is in one of seven possible formats and begins ......
Read more >
cmap: Character to Glyph Index Mapping Table - fontTools
This class represents the cmap table, which maps between input characters (in Unicode or other system encodings) and glyphs within the font. The...
Read more >
java - HashMap - getting First Key value - Stack Overflow
You can try this: Map<String,String> map = new HashMap<>(); Map.Entry<String,String> entry = map.entrySet().iterator().next(); String key = entry.
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