1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

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);