Skip to content

[fpdf2] Make fpdf.fonts.Glyph a dataclass #13645

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions stubs/fpdf2/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ fpdf.fonts.HarfBuzzFont

# Stubtest wants us to use Literals, but that is unreasonable.
fpdf.unicode_script.UNICODE_RANGE_TO_SCRIPT

# Ignore stubtest weirdness "fpdf.fonts.Glyph._DT is not present at runtime"
# https://github.com/python/mypy/issues/18811
fpdf.fonts.Glyph._DT
10 changes: 2 additions & 8 deletions stubs/fpdf2/fpdf/fonts.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,13 @@ class PDFFontDescriptor(PDFObject):
font_name: Incomplete
def __init__(self, ascent, descent, cap_height, flags, font_b_box, italic_angle, stem_v, missing_width) -> None: ...

@dataclass(order=True)
class Glyph:
glyph_id: int
unicode: tuple[Incomplete, ...]
glyph_name: str
glyph_width: int
def __hash__(self): ...
def __init__(self, glyph_id, unicode, glyph_name, glyph_width) -> None: ...
def __lt__(self, other): ...
def __gt__(self, other): ...
def __le__(self, other): ...
def __ge__(self, other): ...

__match_args__ = ("glyph_id", "unicode", "glyph_name", "glyph_width")
def __hash__(self) -> int: ...

class SubsetMap:
font: TTFFont
Expand Down