Merge pull request #19955 from Snuffleupagus/issue-19954
Support Type3 fonts with an incomplete /FontDescriptor dictionary (issue 19954)
This commit is contained in:
commit
36b40d959b
@ -4313,12 +4313,9 @@ class PartialEvaluator {
|
|||||||
|
|
||||||
if (!descriptor) {
|
if (!descriptor) {
|
||||||
if (isType3Font) {
|
if (isType3Font) {
|
||||||
const bbox = lookupNormalRect(dict.getArray("FontBBox"), [0, 0, 0, 0]);
|
|
||||||
// FontDescriptor is only required for Type3 fonts when the document
|
// FontDescriptor is only required for Type3 fonts when the document
|
||||||
// is a tagged pdf. Create a barbebones one to get by.
|
// is a tagged pdf.
|
||||||
descriptor = new Dict(null);
|
descriptor = Dict.empty;
|
||||||
descriptor.set("FontName", Name.get(type));
|
|
||||||
descriptor.set("FontBBox", bbox);
|
|
||||||
} else {
|
} else {
|
||||||
// Before PDF 1.5 if the font was one of the base 14 fonts, having a
|
// Before PDF 1.5 if the font was one of the base 14 fonts, having a
|
||||||
// FontDescriptor was not required.
|
// FontDescriptor was not required.
|
||||||
@ -4420,7 +4417,13 @@ class PartialEvaluator {
|
|||||||
|
|
||||||
const fontNameStr = fontName?.name;
|
const fontNameStr = fontName?.name;
|
||||||
const baseFontStr = baseFont?.name;
|
const baseFontStr = baseFont?.name;
|
||||||
if (!isType3Font && fontNameStr !== baseFontStr) {
|
if (isType3Font) {
|
||||||
|
if (!fontNameStr) {
|
||||||
|
// Since the /FontDescriptor is optional in Type3 fonts, ensure that we
|
||||||
|
// always have a "valid" /FontName (fixes issue19954.pdf).
|
||||||
|
fontName = Name.get(type);
|
||||||
|
}
|
||||||
|
} else if (fontNameStr !== baseFontStr) {
|
||||||
info(
|
info(
|
||||||
`The FontDescriptor's FontName is "${fontNameStr}" but ` +
|
`The FontDescriptor's FontName is "${fontNameStr}" but ` +
|
||||||
`should be the same as the Font's BaseFont "${baseFontStr}".`
|
`should be the same as the Font's BaseFont "${baseFontStr}".`
|
||||||
@ -4438,8 +4441,8 @@ class PartialEvaluator {
|
|||||||
) {
|
) {
|
||||||
fontName = null;
|
fontName = null;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
fontName ||= baseFont;
|
fontName ||= baseFont;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(fontName instanceof Name)) {
|
if (!(fontName instanceof Name)) {
|
||||||
throw new FormatError("invalid font name");
|
throw new FormatError("invalid font name");
|
||||||
@ -4517,7 +4520,7 @@ class PartialEvaluator {
|
|||||||
);
|
);
|
||||||
const bbox = lookupNormalRect(
|
const bbox = lookupNormalRect(
|
||||||
descriptor.getArray("FontBBox") || dict.getArray("FontBBox"),
|
descriptor.getArray("FontBBox") || dict.getArray("FontBBox"),
|
||||||
undefined
|
isType3Font ? [0, 0, 0, 0] : undefined
|
||||||
);
|
);
|
||||||
let ascent = descriptor.get("Ascent");
|
let ascent = descriptor.get("Ascent");
|
||||||
if (typeof ascent !== "number") {
|
if (typeof ascent !== "number") {
|
||||||
@ -4705,9 +4708,9 @@ class TranslatedFont {
|
|||||||
const fontResources = this.dict.get("Resources") || resources;
|
const fontResources = this.dict.get("Resources") || resources;
|
||||||
const charProcOperatorList = Object.create(null);
|
const charProcOperatorList = Object.create(null);
|
||||||
|
|
||||||
const fontBBox = Util.normalizeRect(font.bbox || [0, 0, 0, 0]),
|
const [x0, y0, x1, y1] = font.bbox,
|
||||||
width = fontBBox[2] - fontBBox[0],
|
width = x1 - x0,
|
||||||
height = fontBBox[3] - fontBBox[1];
|
height = y1 - y0;
|
||||||
const fontBBoxSize = Math.hypot(width, height);
|
const fontBBoxSize = Math.hypot(width, height);
|
||||||
|
|
||||||
for (const key of charProcs.getKeys()) {
|
for (const key of charProcs.getKeys()) {
|
||||||
|
|||||||
1
test/pdfs/issue19954.pdf.link
Normal file
1
test/pdfs/issue19954.pdf.link
Normal file
@ -0,0 +1 @@
|
|||||||
|
https://github.com/user-attachments/files/20281525/Capital.Bancorp.Inc.Corporate.Responsibility.2025509.SD000000003063823863-1-2.pdf
|
||||||
@ -2859,6 +2859,15 @@
|
|||||||
"rounds": 1,
|
"rounds": 1,
|
||||||
"type": "eq"
|
"type": "eq"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "issue19954",
|
||||||
|
"file": "pdfs/issue19954.pdf",
|
||||||
|
"md5": "9742309bb321691b53b96069dfc1099b",
|
||||||
|
"link": true,
|
||||||
|
"rounds": 1,
|
||||||
|
"lastPage": 1,
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "IndexedCS_negative_and_high",
|
"id": "IndexedCS_negative_and_high",
|
||||||
"file": "pdfs/IndexedCS_negative_and_high.pdf",
|
"file": "pdfs/IndexedCS_negative_and_high.pdf",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user