From 2cbb35362ec16a75167ac6ce38fef3bd6756bf2b Mon Sep 17 00:00:00 2001 From: Brendan Dahl Date: Tue, 8 Jan 2013 10:44:39 -0800 Subject: [PATCH] Add support for more Type1 private dictionary entries. --- src/fonts.js | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/fonts.js b/src/fonts.js index d7c797473..a8d4c07f2 100644 --- a/src/fonts.js +++ b/src/fonts.js @@ -4758,6 +4758,23 @@ var Type1Parser = function type1Parser() { return parseFloat(str.substr(start, count) || 0); } + function readBoolean(str, index) { + while (str[index] == ' ') + index++; + + var start = index; + + var count = 0; + var length = str.length; + while (index < length && str[index++] != ' ') { + count++; + } + + // Use 1 and 0 since that's what type2 charstrings use. + return str.substr(start, count) === 'true' ? 1 : 0; + } + + function isSeparator(c) { return c == ' ' || c == '\n' || c == '\x0d'; } @@ -4874,7 +4891,7 @@ var Type1Parser = function type1Parser() { case '/StdHW': case '/StdVW': program.properties.privateData[token.substring(1)] = - readNumberArray(eexecStr, i + 2)[0]; + readNumberArray(eexecStr, i + 1)[0]; break; case '/BlueShift': case '/lenIV': @@ -4885,6 +4902,10 @@ var Type1Parser = function type1Parser() { program.properties.privateData[token.substring(1)] = readNumber(eexecStr, i + 1); break; + case '/ForceBold': + program.properties.privateData[token.substring(1)] = + readBoolean(eexecStr, i + 1); + break; } } else if (c == '/') { token = glyph = ''; @@ -5242,7 +5263,6 @@ Type1Font.prototype = { var privateDict = new CFFPrivateDict(); privateDict.setByName('Subrs', null); // placeholder var fields = [ - // TODO: missing StdHW, StdVW, ForceBold 'BlueValues', 'OtherBlues', 'FamilyBlues', @@ -5253,7 +5273,10 @@ Type1Font.prototype = { 'BlueFuzz', 'BlueScale', 'LanguageGroup', - 'ExpansionFactor' + 'ExpansionFactor', + 'ForceBold', + 'StdHW', + 'StdVW' ]; for (var i = 0, ii = fields.length; i < ii; i++) { var field = fields[i];