|
17 | 17 | /* globals assert, bytesToString, CIDToUnicodeMaps, error, ExpertCharset,
|
18 | 18 | ExpertSubsetCharset, FileReaderSync, globalScope, GlyphsUnicode,
|
19 | 19 | info, isArray, isNum, ISOAdobeCharset, isWorker, PDFJS, Stream,
|
20 |
| - stringToBytes, TextDecoder, TODO, warn, Lexer */ |
| 20 | + stringToBytes, TextDecoder, TODO, warn, Lexer, Util */ |
21 | 21 |
|
22 | 22 | 'use strict';
|
23 | 23 |
|
@@ -6696,6 +6696,33 @@ var CFFCompiler = (function CFFCompilerClosure() {
|
6696 | 6696 | var nameIndex = this.compileNameIndex(cff.names);
|
6697 | 6697 | output.add(nameIndex);
|
6698 | 6698 |
|
| 6699 | + if (cff.isCIDFont) { |
| 6700 | + // The spec is unclear on how font matrices should relate to each other |
| 6701 | + // when there is one in the main top dict and the sub top dicts. |
| 6702 | + // Windows handles this differently than linux and osx so we have to |
| 6703 | + // normalize to work on all. |
| 6704 | + // Rules based off of some mailing list discussions: |
| 6705 | + // - If main font has a matrix and subfont doesn't, use the main matrix. |
| 6706 | + // - If no main font matrix and there is a subfont matrix, use the |
| 6707 | + // subfont matrix. |
| 6708 | + // - If both have matrices, concat together. |
| 6709 | + // - If neither have matrices, use default. |
| 6710 | + // To make this work on all platforms we move the top matrix into each |
| 6711 | + // sub top dict and concat if necessary. |
| 6712 | + if (cff.topDict.hasName('FontMatrix')) { |
| 6713 | + var base = cff.topDict.getByName('FontMatrix'); |
| 6714 | + cff.topDict.removeByName('FontMatrix'); |
| 6715 | + for (var i = 0, ii = cff.fdArray.length; i < ii; i++) { |
| 6716 | + var subDict = cff.fdArray[i]; |
| 6717 | + var matrix = base.slice(0); |
| 6718 | + if (subDict.hasName('FontMatrix')) { |
| 6719 | + matrix = Util.transform(matrix, subDict.getByName('FontMatrix')); |
| 6720 | + } |
| 6721 | + subDict.setByName('FontMatrix', matrix); |
| 6722 | + } |
| 6723 | + } |
| 6724 | + } |
| 6725 | + |
6699 | 6726 | var compiled = this.compileTopDicts([cff.topDict],
|
6700 | 6727 | output.length,
|
6701 | 6728 | cff.isCIDFont);
|
|
0 commit comments