Skip to content

Commit e931405

Browse files
committed
ROB: font_metrics: Add font aliases
Version 1.7 of the PDF reference lists various alternatives names as accepted for the 14 core fonts, such as Arial for Helvetica and CourierNew for Courier. Add these alternative names to the font metrics.
1 parent dc91af8 commit e931405

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pypdf/_codecs/core_fontmetrics.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4456,3 +4456,17 @@
44564456
},
44574457
),
44584458
}
4459+
4460+
# Add aliases per table H.3 on pp. 1109-1110 of the PDF 1.7 reference
4461+
FONT_METRICS["Arial"] = FONT_METRICS["Helvetica"]
4462+
FONT_METRICS["Arial,Italic"] = FONT_METRICS["Helvetica-Oblique"]
4463+
FONT_METRICS["Arial,Bold"] = FONT_METRICS["Helvetica-Bold"]
4464+
FONT_METRICS["Arial,BoldItalic"] = FONT_METRICS["Helvetica-BoldOblique"]
4465+
FONT_METRICS["CourierNew"] = FONT_METRICS["Courier"]
4466+
FONT_METRICS["CourierNew,Italic"] = FONT_METRICS["Courier-Oblique"]
4467+
FONT_METRICS["CourierNew,Bold"] = FONT_METRICS["Courier-Bold"]
4468+
FONT_METRICS["CourierNew,BoldItalic"] = FONT_METRICS["Courier-BoldOblique"]
4469+
FONT_METRICS["TimesNewRoman"] = FONT_METRICS["Times-Roman"]
4470+
FONT_METRICS["TimesNewRoman,Italic"] = FONT_METRICS["Times-Italic"]
4471+
FONT_METRICS["TimesNewRoman,Bold"] = FONT_METRICS["Times-Bold"]
4472+
FONT_METRICS["TimesNewRoman,BoldItalic"] = FONT_METRICS["Times-BoldItalic"]

0 commit comments

Comments
 (0)