Skip to content

Commit

Permalink
Support Unicode Full Repertoire cmap tables.
Browse files Browse the repository at this point in the history
For example, "Apple Color Emoji.ttc" has such a cmap. After this commit,
we can render its glyph for "U+0001F1E6 REGIONAL INDICATOR SYMBOL LETTER
A", which is clearly outside the Unicode BMP.

Note that this only lets us render black-and-white glyphs for out-of-BMP
runes. Rendering color glyphs (i.e. emoji) remains TODO.

Updates #45
  • Loading branch information
nigeltao committed Apr 20, 2017
1 parent 255de57 commit b12e981
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions truetype/truetype.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ const (
// A 32-bit encoding consists of a most-significant 16-bit Platform ID and a
// least-significant 16-bit Platform Specific ID. The magic numbers are
// specified at https://www.microsoft.com/typography/otspec/name.htm
unicodeEncoding = 0x00000003 // PID = 0 (Unicode), PSID = 3 (Unicode 2.0)
unicodeEncodingBMPOnly = 0x00000003 // PID = 0 (Unicode), PSID = 3 (Unicode 2.0 BMP Only)
unicodeEncodingFull = 0x00000004 // PID = 0 (Unicode), PSID = 4 (Unicode 2.0 Full Repertoire)
microsoftSymbolEncoding = 0x00030000 // PID = 3 (Microsoft), PSID = 0 (Symbol)
microsoftUCS2Encoding = 0x00030001 // PID = 3 (Microsoft), PSID = 1 (UCS-2)
microsoftUCS4Encoding = 0x0003000a // PID = 3 (Microsoft), PSID = 10 (UCS-4)
Expand Down Expand Up @@ -142,7 +143,7 @@ func parseSubtables(table []byte, name string, offset, size int, pred func([]byt
pidPsid := u32(table, offset)
// We prefer the Unicode cmap encoding. Failing to find that, we fall
// back onto the Microsoft cmap encoding.
if pidPsid == unicodeEncoding {
if pidPsid == unicodeEncodingBMPOnly || pidPsid == unicodeEncodingFull {
bestOffset, bestPID, ok = offset, pidPsid>>16, true
break

Expand Down

0 comments on commit b12e981

Please sign in to comment.