File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change
1
+ """Test font-related functionality."""
2
+
3
+
4
+ from pypdf ._font import FontDescriptor
5
+
6
+
7
+ def test_font_descriptor ():
8
+ font_res = {"/BaseFont" : "/Helvetica" }
9
+ my_font = FontDescriptor .from_font_res (font_res )
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_res = {"/BaseFont" : "/Palatino" }
20
+ my_font = FontDescriptor .from_font_res (font_res )
21
+ assert my_font .weight == "Unknown"
22
+
23
+
24
+ font_res = {"/BaseFont" : "/Courier-Bold" }
25
+ my_font = FontDescriptor .from_font_res (font_res )
26
+ assert my_font .italic_angle == 0
27
+ assert my_font .flags == 64
28
+ assert my_font .bbox == (- 113.0 , - 250.0 , 749.0 , 801.0 )
29
+
You can’t perform that action at this time.
0 commit comments