From e00975323425bf19c298fdad7246ca104e8f5d94 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Thu, 6 Feb 2014 10:38:58 +1100 Subject: [PATCH] freetype/truetype: support symbol fonts such as Webdings. LGTM=bsiegert R=bsiegert CC=golang-codereviews https://codereview.appspot.com/60380043 --- freetype/truetype/truetype.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/freetype/truetype/truetype.go b/freetype/truetype/truetype.go index 7070aef..96ceef5 100644 --- a/freetype/truetype/truetype.go +++ b/freetype/truetype/truetype.go @@ -119,10 +119,12 @@ func (f *Font) parseCmap() error { languageIndependent = 0 // A 32-bit encoding consists of a most-significant 16-bit Platform ID and a - // least-significant 16-bit Platform Specific ID. - unicodeEncoding = 0x00000003 // PID = 0 (Unicode), PSID = 3 (Unicode 2.0) - microsoftUCS2Encoding = 0x00030001 // PID = 3 (Microsoft), PSID = 1 (UCS-2) - microsoftUCS4Encoding = 0x0003000a // PID = 3 (Microsoft), PSID = 10 (UCS-4) + // 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) + 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) ) if len(f.cmap) < 4 { @@ -143,7 +145,11 @@ func (f *Font) parseCmap() error { if pidPsid == unicodeEncoding { offset, found = int(o), true break - } else if pidPsid == microsoftUCS2Encoding || pidPsid == microsoftUCS4Encoding { + + } else if pidPsid == microsoftSymbolEncoding || + pidPsid == microsoftUCS2Encoding || + pidPsid == microsoftUCS4Encoding { + offset, found = int(o), true // We don't break out of the for loop, so that Unicode can override Microsoft. } -- GitLab