Skip to content

Commit f8f9738

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 cc64eca commit f8f9738

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
@@ -4425,3 +4425,17 @@
44254425
),
44264426
}
44274427

4428+
4429+
# Add aliases per table H.3 on pp. 1109-1110 of the PDF 1.7 reference
4430+
FONT_METRICS["Arial"] = FONT_METRICS["Helvetica"]
4431+
FONT_METRICS["Arial,Italic"] = FONT_METRICS["Helvetica-Oblique"]
4432+
FONT_METRICS["Arial,Bold"] = FONT_METRICS["Helvetica-Bold"]
4433+
FONT_METRICS["Arial,BoldItalic"] = FONT_METRICS["Helvetica-BoldOblique"]
4434+
FONT_METRICS["CourierNew"] = FONT_METRICS["Courier"]
4435+
FONT_METRICS["CourierNew,Italic"] = FONT_METRICS["Courier-Oblique"]
4436+
FONT_METRICS["CourierNew,Bold"] = FONT_METRICS["Courier-Bold"]
4437+
FONT_METRICS["CourierNew,BoldItalic"] = FONT_METRICS["Courier-BoldOblique"]
4438+
FONT_METRICS["TimesNewRoman"] = FONT_METRICS["Times-Roman"]
4439+
FONT_METRICS["TimesNewRoman,Italic"] = FONT_METRICS["Times-Italic"]
4440+
FONT_METRICS["TimesNewRoman,Bold"] = FONT_METRICS["Times-Bold"]
4441+
FONT_METRICS["TimesNewRoman,BoldItalic"] = FONT_METRICS["Times-BoldItalic"]

0 commit comments

Comments
 (0)