Skip to content

Commit 8f40d8b

Browse files
committed
[fpdf2] Update to 2.8.4
Closes: #14560
1 parent 5e40362 commit 8f40d8b

File tree

9 files changed

+115
-26
lines changed

9 files changed

+115
-26
lines changed

stubs/fpdf2/METADATA.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version = "2.8.3"
1+
version = "2.8.4"
22
upstream_repository = "https://github.com/PyFPDF/fpdf2"
33
requires = ["Pillow>=10.3.0"]
44

stubs/fpdf2/fpdf/enums.pyi

Lines changed: 91 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1+
from abc import ABC, abstractmethod
2+
from collections.abc import Sequence
3+
from dataclasses import dataclass
14
from enum import Enum, Flag, IntEnum, IntFlag
2-
from typing import Literal
5+
from typing import Final, Literal
36
from typing_extensions import Self, TypeAlias
47

8+
from .drawing import DeviceCMYK, DeviceGray, DeviceRGB
59
from .syntax import Name
610

11+
_Color: TypeAlias = str | int | Sequence[int] | DeviceCMYK | DeviceGray | DeviceRGB
12+
713
class SignatureFlag(IntEnum):
814
SIGNATURES_EXIST = 1
915
APPEND_ONLY = 2
@@ -68,15 +74,6 @@ class MethodReturnValue(CoerciveIntFlag):
6874
LINES = 2
6975
HEIGHT = 4
7076

71-
class TableBordersLayout(CoerciveEnum):
72-
ALL = "ALL"
73-
NONE = "NONE"
74-
INTERNAL = "INTERNAL"
75-
MINIMAL = "MINIMAL"
76-
HORIZONTAL_LINES = "HORIZONTAL_LINES"
77-
NO_HORIZONTAL_LINES = "NO_HORIZONTAL_LINES"
78-
SINGLE_TOP_LINE = "SINGLE_TOP_LINE"
79-
8077
class CellBordersLayout(CoerciveIntFlag):
8178
NONE = 0
8279
LEFT = 1
@@ -86,6 +83,90 @@ class CellBordersLayout(CoerciveIntFlag):
8683
ALL = 15
8784
INHERIT = 16
8885

86+
@dataclass
87+
class TableBorderStyle:
88+
thickness: float | None = None
89+
color: int | tuple[int, int, int] | None = None
90+
dash: float | None = None
91+
gap: float = 0.0
92+
phase: float = 0.0
93+
94+
@staticmethod
95+
def from_bool(should_draw: TableBorderStyle | bool | None) -> TableBorderStyle: ...
96+
@property
97+
def dash_dict(self) -> dict[str, float | None]: ...
98+
def changes_stroke(self, pdf) -> bool: ...
99+
def should_render(self) -> bool: ...
100+
def get_change_stroke_commands(self, scale: float) -> list[str]: ...
101+
@staticmethod
102+
def get_line_command(x1: float, y1: float, x2: float, y2: float) -> list[str]: ...
103+
def get_draw_commands(self, pdf, x1: float, y1: float, x2: float, y2: float) -> list[str]: ...
104+
105+
@dataclass
106+
class TableCellStyle:
107+
left: bool | TableBorderStyle = False
108+
bottom: bool | TableBorderStyle = False
109+
right: bool | TableBorderStyle = False
110+
top: bool | TableBorderStyle = False
111+
112+
@staticmethod
113+
def get_change_fill_color_command(color: _Color | None) -> list[str]: ...
114+
def get_draw_commands(
115+
self, pdf, x1: float, y1: float, x2: float, y2: float, fill_color: _Color | None = None
116+
) -> list[str]: ...
117+
def override_cell_border(self, cell_border: CellBordersLayout) -> Self: ...
118+
def draw_cell_border(self, pdf, x1: float, y1: float, x2: float, y2: float, fill_color: _Color | None = None) -> None: ...
119+
120+
class TableBordersLayout(ABC):
121+
ALL: Final[TableBordersLayoutAll]
122+
NONE: Final[TableBordersLayoutNone]
123+
INTERNAL: Final[TableBordersLayoutInternal]
124+
MINIMAL: Final[TableBordersLayoutMinimal]
125+
HORIZONTAL_LINES: Final[TableBordersLayoutHorizontalLines]
126+
NO_HORIZONTAL_LINES: Final[TableBordersLayoutNoHorizontalLines]
127+
SINGLE_TOP_LINE: Final[TableBordersLayoutSingleTopLine]
128+
@abstractmethod
129+
def cell_style_getter(
130+
self, row_idx: int, col_idx: int, col_pos: int, num_heading_rows: int, num_rows: int, num_col_idx: int, num_col_pos: int
131+
) -> TableCellStyle: ...
132+
@classmethod
133+
def coerce(cls, value: Self | str) -> Self: ...
134+
135+
class TableBordersLayoutAll(TableBordersLayout):
136+
def cell_style_getter(
137+
self, row_idx: int, col_idx: int, col_pos: int, num_heading_rows: int, num_rows: int, num_col_idx: int, num_col_pos: int
138+
) -> TableCellStyle: ...
139+
140+
class TableBordersLayoutNone(TableBordersLayout):
141+
def cell_style_getter(
142+
self, row_idx: int, col_idx: int, col_pos: int, num_heading_rows: int, num_rows: int, num_col_idx: int, num_col_pos: int
143+
) -> TableCellStyle: ...
144+
145+
class TableBordersLayoutInternal(TableBordersLayout):
146+
def cell_style_getter(
147+
self, row_idx: int, col_idx: int, col_pos: int, num_heading_rows: int, num_rows: int, num_col_idx: int, num_col_pos: int
148+
) -> TableCellStyle: ...
149+
150+
class TableBordersLayoutMinimal(TableBordersLayout):
151+
def cell_style_getter(
152+
self, row_idx: int, col_idx: int, col_pos: int, num_heading_rows: int, num_rows: int, num_col_idx: int, num_col_pos: int
153+
) -> TableCellStyle: ...
154+
155+
class TableBordersLayoutHorizontalLines(TableBordersLayout):
156+
def cell_style_getter(
157+
self, row_idx: int, col_idx: int, col_pos: int, num_heading_rows: int, num_rows: int, num_col_idx: int, num_col_pos: int
158+
) -> TableCellStyle: ...
159+
160+
class TableBordersLayoutNoHorizontalLines(TableBordersLayout):
161+
def cell_style_getter(
162+
self, row_idx: int, col_idx: int, col_pos: int, num_heading_rows: int, num_rows: int, num_col_idx: int, num_col_pos: int
163+
) -> TableCellStyle: ...
164+
165+
class TableBordersLayoutSingleTopLine(TableBordersLayout):
166+
def cell_style_getter(
167+
self, row_idx: int, col_idx: int, col_pos: int, num_heading_rows: int, num_rows: int, num_col_idx: int, num_col_pos: int
168+
) -> TableCellStyle: ...
169+
89170
class TableCellFillMode(CoerciveEnum):
90171
NONE = "NONE"
91172
ALL = "ALL"

stubs/fpdf2/fpdf/fonts.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ class TTFFont:
114114
subset: SubsetMap
115115
hbfont: HarfBuzzFont | None # Not always defined.
116116
def __init__(self, fpdf, font_file_path, fontkey: str, style: int) -> None: ...
117+
def __deepcopy__(self, memo) -> Self: ...
117118
def close(self) -> None: ...
118119
def get_text_width(self, text: str, font_size_pt: int, text_shaping_params): ...
119120
def shaped_text_width(self, text: str, font_size_pt: int, text_shaping_params): ...

stubs/fpdf2/fpdf/fpdf.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ _FontStyles: TypeAlias = Literal[
109109
]
110110

111111
FPDF_VERSION: Final[str]
112-
PAGE_FORMATS: dict[_Format, tuple[float, float]]
112+
PAGE_FORMATS: Final[dict[_Format, tuple[float, float]]]
113113

114114
class ToCPlaceholder(NamedTuple):
115115
render_function: Callable[[FPDF, list[OutlineSection]], object]

stubs/fpdf2/fpdf/html.pyi

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ from typing_extensions import TypeAlias
77

88
from fpdf import FPDF
99

10-
from .enums import TextEmphasis
10+
from .enums import Align, TextEmphasis
1111
from .fonts import FontFace
1212
from .table import Row, Table
1313

@@ -17,8 +17,10 @@ __copyright__: Final[str]
1717
_OLType: TypeAlias = Literal["1", "a", "A", "I", "i"]
1818

1919
LOGGER: Logger
20-
BULLET_WIN1252: Final[str]
21-
DEGREE_WIN1252: Final[str]
20+
MESSAGE_WAITING_WIN1252: Final = "\x95"
21+
BULLET_UNICODE: Final = "•"
22+
DEGREE_SIGN_WIN1252: Final = "\xb0"
23+
RING_OPERATOR_UNICODE: Final = "∘"
2224
HEADING_TAGS: Final[tuple[str, ...]]
2325
DEFAULT_TAG_STYLES: Final[dict[str, FontFace]]
2426
INLINE_TAGS: Final[tuple[str, ...]]
@@ -49,10 +51,10 @@ class HTML2FPDF(HTMLParser):
4951
follows_trailing_space: bool
5052
follows_heading: bool
5153
href: str
52-
align: str
54+
align: float | Align | None
5355
indent: int
5456
line_height_stack: list[Incomplete]
55-
ol_type: list[_OLType]
57+
ol_type: dict[int, _OLType]
5658
bullet: list[Incomplete]
5759
heading_level: Incomplete | None
5860
render_title_tag: bool
@@ -71,7 +73,7 @@ class HTML2FPDF(HTMLParser):
7173
li_tag_indent: int | None = None,
7274
dd_tag_indent: int | None = None,
7375
table_line_separators: bool = False,
74-
ul_bullet_char: str = "\x95",
76+
ul_bullet_char: str = "disc",
7577
li_prefix_color: tuple[int, int, int] = (190, 0, 0),
7678
heading_sizes: SupportsKeysAndGetItem[str, int] | Iterable[tuple[str, int]] | None = None,
7779
pre_code_font: str | None = None,
@@ -88,7 +90,7 @@ class HTML2FPDF(HTMLParser):
8890
def render_toc(self, pdf, outline) -> None: ...
8991
def error(self, message: str) -> None: ...
9092

91-
def ul_prefix(ul_type: str) -> str: ...
93+
def ul_prefix(ul_type: str, is_ttf_font: bool | None) -> str: ...
9294
def ol_prefix(ol_type: _OLType, index: int) -> str: ...
9395

9496
class HTMLMixin:

stubs/fpdf2/fpdf/svg.pyi

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,26 @@ from _typeshed import Incomplete, Unused
22
from collections.abc import Callable
33
from logging import Logger
44
from re import Pattern
5-
from typing import Literal, NamedTuple, overload
5+
from typing import Final, Literal, NamedTuple, Protocol, TypeVar, overload, type_check_only
66

77
from ._fonttools_shims import BasePen, _TTGlyphSet
88
from .drawing import ClippingPath, PaintedPath
99
from .fpdf import FPDF
1010
from .image_datastructures import ImageCache
1111

1212
LOGGER: Logger
13-
1413
__pdoc__: dict[str, bool]
1514

16-
def force_nodocument(item): ...
15+
@type_check_only
16+
class _HasQualname(Protocol):
17+
__qualname__: str
18+
19+
_T = TypeVar("_T", bound=_HasQualname)
20+
21+
def force_nodocument(item: _T) -> _T: ...
1722

18-
NUMBER_SPLIT: Pattern[str]
19-
TRANSFORM_GETTER: Pattern[str]
23+
NUMBER_SPLIT: Final[Pattern[str]]
24+
TRANSFORM_GETTER: Final[Pattern[str]]
2025

2126
class Percent(float): ...
2227

stubs/fpdf2/fpdf/syntax.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def create_dictionary_string(
2121
def create_list_string(list_): ...
2222
def iobj_ref(n): ...
2323
def create_stream(stream: str | bytes | bytearray, encryption_handler: StandardSecurityHandler | None = None, obj_id=None): ...
24+
def wrap_in_local_context(draw_commands: list[str]) -> list[str]: ...
2425

2526
class Raw(str): ...
2627

stubs/fpdf2/fpdf/table.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ class Table:
5858
self, cells: Iterable[str] = (), style: FontFace | None = None, v_align: VAlign | str | None = None, min_height=None
5959
) -> Row: ...
6060
def render(self) -> None: ...
61-
def get_cell_border(self, i: int, j: int, cell: Cell) -> str | Literal[0, 1]: ...
6261

6362
class Row:
6463
cells: list[Cell]

stubs/fpdf2/fpdf/template.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class FlexTemplate:
2222
set: Any
2323
def __contains__(self, name): ...
2424
def __getitem__(self, name): ...
25-
def split_multicell(self, text, element_name): ...
25+
def split_multicell(self, text: str, element_name: str) -> list[str]: ...
2626
def render(self, offsetx: float = 0.0, offsety: float = 0.0, rotate: float = 0.0, scale: float = 1.0): ...
2727

2828
class Template(FlexTemplate):

0 commit comments

Comments
 (0)