Skip to content

Commit

Permalink
Merge pull request #10604 from brendandahl/fix-type1-charset
Browse files Browse the repository at this point in the history
Put the string name of the glyph in the charset array.
  • Loading branch information
timvandermeij authored Mar 2, 2019
2 parents 7208f0f + 7d6ab08 commit 4f13eb0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
8 changes: 6 additions & 2 deletions src/core/cff_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ var CFFStrings = (function CFFStringsClosure() {
return -1;
},
add: function CFFStrings_add(value) {
return this.strings.push(value) + NUM_STANDARD_CFF_STRINGS - 1;
this.strings.push(value);
},
get count() {
return this.strings.length;
Expand Down Expand Up @@ -1616,14 +1616,18 @@ var CFFCompiler = (function CFFCompilerClosure() {
out[0] = 0; // format 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;
warn(`Couldn't find ${name} in CFF strings`);
if (!warned) {
warned = true;
warn(`Couldn't find ${name} in CFF strings`);
}
}
}
out[i] = (sid >> 8) & 0xFF;
Expand Down
9 changes: 5 additions & 4 deletions src/core/fonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -3335,14 +3335,15 @@ var Type1Font = (function Type1FontClosure() {
cff.globalSubrIndex = new CFFIndex();

var count = glyphs.length;
var charsetArray = [0];
var charsetArray = ['.notdef'];
var i, ii;
for (i = 0; i < count; i++) {
var index = CFFStandardStrings.indexOf(charstrings[i].glyphName);
let glyphName = charstrings[i].glyphName;
let index = CFFStandardStrings.indexOf(glyphName);
if (index === -1) {
index = strings.add(charstrings[i].glyphName);
strings.add(glyphName);
}
charsetArray.push(index);
charsetArray.push(glyphName);
}
cff.charset = new CFFCharset(false, 0, charsetArray);

Expand Down

0 comments on commit 4f13eb0

Please sign in to comment.