Skip to content

Commit

Permalink
Bug 1530881 - Uplift CFF font fixes for MacOS. r=yury a=lizzard
Browse files Browse the repository at this point in the history
Summary:
Includes pdf.js pull requests:
mozilla/pdf.js#10591
mozilla/pdf.js#10604

Reviewers: yury

Reviewed By: yury

Bug #: 1530881

Differential Revision: https://phabricator.services.mozilla.com/D22131
  • Loading branch information
Brendan Dahl committed Mar 6, 2019
1 parent 162e765 commit a51a6c0
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 22 deletions.
4 changes: 2 additions & 2 deletions browser/extensions/pdfjs/README.mozilla
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
This is the PDF.js project output, https://github.com/mozilla/pdf.js

Current extension version is: 2.1.215
Current extension version is: 2.1.220

Taken from upstream commit: 9128335c
Taken from upstream commit: ca472be4
10 changes: 5 additions & 5 deletions browser/extensions/pdfjs/content/build/pdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ return /******/ (function(modules) { // webpackBootstrap
"use strict";


var pdfjsVersion = '2.1.215';
var pdfjsBuild = '9128335c';
var pdfjsVersion = '2.1.220';
var pdfjsBuild = 'ca472be4';

var pdfjsSharedUtil = __w_pdfjs_require__(1);

Expand Down Expand Up @@ -1397,7 +1397,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {

return worker.messageHandler.sendWithPromise('GetDocRequest', {
docId,
apiVersion: '2.1.215',
apiVersion: '2.1.220',
source: {
data: source.data,
url: source.url,
Expand Down Expand Up @@ -3134,9 +3134,9 @@ const InternalRenderTask = function InternalRenderTaskClosure() {
return InternalRenderTask;
}();

const version = '2.1.215';
const version = '2.1.220';
exports.version = version;
const build = '9128335c';
const build = 'ca472be4';
exports.build = build;

/***/ }),
Expand Down
81 changes: 66 additions & 15 deletions browser/extensions/pdfjs/content/build/pdf.worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ return /******/ (function(modules) { // webpackBootstrap
"use strict";


const pdfjsVersion = '2.1.215';
const pdfjsBuild = '9128335c';
const pdfjsVersion = '2.1.220';
const pdfjsBuild = 'ca472be4';

const pdfjsCoreWorker = __w_pdfjs_require__(1);

Expand Down Expand Up @@ -375,7 +375,7 @@ var WorkerMessageHandler = {
var cancelXHRs = null;
var WorkerTasks = [];
let apiVersion = docParams.apiVersion;
let workerVersion = '2.1.215';
let workerVersion = '2.1.220';

if (apiVersion !== workerVersion) {
throw new Error(`The API version "${apiVersion}" does not match ` + `the Worker version "${workerVersion}".`);
Expand Down Expand Up @@ -26683,20 +26683,22 @@ var Type1Font = function Type1FontClosure() {
cff.strings = strings;
cff.globalSubrIndex = new _cff_parser.CFFIndex();
var count = glyphs.length;
var charsetArray = [0];
var charsetArray = ['.notdef'];
var i, ii;

for (i = 0; i < count; i++) {
var index = _cff_parser.CFFStandardStrings.indexOf(charstrings[i].glyphName);
let glyphName = charstrings[i].glyphName;

let index = _cff_parser.CFFStandardStrings.indexOf(glyphName);

if (index === -1) {
index = 0;
strings.add(glyphName);
}

charsetArray.push(index >> 8 & 0xff, index & 0xff);
charsetArray.push(glyphName);
}

cff.charset = new _cff_parser.CFFCharset(false, 0, [], charsetArray);
cff.charset = new _cff_parser.CFFCharset(false, 0, charsetArray);
var charStringsIndex = new _cff_parser.CFFIndex();
charStringsIndex.add([0x8B, 0x0E]);

Expand Down Expand Up @@ -26824,6 +26826,7 @@ var _encodings = __w_pdfjs_require__(32);
var MAX_SUBR_NESTING = 10;
var CFFStandardStrings = ['.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', 'twodotenleader', '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'];
exports.CFFStandardStrings = CFFStandardStrings;
const NUM_STANDARD_CFF_STRINGS = 391;

var CFFParser = function CFFParserClosure() {
var CharstringValidationData = [null, {
Expand Down Expand Up @@ -27823,16 +27826,31 @@ var CFFStrings = function CFFStringsClosure() {

CFFStrings.prototype = {
get: function CFFStrings_get(index) {
if (index >= 0 && index <= 390) {
if (index >= 0 && index <= NUM_STANDARD_CFF_STRINGS - 1) {
return CFFStandardStrings[index];
}

if (index - 391 <= this.strings.length) {
return this.strings[index - 391];
if (index - NUM_STANDARD_CFF_STRINGS <= this.strings.length) {
return this.strings[index - NUM_STANDARD_CFF_STRINGS];
}

return CFFStandardStrings[0];
},
getSID: function CFFStrings_getSID(str) {
let index = CFFStandardStrings.indexOf(str);

if (index !== -1) {
return index;
}

index = this.strings.indexOf(str);

if (index !== -1) {
return index + NUM_STANDARD_CFF_STRINGS;
}

return -1;
},
add: function CFFStrings_add(value) {
this.strings.push(value);
},
Expand Down Expand Up @@ -28169,7 +28187,7 @@ var CFFCompiler = function CFFCompilerClosure() {
}
}

var charset = this.compileCharset(cff.charset);
var charset = this.compileCharset(cff.charset, cff.charStrings.count, cff.strings, cff.isCIDFont);
topDictTracker.setEntryLocation('charset', [output.length], output);
output.add(charset);
var charStrings = this.compileCharStrings(cff.charStrings);
Expand Down Expand Up @@ -28435,9 +28453,42 @@ var CFFCompiler = function CFFCompilerClosure() {

return this.compileIndex(charStringsIndex);
},
compileCharset: function CFFCompiler_compileCharset(charset) {
let length = 1 + (this.cff.charStrings.count - 1) * 2;
let out = new Uint8Array(length);
compileCharset: function CFFCompiler_compileCharset(charset, numGlyphs, strings, isCIDFont) {
let out;
let numGlyphsLessNotDef = numGlyphs - 1;

if (isCIDFont) {
out = new Uint8Array([2, 0, 0, numGlyphsLessNotDef >> 8 & 0xFF, numGlyphsLessNotDef & 0xFF]);
} else {
let length = 1 + numGlyphsLessNotDef * 2;
out = new Uint8Array(length);
out[0] = 0;
let charsetIndex = 0;
let numCharsets = charset.charset.length;
let warned = false;

for (let i = 1; i < out.length; i += 2) {
let sid = 0;

if (charsetIndex < numCharsets) {
let name = charset.charset[charsetIndex++];
sid = strings.getSID(name);

if (sid === -1) {
sid = 0;

if (!warned) {
warned = true;
(0, _util.warn)(`Couldn't find ${name} in CFF strings`);
}
}
}

out[i] = sid >> 8 & 0xFF;
out[i + 1] = sid & 0xFF;
}
}

return this.compileTypedArray(out);
},
compileEncoding: function CFFCompiler_compileEncoding(encoding) {
Expand Down

0 comments on commit a51a6c0

Please sign in to comment.