1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 10:08:06 +02:00

Fix glyph 0 in CIDFontType2 that has a CIDToGIDMap stream

This commit is contained in:
Jani Pehkonen 2019-05-07 18:44:37 +03:00
parent 83f6de3cf8
commit 05c527f035
5 changed files with 26 additions and 9 deletions

View file

@ -1606,7 +1606,8 @@ var Font = (function FontClosure() {
};
}
function sanitizeMetrics(font, header, metrics, numGlyphs) {
function sanitizeMetrics(font, header, metrics, numGlyphs,
dupFirstEntry) {
if (!header) {
if (metrics) {
metrics.data = null;
@ -1649,6 +1650,11 @@ var Font = (function FontClosure() {
// the use of |numMissing * 2| when initializing the typed array.
var entries = new Uint8Array(metrics.length + numMissing * 2);
entries.set(metrics.data);
if (dupFirstEntry) {
// Set the sidebearing value of the duplicated glyph.
entries[metrics.length] = metrics.data[2];
entries[metrics.length + 1] = metrics.data[3];
}
metrics.data = entries;
}
}
@ -2366,7 +2372,8 @@ var Font = (function FontClosure() {
// Ensure the hmtx table contains the advance width and
// sidebearings information for numGlyphs in the maxp table
sanitizeMetrics(font, tables['hhea'], tables['hmtx'], numGlyphsOut);
sanitizeMetrics(font, tables['hhea'], tables['hmtx'], numGlyphsOut,
dupFirstEntry);
if (!tables['head']) {
throw new FormatError('Required "head" table is not found');