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

XFA - Fix font scale factors (bug 1720888)

- All the scale factors in for the substitution font were wrong because of different glyph positions between Liberation and the other ones:
    - regenerate all the factors
  - Text may have polish chars for example and in this case the glyph widths were wrong:
    - treat substitution font as a composite one
    - add a map glyphIndex to unicode for Liberation in order to generate width array for cid font
This commit is contained in:
Calixte Denizet 2021-07-28 18:30:22 +02:00
parent ac5c4b7fd0
commit 4a4591bd2c
17 changed files with 1614 additions and 1248 deletions

View file

@ -53,12 +53,12 @@ import {
XRefEntryException,
XRefParseException,
} from "./core_utils.js";
import { getXfaFontDict, getXfaFontName } from "./xfa_fonts.js";
import { NullStream, Stream } from "./stream.js";
import { AnnotationFactory } from "./annotation.js";
import { BaseStream } from "./base_stream.js";
import { calculateMD5 } from "./crypto.js";
import { Catalog } from "./catalog.js";
import { getXfaFontWidths } from "./xfa_fonts.js";
import { Linearization } from "./parser.js";
import { ObjectLoader } from "./object_loader.js";
import { OperatorList } from "./operator_list.js";
@ -1019,7 +1019,7 @@ class PDFDocument {
const reallyMissingFonts = new Set();
for (const missing of missingFonts) {
if (!getXfaFontWidths(`${missing}-Regular`)) {
if (!getXfaFontName(`${missing}-Regular`)) {
// No substitution available: we'll fallback on Myriad.
reallyMissingFonts.add(missing);
}
@ -1040,15 +1040,7 @@ class PDFDocument {
{ name: "BoldItalic", fontWeight: 700, italicAngle: 12 },
]) {
const name = `${missing}-${fontInfo.name}`;
const widths = getXfaFontWidths(name);
const dict = new Dict(null);
dict.set("BaseFont", Name.get(name));
dict.set("Type", Name.get("Font"));
dict.set("Subtype", Name.get("TrueType"));
dict.set("Encoding", Name.get("WinAnsiEncoding"));
const descriptor = new Dict(null);
descriptor.set("Widths", widths);
dict.set("FontDescriptor", descriptor);
const dict = getXfaFontDict(name);
promises.push(
partialEvaluator