Fixing TrueType code-glyph assigmnent to pass sanitizer

This commit is contained in:
notmasteryet 2011-12-07 20:59:44 -06:00
parent cb592d6e51
commit 18db087f79
3 changed files with 24 additions and 2 deletions

View File

@ -1765,7 +1765,7 @@ var Font = (function Font() {
var hasShortCmap = !!cmapTable.hasShortCmap;
var toUnicode = this.toUnicode;
if (toUnicode) {
if (toUnicode && toUnicode.length > 0) {
// checking if cmap is just identity map
var isIdentity = true;
for (var i = 0, ii = glyphs.length; i < ii; i++) {
@ -1776,9 +1776,22 @@ var Font = (function Font() {
}
// if it is, replacing with meaningful toUnicode values
if (isIdentity) {
var usedUnicodes = [], unassignedUnicodeItems = [];
for (var i = 0, ii = glyphs.length; i < ii; i++) {
var unicode = toUnicode[i + 1] || i + 1;
var unicode = toUnicode[i + 1];
if (!unicode || usedUnicodes[unicode]) {
unassignedUnicodeItems.push(i);
continue;
}
glyphs[i].unicode = unicode;
usedUnicodes[unicode] = true;
}
var unusedUnicode = kCmapGlyphOffset;
for (var j = 0, jj = unassignedUnicodeItems.length; j < jj; j++) {
var i = unassignedUnicodeItems[j];
while (usedUnicodes[unusedUnicode])
unusedUnicode++;
glyphs[i].unicode = unusedUnicode++;
}
this.useToUnicode = true;
}

View File

@ -0,0 +1 @@
http://www.lfg.com.br/concursodebolsas/lista_preliminar_classificao.pdf

View File

@ -311,5 +311,13 @@
"pageLimit": 5,
"skipPages": [1],
"type": "eq"
},
{ "id": "lista_preliminar",
"file": "pdfs/lista_preliminar.pdf",
"md5": "4eff251319eeb660ba8a7a5cfac7787d",
"rounds": 1,
"link": true,
"pageLimit": 3,
"type": "eq"
}
]