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:
parent
83dd94257a
commit
0527b8bc8d
3 changed files with 28 additions and 0 deletions
19
src/fonts.js
19
src/fonts.js
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue