From 71d0f0d55c4584e2731a9f0e573c183a87f39ea9 Mon Sep 17 00:00:00 2001 From: Vivien Nicolas <21@vingtetun.org> Date: Thu, 8 Sep 2011 13:03:30 +0200 Subject: [PATCH 01/39] Remove a useless check in charsToUnicode --- fonts.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/fonts.js b/fonts.js index bfdbb0b4a..5622e84e4 100755 --- a/fonts.js +++ b/fonts.js @@ -444,7 +444,6 @@ var Font = (function Font() { var constructor = function font_constructor(name, file, properties) { this.name = name; this.encoding = properties.encoding; - this.glyphs = properties.glyphs; this.sizes = []; var names = name.split("+"); @@ -1368,10 +1367,6 @@ var Font = (function Font() { unicode = charcode; } - // Check if the glyph has already been converted - if (!IsNum(unicode)) - unicode = encoding[charcode].unicode = this.glyphs[unicode].unicode; - // Handle surrogate pairs if (unicode > 0xFFFF) { str += String.fromCharCode(unicode & 0xFFFF); From 81d7d1a72515450b25b07eaf482a3591820db46f Mon Sep 17 00:00:00 2001 From: Vivien Nicolas <21@vingtetun.org> Date: Thu, 8 Sep 2011 17:57:37 +0200 Subject: [PATCH 02/39] Add widths information for the most common fonts cases --- fonts.js | 28 +++++++++++++++++-------- pdf.js | 64 ++++++++++++++++++++++++++------------------------------ 2 files changed, 49 insertions(+), 43 deletions(-) diff --git a/fonts.js b/fonts.js index 5622e84e4..cca1d816c 100755 --- a/fonts.js +++ b/fonts.js @@ -140,11 +140,21 @@ var FontMeasure = (function FontMeasure() { ctx.font = rule; current = font; }, - measureText: function fonts_measureText(text) { + measureText: function fonts_measureText(text, encoding, size) { var width; if (measureCache && (width = measureCache[text])) return width; - width = ctx.measureText(text).width / kScalePrecision; + + try { + width = 0.0; + for (var i = 0; i < text.length; i++) { + var charWidth = encoding[text.charCodeAt(i)].width; + width += parseFloat(charWidth); + } + width = width * size / 1000; + } catch(e) { + width = ctx.measureText(text).width / kScalePrecision; + } if (measureCache) measureCache[text] = width; return width; @@ -468,8 +478,7 @@ var Font = (function Font() { (fontName.indexOf('Italic') != -1); // Use 'name' instead of 'fontName' here because the original - // name ArialNarrow for example will be replaced by Helvetica. - this.narrow = (name.indexOf("Narrow") != -1) + // name ArialBlack for example will be replaced by Helvetica. this.black = (name.indexOf("Black") != -1) this.loadedName = fontName.split('-')[0]; @@ -1018,7 +1027,9 @@ var Font = (function Font() { var index = firstCode; for (var j = start; j <= end; j++) { var code = j - firstCode - 1; - encoding[index++] = { unicode: glyphs[code].unicode }; + var mapping = encoding[index + 1] || {}; + mapping.unicode = glyphs[code].unicode; + encoding[index++] = mapping; } return cmap.data = createCMapTable(glyphs); } @@ -2329,12 +2340,11 @@ var Type2CFF = (function() { } } - if (code == -1) { - var mapping = properties.glyphs[glyph] || {}; + var mapping = properties.glyphs[glyph] || {}; + if (code == -1) index = code = mapping.unicode || index; - } - var width = widths[code] || defaultWidth; + var width = mapping.width || defaultWidth; if (code <= 0x1f || (code >= 127 && code <= 255)) code += kCmapGlyphOffset; diff --git a/pdf.js b/pdf.js index 40ffde688..7fff8ae62 100644 --- a/pdf.js +++ b/pdf.js @@ -4273,22 +4273,23 @@ var PartialEvaluator = (function() { var glyphs = {}; for (var i = firstChar; i <= lastChar; i++) { var glyph = differences[i] || baseEncoding[i]; - if (glyph) { - var index = GlyphsUnicode[glyph] || i; - glyphs[glyph] = map[i] = { - unicode: index, - width: properties.widths[i - firstChar] || properties.defaultWidth - }; + var index = GlyphsUnicode[glyph] || i; + map[i] = { + unicode: index, + width: properties.widths[i] || properties.defaultWidth + }; - // If there is no file, the character mapping can't be modified - // but this is unlikely that there is any standard encoding with - // chars below 0x1f, so that's fine. - if (!properties.file) - continue; + if (glyph) + glyphs[glyph] = map[i]; - if (index <= 0x1f || (index >= 127 && index <= 255)) - map[i].unicode += kCmapGlyphOffset; - } + // If there is no file, the character mapping can't be modified + // but this is unlikely that there is any standard encoding with + // chars below 0x1f, so that's fine. + if (!properties.file) + continue; + + if (index <= 0x1f || (index >= 127 && index <= 255)) + map[i].unicode += kCmapGlyphOffset; } if (type == 'TrueType' && dict.has('ToUnicode') && differences) { @@ -4325,10 +4326,9 @@ var PartialEvaluator = (function() { var endRange = tokens[j + 1]; var code = tokens[j + 2]; while (startRange < endRange) { - map[startRange] = { - unicode: code++, - width: 0 - } + var mapping = map[startRange] || {}; + mapping.unicode = code++; + map[startRange] = mapping; ++startRange; } } @@ -4339,10 +4339,9 @@ var PartialEvaluator = (function() { for (var j = 0; j < tokens.length; j += 2) { var index = tokens[j]; var code = tokens[j + 1]; - map[index] = { - unicode: code, - width: 0 - }; + var mapping = map[index] || {}; + mapping.unicode = code; + map[index] = mapping; } break; @@ -4494,13 +4493,13 @@ var PartialEvaluator = (function() { descent: descriptor.get('Descent'), xHeight: descriptor.get('XHeight'), capHeight: descriptor.get('CapHeight'), - defaultWidth: descriptor.get('MissingWidth') || 0, + defaultWidth: parseFloat(descriptor.get('MissingWidth')) || 0, flags: descriptor.get('Flags'), italicAngle: descriptor.get('ItalicAngle'), differences: [], widths: (function() { var glyphWidths = {}; - for (var i = 0; i <= widths.length; i++) + for (var i = 0; i < widths.length; i++) glyphWidths[firstChar++] = widths[i]; return glyphWidths; })(), @@ -4898,6 +4897,7 @@ var CanvasGraphics = (function() { var scaleFactorX = 1, scaleFactorY = 1; var font = current.font; + var baseText= text; if (font) { if (current.fontSize <= kRasterizerMin) { scaleFactorX = scaleFactorY = kScalePrecision; @@ -4907,26 +4907,22 @@ var CanvasGraphics = (function() { text = font.charsToUnicode(text); } + var encoding = current.font.encoding; + var size = current.fontSize; var charSpacing = current.charSpacing; var wordSpacing = current.wordSpacing; var textHScale = current.textHScale; - // This is a poor simulation for Arial Narrow while font-stretch - // is not implemented (bug 3512) - if (current.font.narrow) { - textHScale += 0.2; - charSpacing -= (0.09 * current.fontSize); - } - if (charSpacing != 0 || wordSpacing != 0 || textHScale != 1) { scaleFactorX *= textHScale; ctx.scale(1 / textHScale, 1); var width = 0; for (var i = 0, ii = text.length; i < ii; ++i) { - var c = text.charAt(i); + var c = baseText.charAt(i); ctx.fillText(c, 0, 0); - var charWidth = FontMeasure.measureText(c) + charSpacing; + var charWidth = FontMeasure.measureText(c, encoding, size); + charWidth += charSpacing; if (c.charCodeAt(0) == 32) charWidth += wordSpacing; ctx.translate(charWidth * scaleFactorX, 0); @@ -4935,7 +4931,7 @@ var CanvasGraphics = (function() { current.x += width; } else { ctx.fillText(text, 0, 0); - current.x += FontMeasure.measureText(text); + current.x += FontMeasure.measureText(baseText, encoding, size); } this.ctx.restore(); From bcd86194146651abc05ae335bbbe25ac19b8062c Mon Sep 17 00:00:00 2001 From: Vivien Nicolas <21@vingtetun.org> Date: Sun, 11 Sep 2011 15:23:35 +0200 Subject: [PATCH 03/39] Prevent the deprecated 'dotsection' command in Type1C to hit the sanitizer --- fonts.js | 37 +++++++++++++++++++++++++++++++++--- utils/cffStandardStrings.js | 2 +- utils/fonts_utils.js | 38 +++++++++++++++++++++++-------------- 3 files changed, 59 insertions(+), 18 deletions(-) diff --git a/fonts.js b/fonts.js index cc353c03b..e10007c94 100755 --- a/fonts.js +++ b/fonts.js @@ -2251,7 +2251,7 @@ var Type2CFF = (function() { var strings = this.getStrings(stringIndex); - var baseDict = this.parseDict(dictIndex.get(0)); + var baseDict = this.parseDict(dictIndex.get(0).data); var topDict = this.getTopDict(baseDict, strings); var bytes = this.bytes; @@ -2276,6 +2276,33 @@ var Type2CFF = (function() { if (hasSupplement) bytes[topDict.Encoding] = 0; + // The CFF specification state that the 'dotsection' command + // (12, 0) is deprecated and treated as a no-op, but all Type2 + // charstrings processors should support them. Unfortunately + // the font sanitizer don't. As a workaround the sequence (12, 0) + // is replaced by a useless (0, hmoveto). + var count = charStrings.length; + for (var i = 0; i < count; i++) { + var charstring = charStrings.get(i); + + var start = charstring.start; + var data = charstring.data; + var length = data.length; + for (var j = 0; j <= length; j) { + var value = data[j++]; + if (value == 12 && data[j++] == 0) { + bytes[start + j - 2] = 139; + bytes[start + j - 1] = 22; + } else if (value === 28) { + j += 2; + } else if (value >= 247 && value <= 254) { + j++; + } else if (value == 255) { + j += 4; + } + } + } + // charstrings contains info about glyphs (one element per glyph // containing mappings for {unicode, width}) var charstrings = this.getCharStrings(charset, charStrings, @@ -2566,7 +2593,7 @@ var Type2CFF = (function() { } else if (value <= 254) { return -((value - 251) * 256) - dict[pos++] - 108; } else { - error('Incorrect byte'); + error('255 is not a valid DICT command'); } return -1; }; @@ -2644,7 +2671,11 @@ var Type2CFF = (function() { var start = offsets[index]; var end = offsets[index + 1]; - return bytes.subarray(start, end); + return { + start: start, + end: end, + data: bytes.subarray(start, end) + } }, length: count, endPos: end diff --git a/utils/cffStandardStrings.js b/utils/cffStandardStrings.js index 09c408ee7..7919b0f17 100644 --- a/utils/cffStandardStrings.js +++ b/utils/cffStandardStrings.js @@ -560,7 +560,7 @@ var CFFDictDataMap = { '18': { name: 'ExpansionFactor' }, - '9': { + '19': { name: 'initialRandomSeed' }, '20': { diff --git a/utils/fonts_utils.js b/utils/fonts_utils.js index 7665906a1..2c05a64ba 100644 --- a/utils/fonts_utils.js +++ b/utils/fonts_utils.js @@ -20,17 +20,27 @@ function readCharset(aStream, aCharstrings) { var charset = {}; var format = aStream.getByte(); + var count = aCharstrings.length - 1; if (format == 0) { charset['.notdef'] = readCharstringEncoding(aCharstrings[0]); - var count = aCharstrings.length - 1; for (var i = 1; i < count + 1; i++) { var sid = aStream.getByte() << 8 | aStream.getByte(); charset[CFFStrings[sid]] = readCharstringEncoding(aCharstrings[i]); //log(CFFStrings[sid] + "::" + charset[CFFStrings[sid]]); } } else if (format == 1) { - error('Charset Range are not supported'); + for (var i = 1; i < count + 1; i++) { + var first = aStream.getByte(); + first = (first << 8) | aStream.getByte(); + var numLeft = aStream.getByte(); + for (var j = 0; j <= numLeft; j++) { + var sid = first++; + if (CFFStrings[sid] == 'three') + log(aCharstrings[j]); + charset[CFFStrings[sid]] = readCharstringEncoding(aCharstrings[j]); + } + } } else { error('Invalid charset format'); } @@ -44,6 +54,9 @@ function readCharset(aStream, aCharstrings) { * chapter 3.1. */ function readCharstringEncoding(aString) { + if (!aString) + return ""; + var charstringTokens = []; var count = aString.length; @@ -71,9 +84,9 @@ function readCharstringEncoding(aString) { } else if (value < 247) { token = parseInt(value) - 139; } else if (value < 251) { - token = ((value - 247) * 256) + aString[i++] + 108; + token = (value - 247) * 256 + aString[i++] + 108; } else if (value < 255) { - token = -((value - 251) * 256) - aString[i++] - 108; + token = -(value - 251) * 256 - aString[i++] - 108; } else {// value == 255 token = aString[i++] << 24 | aString[i++] << 16 | aString[i++] << 8 | aString[i]; @@ -146,9 +159,9 @@ function readFontDictData(aString, aMap) { } else if (value <= 246) { token = parseInt(value) - 139; } else if (value <= 250) { - token = ((value - 247) * 256) + aString[i++] + 108; + token = (value - 247) * 256 + aString[i++] + 108; } else if (value <= 254) { - token = -((value - 251) * 256) - aString[i++] - 108; + token = -(value - 251) * 256 - aString[i++] - 108; } else if (value == 255) { error('255 is not a valid DICT command'); } @@ -199,7 +212,7 @@ function readFontIndexData(aStream, aIsByte) { for (var i = 0; i < count + 1; i++) offsets.push(getNextOffset()); - log('Found ' + count + ' objects at offsets :' + + dump('Found ' + count + ' objects at offsets :' + offsets + ' (offsize: ' + offsize + ')'); // Now extract the objects @@ -285,23 +298,20 @@ var Type2Parser = function(aFilePath) { font.set('hdrSize', aStream.getByte()); font.set('offsize', aStream.getByte()); - // Move the cursor after the header - aStream.skip(font.get('hdrSize') - aStream.pos); - // Read the NAME Index dump('Reading Index: Names'); font.set('Names', readFontIndexData(aStream)); - log('Names: ' + font.get('Names')); + dump('Names: ' + font.get('Names')); // Read the Top Dict Index dump('Reading Index: TopDict'); var topDict = readFontIndexData(aStream, true); - log('TopDict: ' + topDict); + dump('TopDict: ' + topDict); // Read the String Index dump('Reading Index: Strings'); var strings = readFontIndexData(aStream); - log('strings: ' + strings); + dump('strings: ' + strings); // Fill up the Strings dictionary with the new unique strings for (var i = 0; i < strings.length; i++) @@ -321,7 +331,7 @@ var Type2Parser = function(aFilePath) { // Reading Private Dict var priv = font.get('Private'); - log('Reading Private Dict (offset: ' + priv.offset + + dump('Reading Private Dict (offset: ' + priv.offset + ' size: ' + priv.size + ')'); aStream.pos = priv.offset; From a7332d178a53fbc99e5f668f2a71d85a1a4ee82d Mon Sep 17 00:00:00 2001 From: Vivien Nicolas <21@vingtetun.org> Date: Sun, 11 Sep 2011 15:32:32 +0200 Subject: [PATCH 04/39] Fix a small error in font encoding --- pdf.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pdf.js b/pdf.js index b4fe814c2..f279e0cdc 100644 --- a/pdf.js +++ b/pdf.js @@ -4939,7 +4939,6 @@ var CanvasGraphics = (function() { } var composite = font.composite; - var encoding = font.encoding; var fontSize = current.fontSize; var charSpacing = current.charSpacing; var wordSpacing = current.wordSpacing; @@ -4956,7 +4955,9 @@ var CanvasGraphics = (function() { var charcode = originalText.charCodeAt(i); } - var charWidth = font.encoding[charcode].width * fontSize * 0.001; + var encoding = font.encoding[charcode]; + var charWidth = (encoding ? encoding.width : font.defaultWidth); + charWidth *= (fontSize * 0.001); charWidth += charSpacing; if (charcode == 32) charWidth += wordSpacing; From ae0f5e62747fd4083c9b76babb790ad11f971707 Mon Sep 17 00:00:00 2001 From: Vivien Nicolas <21@vingtetun.org> Date: Sun, 11 Sep 2011 16:14:28 +0200 Subject: [PATCH 05/39] Fix a regression caused by the last patch to resolve the 'dotsection' issue --- fonts.js | 18 +- utils/cffStandardStrings.js | 394 ------------------------------------ 2 files changed, 9 insertions(+), 403 deletions(-) diff --git a/fonts.js b/fonts.js index e10007c94..8323f895d 100755 --- a/fonts.js +++ b/fonts.js @@ -2534,20 +2534,20 @@ var Type2CFF = (function() { } return dict; }, - getStrings: function cff_getstrings(stringIndex) { - function bytesToString(bytesArr) { - var s = ''; - for (var i = 0, ii = bytesArr.length; i < ii; ++i) - s += String.fromCharCode(bytesArr[i]); - return s; + getStrings: function cff_getStrings(stringIndex) { + function bytesToString(bytesArray) { + var str = ''; + for (var i = 0, length = bytesArray.length; i < length; i++) + str += String.fromCharCode(bytesArray[i]); + return str; } var stringArray = []; - for (var i = 0, ii = CFFStrings.length; i < ii; ++i) + for (var i = 0, length = CFFStrings.length; i < length; i++) stringArray.push(CFFStrings[i]); - for (var i = 0, ii = stringIndex.length; i < ii; ++i) - stringArray.push(bytesToString(stringIndex.get(i))); + for (var i = 0, length = stringIndex.length; i < length; i++) + stringArray.push(bytesToString(stringIndex.get(i).data)); return stringArray; }, diff --git a/utils/cffStandardStrings.js b/utils/cffStandardStrings.js index 7919b0f17..4a63ff597 100644 --- a/utils/cffStandardStrings.js +++ b/utils/cffStandardStrings.js @@ -3,400 +3,6 @@ 'use strict'; -var CFFStrings = [ - '.notdef', - 'space', - 'exclam', - 'quotedbl', - 'numbersign', - 'dollar', - 'percent', - 'ampersand', - 'quoteright', - 'parenleft', - 'parenright', - 'asterisk', - 'plus', - 'comma', - 'hyphen', - 'period', - 'slash', - 'zero', - 'one', - 'two', - 'three', - 'four', - 'five', - 'six', - 'seven', - 'eight', - 'nine', - 'colon', - 'semicolon', - 'less', - 'equal', - 'greater', - 'question', - 'at', - 'A', - 'B', - 'C', - 'D', - 'E', - 'F', - 'G', - 'H', - 'I', - 'J', - 'K', - 'L', - 'M', - 'N', - 'O', - 'P', - 'Q', - 'R', - 'S', - 'T', - 'U', - 'V', - 'W', - 'X', - 'Y', - 'Z', - 'bracketleft', - 'backslash', - 'bracketright', - 'asciicircum', - 'underscore', - 'quoteleft', - 'a', - 'b', - 'c', - 'd', - 'e', - 'f', - 'g', - 'h', - 'i', - 'j', - 'k', - 'l', - 'm', - 'n', - 'o', - 'p', - 'q', - 'r', - 's', - 't', - 'u', - 'v', - 'w', - 'x', - 'y', - 'z', - 'braceleft', - 'bar', - 'braceright', - 'asciitilde', - 'exclamdown', - 'cent', - 'sterling', - 'fraction', - 'yen', - 'florin', - 'section', - 'currency', - 'quotesingle', - 'quotedblleft', - 'guillemotleft', - 'guilsinglleft', - 'guilsinglright', - 'fi', - 'fl', - 'endash', - 'dagger', - 'daggerdbl', - 'periodcentered', - 'paragraph', - 'bullet', - 'quotesinglbase', - 'quotedblbase', - 'quotedblright', - 'guillemotright', - 'ellipsis', - 'perthousand', - 'questiondown', - 'grave', - 'acute', - 'circumflex', - 'tilde', - 'macron', - 'breve', - 'dotaccent', - 'dieresis', - 'ring', - 'cedilla', - 'hungarumlaut', - 'ogonek', - 'caron', - 'emdash', - 'AE', - 'ordfeminine', - 'Lslash', - 'Oslash', - 'OE', - 'ordmasculine', - 'ae', - 'dotlessi', - 'lslash', - 'oslash', - 'oe', - 'germandbls', - 'onesuperior', - 'logicalnot', - 'mu', - 'trademark', - 'Eth', - 'onehalf', - 'plusminus', - 'Thorn', - 'onequarter', - 'divide', - 'brokenbar', - 'degree', - 'thorn', - 'threequarters', - 'twosuperior', - 'registered', - 'minus', - 'eth', - 'multiply', - 'threesuperior', - 'copyright', - 'Aacute', - 'Acircumflex', - 'Adieresis', - 'Agrave', - 'Aring', - 'Atilde', - 'Ccedilla', - 'Eacute', - 'Ecircumflex', - 'Edieresis', - 'Egrave', - 'Iacute', - 'Icircumflex', - 'Idieresis', - 'Igrave', - 'Ntilde', - 'Oacute', - 'Ocircumflex', - 'Odieresis', - 'Ograve', - 'Otilde', - 'Scaron', - 'Uacute', - 'Ucircumflex', - 'Udieresis', - 'Ugrave', - 'Yacute', - 'Ydieresis', - 'Zcaron', - 'aacute', - 'acircumflex', - 'adieresis', - 'agrave', - 'aring', - 'atilde', - 'ccedilla', - 'eacute', - 'ecircumflex', - 'edieresis', - 'egrave', - 'iacute', - 'icircumflex', - 'idieresis', - 'igrave', - 'ntilde', - 'oacute', - 'ocircumflex', - 'odieresis', - 'ograve', - 'otilde', - 'scaron', - 'uacute', - 'ucircumflex', - 'udieresis', - 'ugrave', - 'yacute', - 'ydieresis', - 'zcaron', - 'exclamsmall', - 'Hungarumlautsmall', - 'dollaroldstyle', - 'dollarsuperior', - 'ampersandsmall', - 'Acutesmall', - 'parenleftsuperior', - 'parenrightsuperior', - '266 ff', - 'onedotenleader', - 'zerooldstyle', - 'oneoldstyle', - 'twooldstyle', - 'threeoldstyle', - 'fouroldstyle', - 'fiveoldstyle', - 'sixoldstyle', - 'sevenoldstyle', - 'eightoldstyle', - 'nineoldstyle', - 'commasuperior', - 'threequartersemdash', - 'periodsuperior', - 'questionsmall', - 'asuperior', - 'bsuperior', - 'centsuperior', - 'dsuperior', - 'esuperior', - 'isuperior', - 'lsuperior', - 'msuperior', - 'nsuperior', - 'osuperior', - 'rsuperior', - 'ssuperior', - 'tsuperior', - 'ff', - 'ffi', - 'ffl', - 'parenleftinferior', - 'parenrightinferior', - 'Circumflexsmall', - 'hyphensuperior', - 'Gravesmall', - 'Asmall', - 'Bsmall', - 'Csmall', - 'Dsmall', - 'Esmall', - 'Fsmall', - 'Gsmall', - 'Hsmall', - 'Ismall', - 'Jsmall', - 'Ksmall', - 'Lsmall', - 'Msmall', - 'Nsmall', - 'Osmall', - 'Psmall', - 'Qsmall', - 'Rsmall', - 'Ssmall', - 'Tsmall', - 'Usmall', - 'Vsmall', - 'Wsmall', - 'Xsmall', - 'Ysmall', - 'Zsmall', - 'colonmonetary', - 'onefitted', - 'rupiah', - 'Tildesmall', - 'exclamdownsmall', - 'centoldstyle', - 'Lslashsmall', - 'Scaronsmall', - 'Zcaronsmall', - 'Dieresissmall', - 'Brevesmall', - 'Caronsmall', - 'Dotaccentsmall', - 'Macronsmall', - 'figuredash', - 'hypheninferior', - 'Ogoneksmall', - 'Ringsmall', - 'Cedillasmall', - 'questiondownsmall', - 'oneeighth', - 'threeeighths', - 'fiveeighths', - 'seveneighths', - 'onethird', - 'twothirds', - 'zerosuperior', - 'foursuperior', - 'fivesuperior', - 'sixsuperior', - 'sevensuperior', - 'eightsuperior', - 'ninesuperior', - 'zeroinferior', - 'oneinferior', - 'twoinferior', - 'threeinferior', - 'fourinferior', - 'fiveinferior', - 'sixinferior', - 'seveninferior', - 'eightinferior', - 'nineinferior', - 'centinferior', - 'dollarinferior', - 'periodinferior', - 'commainferior', - 'Agravesmall', - 'Aacutesmall', - 'Acircumflexsmall', - 'Atildesmall', - 'Adieresissmall', - 'Aringsmall', - 'AEsmall', - 'Ccedillasmall', - 'Egravesmall', - 'Eacutesmall', - 'Ecircumflexsmall', - 'Edieresissmall', - 'Igravesmall', - 'Iacutesmall', - 'Icircumflexsmall', - 'Idieresissmall', - 'Ethsmall', - 'Ntildesmall', - 'Ogravesmall', - 'Oacutesmall', - 'Ocircumflexsmall', - 'Otildesmall', - 'Odieresissmall', - 'OEsmall', - 'Oslashsmall', - 'Ugravesmall', - 'Uacutesmall', - 'Ucircumflexsmall', - 'Udieresissmall', - 'Yacutesmall', - 'Thornsmall', - 'Ydieresissmall', - '001.000', - '001.001', - '001.002', - '001.003', - 'Black', - 'Bold', - 'Book', - 'Light', - 'Medium', - 'Regular', - 'Roman', - 'Semibold' -]; - var CFFEncodingMap = { '0': '-reserved-', '1': 'hstem', From 95ca8ede85f2d08f6d67cc93394d436ad75e8076 Mon Sep 17 00:00:00 2001 From: Vivien Nicolas <21@vingtetun.org> Date: Sun, 11 Sep 2011 17:38:02 +0200 Subject: [PATCH 06/39] Add support for Type1C advanced charsets --- charsets.js | 101 ++++++++++++++++++++++++++++++++++++++++++++++++ fonts.js | 35 ++++++++++------- web/viewer.html | 1 + 3 files changed, 122 insertions(+), 15 deletions(-) create mode 100644 charsets.js diff --git a/charsets.js b/charsets.js new file mode 100644 index 000000000..4066976c9 --- /dev/null +++ b/charsets.js @@ -0,0 +1,101 @@ + +var ISOAdobeCharset = [ + ".notdef", "space", "exclam", "quotedbl", "numbersign", "dollar", + "percent", "ampersand", "quoteright", "parenleft", "parenright", + "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", + "one", "two", "three", "four", "five", "six", "seven", "eight", + "nine", "colon", "semicolon", "less", "equal", "greater", "question", + "at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", + "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", + "bracketleft", "backslash", "bracketright", "asciicircum", "underscore", + "quoteleft", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", + "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", + "braceleft", "bar", "braceright", "asciitilde", "exclamdown", "cent", + "sterling", "fraction", "yen", "florin", "section", "currency", + "quotesingle", "quotedblleft", "guillemotleft", "guilsinglleft", + "guilsinglright", "fi", "fl", "endash", "dagger", "daggerdbl", + "periodcentered", "paragraph", "bullet", "quotesinglbase", + "quotedblbase", "quotedblright", "guillemotright", "ellipsis", + "perthousand", "questiondown", "grave", "acute", "circumflex", "tilde", + "macron", "breve", "dotaccent", "dieresis", "ring", "cedilla", + "hungarumlaut", "ogonek", "caron", "emdash", "AE", "ordfeminine", + "Lslash", "Oslash", "OE", "ordmasculine", "ae", "dotlessi", "lslash", + "oslash", "oe", "germandbls", "onesuperior", "logicalnot", "mu", + "trademark", "Eth", "onehalf", "plusminus", "Thorn", "onequarter", + "divide", "brokenbar", "degree", "thorn", "threequarters", "twosuperior", + "registered", "minus", "eth", "multiply", "threesuperior", "copyright", + "Aacute", "Acircumflex", "Adieresis", "Agrave", "Aring", "Atilde", + "Ccedilla", "Eacute", "Ecircumflex", "Edieresis", "Egrave", "Iacute", + "Icircumflex", "Idieresis", "Igrave", "Ntilde", "Oacute", "Ocircumflex", + "Odieresis", "Ograve", "Otilde", "Scaron", "Uacute", "Ucircumflex", + "Udieresis", "Ugrave", "Yacute", "Ydieresis", "Zcaron", "aacute", + "acircumflex", "adieresis", "agrave", "aring", "atilde", "ccedilla", + "eacute", "ecircumflex", "edieresis", "egrave", "iacute", "icircumflex", + "idieresis", "igrave", "ntilde", "oacute", "ocircumflex", "odieresis", + "ograve", "otilde", "scaron", "uacute", "ucircumflex", "udieresis", + "ugrave", "yacute", "ydieresis", "zcaron" +]; + +var ExpertCharset = [ + ".notdef", "space", "exclamsmall", "Hungarumlautsmall", "dollaroldstyle", + "dollarsuperior", "ampersandsmall", "Acutesmall", "parenleftsuperior", + "parenrightsuperior", "twodotenleader", "onedotenleader", "comma", + "hyphen", "period", "fraction", "zerooldstyle", "oneoldstyle", + "twooldstyle", "threeoldstyle", "fouroldstyle", "fiveoldstyle", + "sixoldstyle", "sevenoldstyle", "eightoldstyle", "nineoldstyle", + "colon", "semicolon", "commasuperior", "threequartersemdash", + "periodsuperior", "questionsmall", "asuperior", "bsuperior", + "centsuperior", "dsuperior", "esuperior", "isuperior", "lsuperior", + "msuperior", "nsuperior", "osuperior", "rsuperior", "ssuperior", + "tsuperior", "ff", "fi", "fl", "ffi", "ffl", "parenleftinferior", + "parenrightinferior", "Circumflexsmall", "hyphensuperior", "Gravesmall", + "Asmall", "Bsmall", "Csmall", "Dsmall", "Esmall", "Fsmall", "Gsmall", + "Hsmall", "Ismall", "Jsmall", "Ksmall", "Lsmall", "Msmall", "Nsmall", + "Osmall", "Psmall", "Qsmall", "Rsmall", "Ssmall", "Tsmall", "Usmall", + "Vsmall", "Wsmall", "Xsmall", "Ysmall", "Zsmall", "colonmonetary", + "onefitted", "rupiah", "Tildesmall", "exclamdownsmall", "centoldstyle", + "Lslashsmall", "Scaronsmall", "Zcaronsmall", "Dieresissmall", + "Brevesmall", "Caronsmall", "Dotaccentsmall", "Macronsmall", + "figuredash", "hypheninferior", "Ogoneksmall", "Ringsmall", + "Cedillasmall", "onequarter", "onehalf", "threequarters", + "questiondownsmall", "oneeighth", "threeeighths", "fiveeighths", + "seveneighths", "onethird", "twothirds", "zerosuperior", "onesuperior", + "twosuperior", "threesuperior", "foursuperior", "fivesuperior", + "sixsuperior", "sevensuperior", "eightsuperior", "ninesuperior", + "zeroinferior", "oneinferior", "twoinferior", "threeinferior", + "fourinferior", "fiveinferior", "sixinferior", "seveninferior", + "eightinferior", "nineinferior", "centinferior", "dollarinferior", + "periodinferior", "commainferior", "Agravesmall", "Aacutesmall", + "Acircumflexsmall", "Atildesmall", "Adieresissmall", "Aringsmall", + "AEsmall", "Ccedillasmall", "Egravesmall", "Eacutesmall", + "Ecircumflexsmall", "Edieresissmall", "Igravesmall", "Iacutesmall", + "Icircumflexsmall", "Idieresissmall", "Ethsmall", "Ntildesmall", + "Ogravesmall", "Oacutesmall", "Ocircumflexsmall", "Otildesmall", + "Odieresissmall", "OEsmall", "Oslashsmall", "Ugravesmall", "Uacutesmall", + "Ucircumflexsmall", "Udieresissmall", "Yacutesmall", "Thornsmall", + "Ydieresissmall" +]; + +var ExpertSubsetCharset = [ + ".notdef", "space", "dollaroldstyle", "dollarsuperior", + "parenleftsuperior", "parenrightsuperior", "twodotenleader", + "onedotenleader", "comma", "hyphen", "period", "fraction", + "zerooldstyle", "oneoldstyle", "twooldstyle", "threeoldstyle", + "fouroldstyle", "fiveoldstyle", "sixoldstyle", "sevenoldstyle", + "eightoldstyle", "nineoldstyle", "colon", "semicolon", "commasuperior", + "threequartersemdash", "periodsuperior", "asuperior", "bsuperior", + "centsuperior", "dsuperior", "esuperior", "isuperior", "lsuperior", + "msuperior", "nsuperior", "osuperior", "rsuperior", "ssuperior", + "tsuperior", "ff", "fi", "fl", "ffi", "ffl", "parenleftinferior", + "parenrightinferior", "hyphensuperior", "colonmonetary", "onefitted", + "rupiah", "centoldstyle", "figuredash", "hypheninferior", "onequarter", + "onehalf", "threequarters", "oneeighth", "threeeighths", "fiveeighths", + "seveneighths", "onethird", "twothirds", "zerosuperior", "onesuperior", + "twosuperior", "threesuperior", "foursuperior", "fivesuperior", + "sixsuperior", "sevensuperior", "eightsuperior", "ninesuperior", + "zeroinferior", "oneinferior", "twoinferior", "threeinferior", + "fourinferior", "fiveinferior", "sixinferior", "seveninferior", + "eightinferior", "nineinferior", "centinferior", "dollarinferior", + "periodinferior", "commainferior" +]; + diff --git a/fonts.js b/fonts.js index 8323f895d..6a361e60e 100755 --- a/fonts.js +++ b/fonts.js @@ -2429,37 +2429,42 @@ var Type2CFF = (function() { }, parseCharsets: function cff_parsecharsets(pos, length, strings) { + if (pos == 0) { + return ISOAdobeCharset; + } else if (pos == 1) { + return CFFExpertCharset; + } else if (pos == 2) { + return CFFExpertSubsetCharset; + } + var bytes = this.bytes; var format = bytes[pos++]; var charset = ['.notdef']; + // subtract 1 for the .notdef glyph length -= 1; switch (format) { case 0: - for (var i = 0; i < length; ++i) { - var id = bytes[pos++]; - id = (id << 8) | bytes[pos++]; - charset.push(strings[id]); + for (var i = 0; i < length; i++) { + var sid = (bytes[pos++] << 8) | bytes[pos++]; + charset.push(strings[sid]); } break; case 1: while (charset.length <= length) { - var first = bytes[pos++]; - first = (first << 8) | bytes[pos++]; - var numLeft = bytes[pos++]; - for (var i = 0; i <= numLeft; ++i) - charset.push(strings[first++]); + var sid = (bytes[pos++] << 8) | bytes[pos++]; + var count = bytes[pos++]; + for (var i = 0; i <= count; i++) + charset.push(strings[sid++]); } break; case 2: while (charset.length <= length) { - var first = bytes[pos++]; - first = (first << 8) | bytes[pos++]; - var numLeft = bytes[pos++]; - numLeft = (numLeft << 8) | bytes[pos++]; - for (var i = 0; i <= numLeft; ++i) - charset.push(strings[first++]); + var sid = (bytes[pos++] << 8) | bytes[pos++]; + var count = (bytes[pos++] << 8) | bytes[pos++]; + for (var i = 0; i <= count; i++) + charset.push(strings[sid++]); } break; default: diff --git a/web/viewer.html b/web/viewer.html index a53593df3..00950a44c 100644 --- a/web/viewer.html +++ b/web/viewer.html @@ -11,6 +11,7 @@ +
From 538d26521d02bcc0690555dd2f6c30b1ef59d892 Mon Sep 17 00:00:00 2001 From: Vivien Nicolas <21@vingtetun.org> Date: Mon, 12 Sep 2011 18:32:46 +0200 Subject: [PATCH 07/39] Basic support for the embedded font file of CIDFontType0 --- fonts.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/fonts.js b/fonts.js index 6a361e60e..beecf0459 100755 --- a/fonts.js +++ b/fonts.js @@ -448,7 +448,7 @@ var Font = (function Font() { this.mimetype = 'font/opentype'; var subtype = properties.subtype; - var cff = (subtype === 'Type1C') ? + var cff = (subtype == 'Type1C' || properties.type == 'CIDFontType0') ? new Type2CFF(file, properties) : new CFF(name, file, properties); // Wrap the CFF data inside an OTF font file @@ -2256,11 +2256,16 @@ var Type2CFF = (function() { var bytes = this.bytes; + var privateDict = {}; var privateInfo = topDict.Private; - var privOffset = privateInfo[1], privLength = privateInfo[0]; - var privBytes = bytes.subarray(privOffset, privOffset + privLength); - baseDict = this.parseDict(privBytes); - var privDict = this.getPrivDict(baseDict, strings); + if (privateInfo) { + var privOffset = privateInfo[1], privLength = privateInfo[0]; + var privBytes = bytes.subarray(privOffset, privOffset + privLength); + baseDict = this.parseDict(privBytes); + privateDict = this.getPrivDict(baseDict, strings); + } else { + privateDict.defaultWidthX = properties.defaultWidth; + } var charStrings = this.parseIndex(topDict.CharStrings); var charset = this.parseCharsets(topDict.charset, @@ -2306,7 +2311,7 @@ var Type2CFF = (function() { // charstrings contains info about glyphs (one element per glyph // containing mappings for {unicode, width}) var charstrings = this.getCharStrings(charset, charStrings, - privDict, this.properties); + privateDict, this.properties); // create the mapping between charstring and glyph id var glyphIds = []; @@ -2323,10 +2328,8 @@ var Type2CFF = (function() { }, getCharStrings: function cff_charstrings(charsets, charStrings, - privDict, properties) { - var defaultWidth = privDict['defaultWidthX']; - var nominalWidth = privDict['nominalWidthX']; - + privateDict, properties) { + var defaultWidth = privateDict['defaultWidthX']; var charstrings = []; var differences = properties.differences; var index = 0; From f3c20150bd4b04de6d06cae0870f7a2f744aadf3 Mon Sep 17 00:00:00 2001 From: Vivien Nicolas <21@vingtetun.org> Date: Tue, 20 Sep 2011 04:26:37 +0200 Subject: [PATCH 08/39] Fix lint errors and add metrics.js and charsets.js to the default set of pdf files in the Makefile --- Makefile | 2 + charsets.js | 182 ++++++++++++++++++++++++++-------------------------- fonts.js | 4 +- 3 files changed, 95 insertions(+), 93 deletions(-) diff --git a/Makefile b/Makefile index fb4ffe9cb..56b597e5f 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,8 @@ PDF_JS_FILES = \ pdf.js \ crypto.js \ fonts.js \ + metrics.js \ + charsets.js \ glyphlist.js \ $(NULL) diff --git a/charsets.js b/charsets.js index 4066976c9..59fcdf5cf 100644 --- a/charsets.js +++ b/charsets.js @@ -1,101 +1,101 @@ var ISOAdobeCharset = [ - ".notdef", "space", "exclam", "quotedbl", "numbersign", "dollar", - "percent", "ampersand", "quoteright", "parenleft", "parenright", - "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", - "one", "two", "three", "four", "five", "six", "seven", "eight", - "nine", "colon", "semicolon", "less", "equal", "greater", "question", - "at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", - "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", - "bracketleft", "backslash", "bracketright", "asciicircum", "underscore", - "quoteleft", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", - "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", - "braceleft", "bar", "braceright", "asciitilde", "exclamdown", "cent", - "sterling", "fraction", "yen", "florin", "section", "currency", - "quotesingle", "quotedblleft", "guillemotleft", "guilsinglleft", - "guilsinglright", "fi", "fl", "endash", "dagger", "daggerdbl", - "periodcentered", "paragraph", "bullet", "quotesinglbase", - "quotedblbase", "quotedblright", "guillemotright", "ellipsis", - "perthousand", "questiondown", "grave", "acute", "circumflex", "tilde", - "macron", "breve", "dotaccent", "dieresis", "ring", "cedilla", - "hungarumlaut", "ogonek", "caron", "emdash", "AE", "ordfeminine", - "Lslash", "Oslash", "OE", "ordmasculine", "ae", "dotlessi", "lslash", - "oslash", "oe", "germandbls", "onesuperior", "logicalnot", "mu", - "trademark", "Eth", "onehalf", "plusminus", "Thorn", "onequarter", - "divide", "brokenbar", "degree", "thorn", "threequarters", "twosuperior", - "registered", "minus", "eth", "multiply", "threesuperior", "copyright", - "Aacute", "Acircumflex", "Adieresis", "Agrave", "Aring", "Atilde", - "Ccedilla", "Eacute", "Ecircumflex", "Edieresis", "Egrave", "Iacute", - "Icircumflex", "Idieresis", "Igrave", "Ntilde", "Oacute", "Ocircumflex", - "Odieresis", "Ograve", "Otilde", "Scaron", "Uacute", "Ucircumflex", - "Udieresis", "Ugrave", "Yacute", "Ydieresis", "Zcaron", "aacute", - "acircumflex", "adieresis", "agrave", "aring", "atilde", "ccedilla", - "eacute", "ecircumflex", "edieresis", "egrave", "iacute", "icircumflex", - "idieresis", "igrave", "ntilde", "oacute", "ocircumflex", "odieresis", - "ograve", "otilde", "scaron", "uacute", "ucircumflex", "udieresis", - "ugrave", "yacute", "ydieresis", "zcaron" + '.notdef', 'space', 'exclam', 'quotedbl', 'numbersign', 'dollar', + 'percent', 'ampersand', 'quoteright', 'parenleft', 'parenright', + 'asterisk', 'plus', 'comma', 'hyphen', 'period', 'slash', 'zero', + 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', + 'nine', 'colon', 'semicolon', 'less', 'equal', 'greater', 'question', + 'at', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', + 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + 'bracketleft', 'backslash', 'bracketright', 'asciicircum', 'underscore', + 'quoteleft', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', + 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', + 'braceleft', 'bar', 'braceright', 'asciitilde', 'exclamdown', 'cent', + 'sterling', 'fraction', 'yen', 'florin', 'section', 'currency', + 'quotesingle', 'quotedblleft', 'guillemotleft', 'guilsinglleft', + 'guilsinglright', 'fi', 'fl', 'endash', 'dagger', 'daggerdbl', + 'periodcentered', 'paragraph', 'bullet', 'quotesinglbase', + 'quotedblbase', 'quotedblright', 'guillemotright', 'ellipsis', + 'perthousand', 'questiondown', 'grave', 'acute', 'circumflex', 'tilde', + 'macron', 'breve', 'dotaccent', 'dieresis', 'ring', 'cedilla', + 'hungarumlaut', 'ogonek', 'caron', 'emdash', 'AE', 'ordfeminine', + 'Lslash', 'Oslash', 'OE', 'ordmasculine', 'ae', 'dotlessi', 'lslash', + 'oslash', 'oe', 'germandbls', 'onesuperior', 'logicalnot', 'mu', + 'trademark', 'Eth', 'onehalf', 'plusminus', 'Thorn', 'onequarter', + 'divide', 'brokenbar', 'degree', 'thorn', 'threequarters', 'twosuperior', + 'registered', 'minus', 'eth', 'multiply', 'threesuperior', 'copyright', + 'Aacute', 'Acircumflex', 'Adieresis', 'Agrave', 'Aring', 'Atilde', + 'Ccedilla', 'Eacute', 'Ecircumflex', 'Edieresis', 'Egrave', 'Iacute', + 'Icircumflex', 'Idieresis', 'Igrave', 'Ntilde', 'Oacute', 'Ocircumflex', + 'Odieresis', 'Ograve', 'Otilde', 'Scaron', 'Uacute', 'Ucircumflex', + 'Udieresis', 'Ugrave', 'Yacute', 'Ydieresis', 'Zcaron', 'aacute', + 'acircumflex', 'adieresis', 'agrave', 'aring', 'atilde', 'ccedilla', + 'eacute', 'ecircumflex', 'edieresis', 'egrave', 'iacute', 'icircumflex', + 'idieresis', 'igrave', 'ntilde', 'oacute', 'ocircumflex', 'odieresis', + 'ograve', 'otilde', 'scaron', 'uacute', 'ucircumflex', 'udieresis', + 'ugrave', 'yacute', 'ydieresis', 'zcaron' ]; var ExpertCharset = [ - ".notdef", "space", "exclamsmall", "Hungarumlautsmall", "dollaroldstyle", - "dollarsuperior", "ampersandsmall", "Acutesmall", "parenleftsuperior", - "parenrightsuperior", "twodotenleader", "onedotenleader", "comma", - "hyphen", "period", "fraction", "zerooldstyle", "oneoldstyle", - "twooldstyle", "threeoldstyle", "fouroldstyle", "fiveoldstyle", - "sixoldstyle", "sevenoldstyle", "eightoldstyle", "nineoldstyle", - "colon", "semicolon", "commasuperior", "threequartersemdash", - "periodsuperior", "questionsmall", "asuperior", "bsuperior", - "centsuperior", "dsuperior", "esuperior", "isuperior", "lsuperior", - "msuperior", "nsuperior", "osuperior", "rsuperior", "ssuperior", - "tsuperior", "ff", "fi", "fl", "ffi", "ffl", "parenleftinferior", - "parenrightinferior", "Circumflexsmall", "hyphensuperior", "Gravesmall", - "Asmall", "Bsmall", "Csmall", "Dsmall", "Esmall", "Fsmall", "Gsmall", - "Hsmall", "Ismall", "Jsmall", "Ksmall", "Lsmall", "Msmall", "Nsmall", - "Osmall", "Psmall", "Qsmall", "Rsmall", "Ssmall", "Tsmall", "Usmall", - "Vsmall", "Wsmall", "Xsmall", "Ysmall", "Zsmall", "colonmonetary", - "onefitted", "rupiah", "Tildesmall", "exclamdownsmall", "centoldstyle", - "Lslashsmall", "Scaronsmall", "Zcaronsmall", "Dieresissmall", - "Brevesmall", "Caronsmall", "Dotaccentsmall", "Macronsmall", - "figuredash", "hypheninferior", "Ogoneksmall", "Ringsmall", - "Cedillasmall", "onequarter", "onehalf", "threequarters", - "questiondownsmall", "oneeighth", "threeeighths", "fiveeighths", - "seveneighths", "onethird", "twothirds", "zerosuperior", "onesuperior", - "twosuperior", "threesuperior", "foursuperior", "fivesuperior", - "sixsuperior", "sevensuperior", "eightsuperior", "ninesuperior", - "zeroinferior", "oneinferior", "twoinferior", "threeinferior", - "fourinferior", "fiveinferior", "sixinferior", "seveninferior", - "eightinferior", "nineinferior", "centinferior", "dollarinferior", - "periodinferior", "commainferior", "Agravesmall", "Aacutesmall", - "Acircumflexsmall", "Atildesmall", "Adieresissmall", "Aringsmall", - "AEsmall", "Ccedillasmall", "Egravesmall", "Eacutesmall", - "Ecircumflexsmall", "Edieresissmall", "Igravesmall", "Iacutesmall", - "Icircumflexsmall", "Idieresissmall", "Ethsmall", "Ntildesmall", - "Ogravesmall", "Oacutesmall", "Ocircumflexsmall", "Otildesmall", - "Odieresissmall", "OEsmall", "Oslashsmall", "Ugravesmall", "Uacutesmall", - "Ucircumflexsmall", "Udieresissmall", "Yacutesmall", "Thornsmall", - "Ydieresissmall" + '.notdef', 'space', 'exclamsmall', 'Hungarumlautsmall', 'dollaroldstyle', + 'dollarsuperior', 'ampersandsmall', 'Acutesmall', 'parenleftsuperior', + 'parenrightsuperior', 'twodotenleader', 'onedotenleader', 'comma', + 'hyphen', 'period', 'fraction', 'zerooldstyle', 'oneoldstyle', + 'twooldstyle', 'threeoldstyle', 'fouroldstyle', 'fiveoldstyle', + 'sixoldstyle', 'sevenoldstyle', 'eightoldstyle', 'nineoldstyle', + 'colon', 'semicolon', 'commasuperior', 'threequartersemdash', + 'periodsuperior', 'questionsmall', 'asuperior', 'bsuperior', + 'centsuperior', 'dsuperior', 'esuperior', 'isuperior', 'lsuperior', + 'msuperior', 'nsuperior', 'osuperior', 'rsuperior', 'ssuperior', + 'tsuperior', 'ff', 'fi', 'fl', 'ffi', 'ffl', 'parenleftinferior', + 'parenrightinferior', 'Circumflexsmall', 'hyphensuperior', 'Gravesmall', + 'Asmall', 'Bsmall', 'Csmall', 'Dsmall', 'Esmall', 'Fsmall', 'Gsmall', + 'Hsmall', 'Ismall', 'Jsmall', 'Ksmall', 'Lsmall', 'Msmall', 'Nsmall', + 'Osmall', 'Psmall', 'Qsmall', 'Rsmall', 'Ssmall', 'Tsmall', 'Usmall', + 'Vsmall', 'Wsmall', 'Xsmall', 'Ysmall', 'Zsmall', 'colonmonetary', + 'onefitted', 'rupiah', 'Tildesmall', 'exclamdownsmall', 'centoldstyle', + 'Lslashsmall', 'Scaronsmall', 'Zcaronsmall', 'Dieresissmall', + 'Brevesmall', 'Caronsmall', 'Dotaccentsmall', 'Macronsmall', + 'figuredash', 'hypheninferior', 'Ogoneksmall', 'Ringsmall', + 'Cedillasmall', 'onequarter', 'onehalf', 'threequarters', + 'questiondownsmall', 'oneeighth', 'threeeighths', 'fiveeighths', + 'seveneighths', 'onethird', 'twothirds', 'zerosuperior', 'onesuperior', + 'twosuperior', 'threesuperior', 'foursuperior', 'fivesuperior', + 'sixsuperior', 'sevensuperior', 'eightsuperior', 'ninesuperior', + 'zeroinferior', 'oneinferior', 'twoinferior', 'threeinferior', + 'fourinferior', 'fiveinferior', 'sixinferior', 'seveninferior', + 'eightinferior', 'nineinferior', 'centinferior', 'dollarinferior', + 'periodinferior', 'commainferior', 'Agravesmall', 'Aacutesmall', + 'Acircumflexsmall', 'Atildesmall', 'Adieresissmall', 'Aringsmall', + 'AEsmall', 'Ccedillasmall', 'Egravesmall', 'Eacutesmall', + 'Ecircumflexsmall', 'Edieresissmall', 'Igravesmall', 'Iacutesmall', + 'Icircumflexsmall', 'Idieresissmall', 'Ethsmall', 'Ntildesmall', + 'Ogravesmall', 'Oacutesmall', 'Ocircumflexsmall', 'Otildesmall', + 'Odieresissmall', 'OEsmall', 'Oslashsmall', 'Ugravesmall', 'Uacutesmall', + 'Ucircumflexsmall', 'Udieresissmall', 'Yacutesmall', 'Thornsmall', + 'Ydieresissmall' ]; var ExpertSubsetCharset = [ - ".notdef", "space", "dollaroldstyle", "dollarsuperior", - "parenleftsuperior", "parenrightsuperior", "twodotenleader", - "onedotenleader", "comma", "hyphen", "period", "fraction", - "zerooldstyle", "oneoldstyle", "twooldstyle", "threeoldstyle", - "fouroldstyle", "fiveoldstyle", "sixoldstyle", "sevenoldstyle", - "eightoldstyle", "nineoldstyle", "colon", "semicolon", "commasuperior", - "threequartersemdash", "periodsuperior", "asuperior", "bsuperior", - "centsuperior", "dsuperior", "esuperior", "isuperior", "lsuperior", - "msuperior", "nsuperior", "osuperior", "rsuperior", "ssuperior", - "tsuperior", "ff", "fi", "fl", "ffi", "ffl", "parenleftinferior", - "parenrightinferior", "hyphensuperior", "colonmonetary", "onefitted", - "rupiah", "centoldstyle", "figuredash", "hypheninferior", "onequarter", - "onehalf", "threequarters", "oneeighth", "threeeighths", "fiveeighths", - "seveneighths", "onethird", "twothirds", "zerosuperior", "onesuperior", - "twosuperior", "threesuperior", "foursuperior", "fivesuperior", - "sixsuperior", "sevensuperior", "eightsuperior", "ninesuperior", - "zeroinferior", "oneinferior", "twoinferior", "threeinferior", - "fourinferior", "fiveinferior", "sixinferior", "seveninferior", - "eightinferior", "nineinferior", "centinferior", "dollarinferior", - "periodinferior", "commainferior" + '.notdef', 'space', 'dollaroldstyle', 'dollarsuperior', + 'parenleftsuperior', 'parenrightsuperior', 'twodotenleader', + 'onedotenleader', 'comma', 'hyphen', 'period', 'fraction', + 'zerooldstyle', 'oneoldstyle', 'twooldstyle', 'threeoldstyle', + 'fouroldstyle', 'fiveoldstyle', 'sixoldstyle', 'sevenoldstyle', + 'eightoldstyle', 'nineoldstyle', 'colon', 'semicolon', 'commasuperior', + 'threequartersemdash', 'periodsuperior', 'asuperior', 'bsuperior', + 'centsuperior', 'dsuperior', 'esuperior', 'isuperior', 'lsuperior', + 'msuperior', 'nsuperior', 'osuperior', 'rsuperior', 'ssuperior', + 'tsuperior', 'ff', 'fi', 'fl', 'ffi', 'ffl', 'parenleftinferior', + 'parenrightinferior', 'hyphensuperior', 'colonmonetary', 'onefitted', + 'rupiah', 'centoldstyle', 'figuredash', 'hypheninferior', 'onequarter', + 'onehalf', 'threequarters', 'oneeighth', 'threeeighths', 'fiveeighths', + 'seveneighths', 'onethird', 'twothirds', 'zerosuperior', 'onesuperior', + 'twosuperior', 'threesuperior', 'foursuperior', 'fivesuperior', + 'sixsuperior', 'sevensuperior', 'eightsuperior', 'ninesuperior', + 'zeroinferior', 'oneinferior', 'twoinferior', 'threeinferior', + 'fourinferior', 'fiveinferior', 'sixinferior', 'seveninferior', + 'eightinferior', 'nineinferior', 'centinferior', 'dollarinferior', + 'periodinferior', 'commainferior' ]; diff --git a/fonts.js b/fonts.js index 105df5ec6..7cd27f8b0 100644 --- a/fonts.js +++ b/fonts.js @@ -2586,7 +2586,7 @@ var Type2CFF = (function() { switch (format) { case 0: for (var i = 0; i < length; i++) { - var sid = (bytes[pos++] << 8) | bytes[pos++]; + var sid = (bytes[pos++] << 8) | bytes[pos++]; charset.push(strings[sid]); } break; @@ -2818,7 +2818,7 @@ var Type2CFF = (function() { start: start, end: end, data: bytes.subarray(start, end) - } + }; }, length: count, endPos: end From f08aafa72acf138421a8e5061fd78e240576181b Mon Sep 17 00:00:00 2001 From: Muhammad Fikri