Skip to content

Commit

Permalink
Merge pull request #4995 from Snuffleupagus/issue-4801
Browse files Browse the repository at this point in the history
Fix another seac regression (issue 4801)
  • Loading branch information
yurydelendik committed Jul 22, 2014
2 parents faa9020 + f13c217 commit 1694cd8
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 21 deletions.
55 changes: 34 additions & 21 deletions src/core/fonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -4110,18 +4110,28 @@ var Font = (function FontClosure() {
this.toFontChar = newMapping.toFontChar;
var numGlyphs = font.numGlyphs;

function getCharCode(charCodeToGlyphId, glyphId, addMap) {
function getCharCodes(charCodeToGlyphId, glyphId) {
var charCodes = null;
for (var charCode in charCodeToGlyphId) {
if (glyphId === charCodeToGlyphId[charCode]) {
return charCode | 0;
if (!charCodes) {
charCodes = [];
}
charCodes.push(charCode | 0);
}
}
if (addMap) {
newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] =
glyphId;
return newMapping.nextAvailableFontCharCode++;
return charCodes;
}

function createCharCode(charCodeToGlyphId, glyphId) {
for (var charCode in charCodeToGlyphId) {
if (glyphId === charCodeToGlyphId[charCode]) {
return charCode | 0;
}
}
return null;
newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] =
glyphId;
return newMapping.nextAvailableFontCharCode++;
}

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

var charCode = getCharCode(mapping, glyphId);
if (charCode === null) {
var charCodes = getCharCodes(mapping, glyphId);
if (!charCodes) {
// There's no point in mapping it if the char code was never mapped
// to begin with.
continue;
}
// Find a fontCharCode that maps to the base and accent glyphs. If one
// doesn't exists, create it.
var charCodeToGlyphId = newMapping.charCodeToGlyphId;
var baseFontCharCode = getCharCode(charCodeToGlyphId, baseGlyphId,
true);
var accentFontCharCode = getCharCode(charCodeToGlyphId, accentGlyphId,
true);
seacMap[charCode] = {
baseFontCharCode: baseFontCharCode,
accentFontCharCode: accentFontCharCode,
accentOffset: accentOffset
};
for (var i = 0, ii = charCodes.length; i < ii; i++) {
var charCode = charCodes[i];
// Find a fontCharCode that maps to the base and accent glyphs.
// If one doesn't exists, create it.
var charCodeToGlyphId = newMapping.charCodeToGlyphId;
var baseFontCharCode = createCharCode(charCodeToGlyphId,
baseGlyphId);
var accentFontCharCode = createCharCode(charCodeToGlyphId,
accentGlyphId);
seacMap[charCode] = {
baseFontCharCode: baseFontCharCode,
accentFontCharCode: accentFontCharCode,
accentOffset: accentOffset
};
}
}
properties.seacMap = seacMap;
}
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,4 @@
!issue4246.pdf
!issue4461.pdf
!issue4573.pdf
!issue4801.pdf
Binary file added test/pdfs/issue4801.pdf
Binary file not shown.
7 changes: 7 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,13 @@
"rounds": 1,
"type": "eq"
},
{ "id": "issue4801",
"file": "pdfs/issue4801.pdf",
"md5": "7f32764717447a8b5c8eac08c9ab8380",
"link": false,
"rounds": 1,
"type": "eq"
},
{ "id": "glyph_accent",
"file": "pdfs/glyph_accent.pdf",
"md5": "1526e4edaa3ec439ebf156d0a0b385aa",
Expand Down

0 comments on commit 1694cd8

Please sign in to comment.