From 2cc89735aea412870c5b3cc0ace446d8b621916c Mon Sep 17 00:00:00 2001 From: notmasteryet Date: Wed, 29 Feb 2012 18:31:03 -0600 Subject: [PATCH] Fixing cap1 statement --- src/fonts.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/fonts.js b/src/fonts.js index 542c33f55..9d11d81cc 100644 --- a/src/fonts.js +++ b/src/fonts.js @@ -1863,6 +1863,13 @@ var Font = (function FontClosure() { var hasShortCmap = !!cmapTable.hasShortCmap; var toFontChar = this.toFontChar; + if (hasShortCmap && ids.length == numGlyphs) { + // Fixes the short cmap tables -- some generators use incorrect + // glyph id. + for (var i = 0, ii = ids.length; i < ii; i++) + ids[i] = i; + } + if (toFontChar && toFontChar.length > 0) { // checking if cmap is just identity map var isIdentity = true; @@ -1906,11 +1913,14 @@ var Font = (function FontClosure() { // copying all characters to private use area, all mapping all known // glyphs to the unicodes. The glyphs and ids arrays will grow. var usedUnicodes = []; + var glyphNames = properties.glyphNames || []; for (var i = 0, ii = glyphs.length; i < ii; i++) { var code = glyphs[i].unicode; + var gid = ids[i]; glyphs[i].unicode += kCmapGlyphOffset; + toFontChar[code] = glyphs[i].unicode; - var glyphName = properties.baseEncoding[code]; + var glyphName = glyphNames[gid] || properties.baseEncoding[code]; if (glyphName in GlyphsUnicode) { var unicode = GlyphsUnicode[glyphName]; if (unicode in usedUnicodes) @@ -1921,9 +1931,11 @@ var Font = (function FontClosure() { unicode: unicode, code: glyphs[i].code }); - ids.push(ids[i]); + ids.push(gid); + toFontChar[code] = unicode; } } + this.useToFontChar = true; } // Moving all symbolic font glyphs into 0xF000 - 0xF0FF range.