We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cd15afc commit 8a89528Copy full SHA for 8a89528
tests/test_font.py
@@ -0,0 +1,23 @@
1
+"""Test font-related functionality."""
2
+
3
4
+from pypdf._codecs.core_fontmetrics import FONT_METRICS
5
6
7
+def test_font_metrics():
8
+ font_name = "Helvetica"
9
+ my_font = FONT_METRICS[font_name]
10
+ assert my_font.family == "Helvetica"
11
+ assert my_font.weight == "Medium"
12
+ assert my_font.ascent == 718
13
+ assert my_font.descent == -207
14
15
+ test_string = "This is a long sentence. !@%%^€€€. çûįö¶´"
16
+ charwidth = sum(my_font.character_widths[char] for char in test_string)
17
+ assert charwidth == 19251
18
19
+ font_name = "Courier-Bold"
20
21
+ assert my_font.italic_angle == 0
22
+ assert my_font.flags == 64
23
+ assert my_font.bbox == (-113.0, -250.0, 749.0, 801.0)
0 commit comments