Skip to content

Commit 1694cd8

Browse files
committed
Merge pull request #4995 from Snuffleupagus/issue-4801
Fix another seac regression (issue 4801)
2 parents faa9020 + f13c217 commit 1694cd8

File tree

4 files changed

+42
-21
lines changed

4 files changed

+42
-21
lines changed

src/core/fonts.js

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4110,18 +4110,28 @@ var Font = (function FontClosure() {
41104110
this.toFontChar = newMapping.toFontChar;
41114111
var numGlyphs = font.numGlyphs;
41124112

4113-
function getCharCode(charCodeToGlyphId, glyphId, addMap) {
4113+
function getCharCodes(charCodeToGlyphId, glyphId) {
4114+
var charCodes = null;
41144115
for (var charCode in charCodeToGlyphId) {
41154116
if (glyphId === charCodeToGlyphId[charCode]) {
4116-
return charCode | 0;
4117+
if (!charCodes) {
4118+
charCodes = [];
4119+
}
4120+
charCodes.push(charCode | 0);
41174121
}
41184122
}
4119-
if (addMap) {
4120-
newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] =
4121-
glyphId;
4122-
return newMapping.nextAvailableFontCharCode++;
4123+
return charCodes;
4124+
}
4125+
4126+
function createCharCode(charCodeToGlyphId, glyphId) {
4127+
for (var charCode in charCodeToGlyphId) {
4128+
if (glyphId === charCodeToGlyphId[charCode]) {
4129+
return charCode | 0;
4130+
}
41234131
}
4124-
return null;
4132+
newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] =
4133+
glyphId;
4134+
return newMapping.nextAvailableFontCharCode++;
41254135
}
41264136

41274137
var seacs = font.seacs;
@@ -4144,24 +4154,27 @@ var Font = (function FontClosure() {
41444154
y: seac[0] * matrix[1] + seac[1] * matrix[3] + matrix[5]
41454155
};
41464156

4147-
var charCode = getCharCode(mapping, glyphId);
4148-
if (charCode === null) {
4157+
var charCodes = getCharCodes(mapping, glyphId);
4158+
if (!charCodes) {
41494159
// There's no point in mapping it if the char code was never mapped
41504160
// to begin with.
41514161
continue;
41524162
}
4153-
// Find a fontCharCode that maps to the base and accent glyphs. If one
4154-
// doesn't exists, create it.
4155-
var charCodeToGlyphId = newMapping.charCodeToGlyphId;
4156-
var baseFontCharCode = getCharCode(charCodeToGlyphId, baseGlyphId,
4157-
true);
4158-
var accentFontCharCode = getCharCode(charCodeToGlyphId, accentGlyphId,
4159-
true);
4160-
seacMap[charCode] = {
4161-
baseFontCharCode: baseFontCharCode,
4162-
accentFontCharCode: accentFontCharCode,
4163-
accentOffset: accentOffset
4164-
};
4163+
for (var i = 0, ii = charCodes.length; i < ii; i++) {
4164+
var charCode = charCodes[i];
4165+
// Find a fontCharCode that maps to the base and accent glyphs.
4166+
// If one doesn't exists, create it.
4167+
var charCodeToGlyphId = newMapping.charCodeToGlyphId;
4168+
var baseFontCharCode = createCharCode(charCodeToGlyphId,
4169+
baseGlyphId);
4170+
var accentFontCharCode = createCharCode(charCodeToGlyphId,
4171+
accentGlyphId);
4172+
seacMap[charCode] = {
4173+
baseFontCharCode: baseFontCharCode,
4174+
accentFontCharCode: accentFontCharCode,
4175+
accentOffset: accentOffset
4176+
};
4177+
}
41654178
}
41664179
properties.seacMap = seacMap;
41674180
}

test/pdfs/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,4 @@
8181
!issue4246.pdf
8282
!issue4461.pdf
8383
!issue4573.pdf
84+
!issue4801.pdf

test/pdfs/issue4801.pdf

8.18 KB
Binary file not shown.

test/test_manifest.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,13 @@
547547
"rounds": 1,
548548
"type": "eq"
549549
},
550+
{ "id": "issue4801",
551+
"file": "pdfs/issue4801.pdf",
552+
"md5": "7f32764717447a8b5c8eac08c9ab8380",
553+
"link": false,
554+
"rounds": 1,
555+
"type": "eq"
556+
},
550557
{ "id": "glyph_accent",
551558
"file": "pdfs/glyph_accent.pdf",
552559
"md5": "1526e4edaa3ec439ebf156d0a0b385aa",

0 commit comments

Comments
 (0)