Skip to content

Commit c477929

Browse files
committed
ENH: FontDescriptor dataclass
This patch adds a new FontDescriptor dataclass. Its initial use, for now, is to act as a dataclass for the font metrics of the 14 Adobe core fonts. These fonts are usually not embedded in PDF documents, while PDF readers are expected to carry that information themselves.
1 parent c8d9ff5 commit c477929

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

pypdf/_font.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from dataclasses import dataclass
2+
3+
4+
@dataclass(frozen=True)
5+
class FontDescriptor:
6+
"""
7+
Represents the FontDescriptor dictionary as defined in the PDF specification.
8+
This contains both descriptive and metric information.
9+
"""
10+
11+
name: str
12+
family: str
13+
weight: str
14+
15+
ascent: float
16+
descent: float
17+
cap_height: float
18+
x_height: float
19+
italic_angle: float
20+
flags: int
21+
bbox: tuple[float, float, float, float]
22+
23+
character_widths: dict[str, int]

0 commit comments

Comments
 (0)