title: What the character codes are in the cmap table in TrueType fonts
body: <p>Wondering what the "character codes" are for the <a href="https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6cmap.html" rel="nofollow noreferrer">cmap table</a> in TrueType fonts. Microsoft talks about the <a href="https://docs.microsoft.com/en-us/typography/opentype/spec/cmap" rel="nofollow noreferrer">Character to Glyph Index Mapping Table</a>, but I don't see what the character or glyph index mean.</p>
  
  <p>Wondering if somewhere in the font file you specify the <em>encoding</em>, such as Unicode 11.0, and then the character codes are equal to the Unicode code points such as <code>U+0061</code> for <code>a</code>. Or if the character codes are instead the "browser" character codes (decimal codes I guess), such as <code>97</code> for <code>a</code>.</p>
  
  <p>Basically wondering how you map keyboard characters to font glyphs, and what that really means. I think you not so much want to map <em>keyboard</em> codes to the font glyphs, but unicode codes like <code>U+0061</code> to the font glyphs, so if in JavaScript (<a href="https://stackoverflow.com/questions/13093126/insert-unicode-character-into-javascript">for example</a>) you can do <code>\u03A9</code> and it will give you <code>Ω</code> if your font supports that.</p>
  
  <p>Trying to understand the anatomy of a font file in terms of how it maps the mathematical glyphs as vectors/paths, to characters or codes of some sort.</p>