1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-29 07:37:57 +02:00

Merge pull request #13517 from calixteman/liberation

XFA - Add Liberation-Sans font as a substitution for some missing fonts
This commit is contained in:
calixteman 2021-06-09 18:19:07 +02:00 committed by GitHub
commit 6d88d8cdaa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
34 changed files with 2453 additions and 54 deletions

View file

@ -506,31 +506,11 @@ function fixTextIndent(styles) {
}
function getFonts(family) {
if (family.startsWith("'")) {
family = `"${family.slice(1, family.length - 1)}"`;
} else if (family.includes(" ") && !family.startsWith('"')) {
family = `"${family}"`;
if (family.startsWith("'") || family.startsWith('"')) {
family = family.slice(1, family.length - 1);
}
// TODO in case Myriad is not available we should generate a new
// font based on helvetica but where glyphs have been rescaled in order
// to have the exact same metrics.
const fonts = [family];
switch (family) {
case `"Myriad Pro"`:
fonts.push(
`"Roboto Condensed"`,
`"Ubuntu Condensed"`,
`"Microsoft Sans Serif"`,
`"Apple Symbols"`,
"Helvetica",
`"sans serif"`
);
break;
case "Arial":
fonts.push("Helvetica", `"Liberation Sans"`, "Arimo", `"sans serif"`);
break;
}
const fonts = [`"${family}"`, `"${family}-PdfJS-XFA"`];
return fonts.join(",");
}