1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 14:48:08 +02:00

Merge pull request #17930 from calixteman/issue17929

Remove the tag for missing font subset when trying to find a substitution
This commit is contained in:
Tim van der Meij 2024-04-12 13:27:32 +02:00 committed by GitHub
commit 2d885e2862
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 71 additions and 15 deletions

View file

@ -4261,7 +4261,8 @@ class PartialEvaluator {
this.idFactory,
this.options.standardFontDataUrl,
baseFontName,
standardFontName
standardFontName,
type
);
}
@ -4381,7 +4382,8 @@ class PartialEvaluator {
this.idFactory,
this.options.standardFontDataUrl,
fontName.name,
standardFontName
standardFontName,
type
);
}
}

View file

@ -456,6 +456,7 @@ function generateFont(
* @param {String} baseFontName The font name to be substituted.
* @param {String|undefined} standardFontName The standard font name to use
* if the base font is not available.
* @param {String} type The font type.
* @returns an Object with the CSS, the loaded name, the src and the style.
*/
function getFontSubstitution(
@ -463,12 +464,21 @@ function getFontSubstitution(
idFactory,
localFontPath,
baseFontName,
standardFontName
standardFontName,
type
) {
if (baseFontName.startsWith("InvalidPDFjsFont_")) {
return null;
}
if (
(type === "TrueType" || type === "Type1") &&
/^[A-Z]{6}\+/.test(baseFontName)
) {
// When the font is a subset, we need to remove the prefix (see 9.6.4).
baseFontName = baseFontName.slice(7);
}
// It's possible to have a font name with spaces, commas or dashes, hence we
// just replace them by a dash.
baseFontName = normalizeFontName(baseFontName);

View file

@ -641,3 +641,4 @@
!issue17871_bottom_right.pdf
!issue17871_top_right.pdf
!bug1889122.pdf
!issue17929.pdf

BIN
test/pdfs/issue17929.pdf Executable file

Binary file not shown.

View file

@ -9833,5 +9833,12 @@
"firstPage": 1,
"lastPage": 1,
"type": "eq"
},
{
"id": "issue17929",
"file": "pdfs/issue17929.pdf",
"md5": "2f5686f77f73fb99037f5c2c7e48ce53",
"rounds": 1,
"type": "eq"
}
]

View file

@ -27,7 +27,32 @@ describe("getFontSubstitution", function () {
idFactory,
localFontPath,
fontName,
undefined
undefined,
"TrueType"
);
expect(fontSubstitution).toEqual(
jasmine.objectContaining({
guessFallback: true,
baseFontName: "Foo",
src: "local(Foo)",
style: {
style: "normal",
weight: "normal",
},
})
);
expect(fontSubstitution.css).toMatch(/^"Foo",g_d(\d+)_sf(\d+)$/);
});
it("should substitute an unknown font subset", () => {
const fontName = "ABCDEF+Foo";
const fontSubstitution = getFontSubstitution(
new Map(),
idFactory,
localFontPath,
fontName,
undefined,
"TrueType"
);
expect(fontSubstitution).toEqual(
jasmine.objectContaining({
@ -50,7 +75,8 @@ describe("getFontSubstitution", function () {
idFactory,
localFontPath,
fontName,
undefined
undefined,
"TrueType"
);
expect(fontSubstitution).toEqual(
jasmine.objectContaining({
@ -73,7 +99,8 @@ describe("getFontSubstitution", function () {
idFactory,
localFontPath,
fontName,
undefined
undefined,
"TrueType"
);
expect(fontSubstitution).toEqual(
jasmine.objectContaining({
@ -96,7 +123,8 @@ describe("getFontSubstitution", function () {
idFactory,
localFontPath,
fontName,
undefined
undefined,
"TrueType"
);
expect(fontSubstitution).toEqual(
jasmine.objectContaining({
@ -119,7 +147,8 @@ describe("getFontSubstitution", function () {
idFactory,
localFontPath,
fontName,
"Helvetica"
"Helvetica",
"TrueType"
);
expect(fontSubstitution).toEqual(
jasmine.objectContaining({
@ -150,7 +179,8 @@ describe("getFontSubstitution", function () {
idFactory,
localFontPath,
fontName,
"Helvetica-Oblique"
"Helvetica-Oblique",
"TrueType"
);
expect(fontSubstitution).toEqual(
jasmine.objectContaining({
@ -183,7 +213,8 @@ describe("getFontSubstitution", function () {
idFactory,
localFontPath,
fontName,
"Helvetica-Bold"
"Helvetica-Bold",
"TrueType"
);
expect(fontSubstitution).toEqual(
jasmine.objectContaining({
@ -215,7 +246,8 @@ describe("getFontSubstitution", function () {
idFactory,
localFontPath,
fontName,
"Helvetica-BoldOblique"
"Helvetica-BoldOblique",
"TrueType"
);
expect(fontSubstitution).toEqual(
jasmine.objectContaining({
@ -250,7 +282,8 @@ describe("getFontSubstitution", function () {
idFactory,
localFontPath,
fontName,
undefined
undefined,
"TrueType"
);
expect(fontSubstitution).toEqual(
jasmine.objectContaining({
@ -283,7 +316,8 @@ describe("getFontSubstitution", function () {
idFactory,
localFontPath,
fontName,
undefined
undefined,
"TrueType"
);
expect(fontSubstitution).toEqual(
jasmine.objectContaining({
@ -318,7 +352,8 @@ describe("getFontSubstitution", function () {
idFactory,
localFontPath,
fontName,
undefined
undefined,
"TrueType"
);
expect(fontSubstitution).toEqual(
jasmine.objectContaining({
@ -353,7 +388,8 @@ describe("getFontSubstitution", function () {
idFactory,
localFontPath,
fontName,
undefined
undefined,
"TrueType"
);
expect(fontSubstitution).toEqual(
jasmine.objectContaining({