Fix invalid version number in truetype 'head' table

This commit is contained in:
mduan 2013-01-18 15:06:12 -08:00
parent 83dd94257a
commit 0527b8bc8d
3 changed files with 28 additions and 0 deletions

View File

@ -3254,6 +3254,21 @@ var Font = (function FontClosure() {
return glyf.length;
}
function sanitizeHead(head) {
var data = head.data;
// Validate version:
// Should always be 0x00010000
var version = int32([data[0], data[1], data[2], data[3]]);
if (version >> 16 !== 1) {
info('Invalid version in data type: ' + version);
data[0] = 0;
data[1] = 1;
data[2] = 0;
data[3] = 0;
}
}
function sanitizeGlyphLocations(loca, glyf, numGlyphs,
isGlyphLocationsLong) {
var itemSize, itemDecode, itemEncode;
@ -3678,6 +3693,10 @@ var Font = (function FontClosure() {
sanitizeTTPrograms(fpgm, prep);
if (head) {
sanitizeHead(head);
}
var isGlyphLocationsLong = int16([head.data[50], head.data[51]]);
if (head && loca && glyf) {
sanitizeGlyphLocations(loca, glyf, numGlyphs, isGlyphLocationsLong);

View File

@ -0,0 +1 @@
http://www.rcjohnso.com/Looper/Looper.pdf

View File

@ -30,6 +30,14 @@
"rounds": 1,
"type": "eq"
},
{ "id": "issue2531",
"file": "pdfs/issue2531.pdf",
"md5": "c58e6642d8a6e2ddd5e07a543ef8f30d",
"link": true,
"rounds": 1,
"pageLimit": 4,
"type": "eq"
},
{ "id": "html5-canvas-cheat-sheet-load",
"file": "pdfs/canvas.pdf",
"md5": "59510028561daf62e00bf9f6f066b033",