Skip to content

Commit 331e32e

Browse files
committed
Simplify how we handle Type3 fonts without a /FontDescriptor dictionary
Part of this is very old code, which we can now simplify a little bit.
1 parent 5f5d9df commit 331e32e

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/core/evaluator.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4313,12 +4313,9 @@ class PartialEvaluator {
43134313

43144314
if (!descriptor) {
43154315
if (isType3Font) {
4316-
const bbox = lookupNormalRect(dict.getArray("FontBBox"), [0, 0, 0, 0]);
43174316
// FontDescriptor is only required for Type3 fonts when the document
4318-
// is a tagged pdf. Create a barbebones one to get by.
4319-
descriptor = new Dict(null);
4320-
descriptor.set("FontName", Name.get(type));
4321-
descriptor.set("FontBBox", bbox);
4317+
// is a tagged pdf.
4318+
descriptor = Dict.empty;
43224319
} else {
43234320
// Before PDF 1.5 if the font was one of the base 14 fonts, having a
43244321
// FontDescriptor was not required.
@@ -4422,8 +4419,8 @@ class PartialEvaluator {
44224419
const baseFontStr = baseFont?.name;
44234420
if (isType3Font) {
44244421
if (!fontNameStr) {
4425-
// The Type3 font has a /FontDescriptor, however it's incomplete, hence
4426-
// why we didn't create a barbebones one above (fixes issue19954.pdf).
4422+
// Since the /FontDescriptor is optional in Type3 fonts, ensure that we
4423+
// always have a "valid" /FontName (fixes issue19954.pdf).
44274424
fontName = Name.get(type);
44284425
}
44294426
} else if (fontNameStr !== baseFontStr) {
@@ -4523,7 +4520,7 @@ class PartialEvaluator {
45234520
);
45244521
const bbox = lookupNormalRect(
45254522
descriptor.getArray("FontBBox") || dict.getArray("FontBBox"),
4526-
undefined
4523+
isType3Font ? [0, 0, 0, 0] : undefined
45274524
);
45284525
let ascent = descriptor.get("Ascent");
45294526
if (typeof ascent !== "number") {
@@ -4711,7 +4708,7 @@ class TranslatedFont {
47114708
const fontResources = this.dict.get("Resources") || resources;
47124709
const charProcOperatorList = Object.create(null);
47134710

4714-
const fontBBox = Util.normalizeRect(font.bbox || [0, 0, 0, 0]),
4711+
const fontBBox = font.bbox,
47154712
width = fontBBox[2] - fontBBox[0],
47164713
height = fontBBox[3] - fontBBox[1];
47174714
const fontBBoxSize = Math.hypot(width, height);

0 commit comments

Comments
 (0)