Sets proper unicode range for symbols; sanitize no-glyphs fonts

This commit is contained in:
notmasteryet 2012-02-18 15:01:53 -06:00
parent fe6ded204d
commit 321750bba6
3 changed files with 28 additions and 1 deletions

View File

@ -1648,6 +1648,18 @@ var Font = (function FontClosure() {
itemEncode(locaData, j, writeOffset);
startOffset = endOffset;
}
if (writeOffset == 0) {
// glyf table cannot be empty -- redoing the glyf and loca tables
// to have single glyph with one point
var simpleGlyph = new Uint8Array(
[0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 0]);
for (var i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize)
itemEncode(locaData, j, simpleGlyph.length);
glyf.data = simpleGlyph;
return;
}
glyf.data = newGlyfData.subarray(0, writeOffset);
}
@ -1928,6 +1940,11 @@ var Font = (function FontClosure() {
}
}
// If font is symbolic and cmap (3,0) present, the characters are
// located in 0xF000 - 0xF0FF range
this.symbolicGlyphsOffset =
this.isSymbolicFont && !hasShortCmap ? 0xF000 : 0;
// remove glyph references outside range of avaialable glyphs
for (var i = 0, ii = ids.length; i < ii; i++) {
if (ids[i] >= numGlyphs)
@ -2315,7 +2332,8 @@ var Font = (function FontClosure() {
break;
}
if (!this.hasEncoding || this.isSymbolicFont) {
unicode = this.useToUnicode ? this.toUnicode[charcode] : charcode;
unicode = this.useToUnicode ? this.toUnicode[charcode] :
(this.symbolicGlyphsOffset + charcode);
break;
}

View File

@ -0,0 +1 @@
http://www.nsa.gov/public_info/_files/nash_letters/nash_letters1.pdf

View File

@ -480,5 +480,13 @@
"rounds": 1,
"link": true,
"type": "eq"
},
{ "id": "issue1243",
"file": "pdfs/issue1243.pdf",
"md5": "130c849b83513d5ac5e03c6421fc7489",
"rounds": 1,
"pageLimit": 2,
"link": true,
"type": "eq"
}
]