Skip to content

Commit 8bd6ceb

Browse files
authored
[fpdf2] Update to 2.7.9 (#11953)
1 parent 9a7ff27 commit 8bd6ceb

File tree

11 files changed

+82
-45
lines changed

11 files changed

+82
-45
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.7.8"
1+
version = "2.7.9"
22
upstream_repository = "https://github.com/PyFPDF/fpdf2"
33
requires = ["Pillow>=10.3.0"]
44

stubs/fpdf2/fpdf/bidi.pyi

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ from collections.abc import Sequence
33
from dataclasses import dataclass
44
from typing import Final, Literal, TypedDict, type_check_only
55

6+
from .enums import TextDirection
7+
68
MAX_DEPTH: Final = 125
79

810
@type_check_only
@@ -40,17 +42,17 @@ class IsolatingRun:
4042
def resolve_neutral_types(self) -> None: ...
4143
def resolve_implicit_levels(self) -> None: ...
4244

43-
def auto_detect_base_direction(string: str, stop_at_pdi: bool = False, debug: bool = False) -> Literal["L", "R"]: ...
45+
def auto_detect_base_direction(string: str, stop_at_pdi: bool = False, debug: bool = False) -> TextDirection: ...
4446
def calculate_isolate_runs(paragraph: Sequence[BidiCharacter]) -> list[IsolatingRun]: ...
4547

4648
class BidiParagraph:
4749
text: str
48-
base_direction: Literal["L", "R"]
50+
base_direction: TextDirection
4951
debug: bool
5052
base_embedding_level: int
5153
characters: list[BidiCharacter]
5254

53-
def __init__(self, text: str, base_direction: Literal["L", "R"] | None = None, debug: bool = False) -> None: ...
55+
def __init__(self, text: str, base_direction: TextDirection | None = None, debug: bool = False) -> None: ...
5456
def get_characters(self) -> list[BidiCharacter]: ...
5557
def get_characters_with_embedding_level(self) -> list[BidiCharacter]: ...
5658
def get_reordered_characters(self) -> list[BidiCharacter]: ...

stubs/fpdf2/fpdf/drawing.pyi

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ class DeviceRGB(_DeviceRGBBase):
4141
def __new__(cls, r: Number, g: Number, b: Number, a: Number | None = None) -> Self: ...
4242
@property
4343
def colors(self) -> tuple[Number, Number, Number]: ...
44+
@property
45+
def colors255(self) -> tuple[Number, Number, Number]: ...
4446
def serialize(self) -> str: ...
4547

4648
class _DeviceGrayBase(NamedTuple):
@@ -51,7 +53,9 @@ class DeviceGray(_DeviceGrayBase):
5153
OPERATOR: ClassVar[str]
5254
def __new__(cls, g: Number, a: Number | None = None) -> Self: ...
5355
@property
54-
def colors(self) -> tuple[Number]: ...
56+
def colors(self) -> tuple[Number, Number, Number]: ...
57+
@property
58+
def colors255(self) -> tuple[Number, Number, Number]: ...
5559
def serialize(self) -> str: ...
5660

5761
class _DeviceCMYKBase(NamedTuple):

stubs/fpdf2/fpdf/enums.pyi

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class VAlign(CoerciveEnum):
4444
B = "BOTTOM"
4545

4646
class TextEmphasis(CoerciveIntFlag):
47+
NONE = 0
4748
B = 1
4849
I = 2
4950
U = 4
@@ -70,13 +71,19 @@ class TableCellFillMode(CoerciveEnum):
7071
ALL = "ALL"
7172
ROWS = "ROWS"
7273
COLUMNS = "COLUMNS"
74+
EVEN_ROWS = "EVEN_ROWS"
75+
EVEN_COLUMNS = "EVEN_COLUMNS"
7376

7477
def should_fill_cell(self, i: int, j: int) -> bool: ...
7578

7679
class TableSpan(CoerciveEnum):
7780
ROW: Literal["ROW"]
7881
COL: Literal["COL"]
7982

83+
class TableHeadingsDisplay(CoerciveIntEnum):
84+
NONE = 0
85+
ON_TOP_OF_EVERY_PAGE = 1
86+
8087
class RenderStyle(CoerciveEnum):
8188
D = "DRAW"
8289
F = "FILL"
@@ -259,3 +266,9 @@ class EncryptionMethod(Enum):
259266
RC4 = 1
260267
AES_128 = 2
261268
AES_256 = 3
269+
270+
class TextDirection(CoerciveEnum):
271+
LTR = "LTR"
272+
RTL = "RTL"
273+
TTB = "TTB"
274+
BTT = "BTT"

stubs/fpdf2/fpdf/fpdf.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ from .enums import (
2525
RenderStyle,
2626
TableBordersLayout,
2727
TableCellFillMode,
28+
TextDirection,
2829
TextMarkupType,
2930
TextMode as TextMode,
3031
WrapMode as WrapMode,
@@ -207,7 +208,7 @@ class FPDF(GraphicsStateMixin):
207208
self,
208209
use_shaping_engine: bool = True,
209210
features: dict[str, bool] | None = None,
210-
direction: Literal["ltr", "rtl"] | None = None,
211+
direction: Literal["ltr", "rtl"] | TextDirection | None = None,
211212
script: str | None = None,
212213
language: str | None = None,
213214
) -> None: ...

stubs/fpdf2/fpdf/html.pyi

Lines changed: 45 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,70 @@
1-
from _typeshed import Incomplete, SupportsKeysAndGetItem, Unused
2-
from collections.abc import Callable, Iterable
1+
from _typeshed import Incomplete, SupportsItemAccess, SupportsKeysAndGetItem, Unused
2+
from collections.abc import Callable, Iterable, Mapping
33
from html.parser import HTMLParser
44
from logging import Logger
5-
from typing import ClassVar, Final
5+
from typing import ClassVar, Final, Literal, TypedDict, type_check_only
6+
from typing_extensions import TypeAlias
67

78
from fpdf import FPDF
89

10+
from .fonts import FontFace
11+
from .table import Row, Table
12+
913
__author__: Final[str]
1014
__copyright__: Final[str]
1115

16+
_OLType: TypeAlias = Literal["1", "a", "A", "I", "i"]
17+
1218
LOGGER: Logger
1319
BULLET_WIN1252: Final[str]
14-
DEFAULT_HEADING_SIZES: dict[str, int]
20+
DEGREE_WIN1252: Final[str]
21+
HEADING_TAGS: Final[tuple[str, ...]]
22+
DEFAULT_TAG_STYLES: Final[dict[str, FontFace]]
23+
DEFAULT_TAG_INDENTS: Final[dict[str, int]]
1524

1625
COLOR_DICT: Final[dict[str, str]]
1726

1827
def color_as_decimal(color: str | None = "#000000") -> tuple[int, int, int] | None: ...
28+
def parse_style(elem_attrs: SupportsItemAccess[str, str]) -> None: ...
29+
@type_check_only
30+
class _Emphasis(TypedDict):
31+
b: bool
32+
i: bool
33+
u: bool
1934

2035
class HTML2FPDF(HTMLParser):
2136
HTML_UNCLOSED_TAGS: ClassVar[tuple[str, ...]]
37+
TABLE_LINE_HEIGHT: ClassVar[float]
2238

2339
pdf: FPDF
24-
image_map: Incomplete
25-
li_tag_indent: int
26-
dd_tag_indent: int
40+
image_map: Callable[[str], str]
2741
ul_bullet_char: str
28-
heading_sizes: dict[str, int]
29-
pre_code_font: str
42+
li_prefix_color: tuple[int, int, int]
3043
warn_on_tags_not_matching: bool
31-
style: Incomplete
32-
font_size: Incomplete
44+
emphasis: _Emphasis
45+
font_size: float
3346
follows_trailing_space: bool
3447
follows_heading: bool
3548
href: str
3649
align: str
37-
page_links: Incomplete
38-
font_stack: Incomplete
50+
style_stack: list[FontFace]
3951
indent: int
40-
bullet: Incomplete
41-
font_color: Incomplete
42-
table: Incomplete
43-
table_col_width: Incomplete
44-
table_col_index: Incomplete
45-
td: Incomplete
46-
th: Incomplete
47-
tr: Incomplete
48-
thead: Incomplete
49-
tfoot: Incomplete
50-
tr_index: Incomplete
51-
theader: Incomplete
52-
tfooter: Incomplete
53-
theader_out: bool
54-
table_row_height: int
55-
heading_level: Incomplete
52+
ol_type: list[_OLType]
53+
bullet: list[Incomplete]
54+
font_color: tuple[int, int, int]
55+
heading_level: Incomplete | None
5656
heading_above: float
5757
heading_below: float
58+
table_line_separators: bool
59+
table: Table | None
60+
table_row: Row | None
61+
tr: dict[str, str] | None
62+
td_th: dict[str, str] | None
63+
tag_indents: dict[str, int]
64+
tag_styles: dict[str, FontFace]
5865

5966
# Not initialized in __init__:
60-
font_face: Incomplete
67+
font_family: str
6168
h: float
6269

6370
def __init__(
@@ -68,20 +75,26 @@ class HTML2FPDF(HTMLParser):
6875
dd_tag_indent: int = 10,
6976
table_line_separators: bool = False,
7077
ul_bullet_char: str = "\x95",
78+
li_prefix_color: tuple[int, int, int] = (190, 0, 0),
7179
heading_sizes: SupportsKeysAndGetItem[str, int] | Iterable[tuple[str, int]] | None = None,
72-
pre_code_font: str = "courier",
80+
pre_code_font: str = ...,
7381
warn_on_tags_not_matching: bool = True,
82+
tag_indents: dict[str, int] | None = None,
83+
tag_styles: Mapping[str, FontFace] | None = None,
7484
**_: Unused,
7585
): ...
7686
def handle_data(self, data) -> None: ...
7787
def handle_starttag(self, tag, attrs) -> None: ...
7888
def handle_endtag(self, tag) -> None: ...
79-
def set_font(self, face: Incomplete | None = None, size: Incomplete | None = None, set_default: bool = False) -> None: ...
89+
def set_font(self, family: str | None = None, size: float | None = None, set_default: bool = False) -> None: ...
8090
def set_style(self, tag: Incomplete | None = None, enable: bool = False) -> None: ...
8191
def set_text_color(self, r: Incomplete | None = None, g: int = 0, b: int = 0) -> None: ...
8292
def put_link(self, text) -> None: ...
8393
def render_toc(self, pdf, outline) -> None: ...
8494
def error(self, message: str) -> None: ...
8595

96+
def ul_prefix(ul_type: str) -> str: ...
97+
def ol_prefix(ol_type: _OLType, index: int) -> str: ...
98+
8699
class HTMLMixin:
87100
def __init__(self, *args, **kwargs) -> None: ...

stubs/fpdf2/fpdf/line_break.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from _typeshed import Incomplete
22
from collections.abc import Callable, Sequence
3-
from typing import Final, Literal, NamedTuple
3+
from typing import Final, NamedTuple
44

5-
from .enums import Align, WrapMode
5+
from .enums import Align, TextDirection, WrapMode
66

77
SOFT_HYPHEN: Final[str]
88
HYPHEN: Final[str]
@@ -60,9 +60,9 @@ class Fragment:
6060
@property
6161
def text_shaping_parameters(self): ...
6262
@property
63-
def paragraph_direction(self) -> Literal["L", "R"]: ...
63+
def paragraph_direction(self) -> TextDirection: ...
6464
@property
65-
def fragment_direction(self) -> Literal["L", "R"]: ...
65+
def fragment_direction(self) -> TextDirection: ...
6666
def trim(self, index: int) -> None: ...
6767
def __eq__(self, other: Fragment) -> bool: ... # type: ignore[override]
6868
def get_width(self, start: int = 0, end: int | None = None, chars: str | None = None, initial_cs: bool = True) -> float: ...

stubs/fpdf2/fpdf/outline.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ from .syntax import Destination, PDFObject, PDFString
77

88
class OutlineSection(NamedTuple):
99
name: str
10-
level: str
10+
level: int
1111
page_number: int
1212
dest: Destination
1313
struct_elem: StructElem | None = ...

stubs/fpdf2/fpdf/svg.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ def optional(value, converter=...): ...
4242

4343
svg_attr_map: dict[str, Callable[[Incomplete], tuple[str, Incomplete]]]
4444

45-
def parse_style(svg_element) -> None: ...
4645
def apply_styles(stylable, svg_element) -> None: ...
4746

4847
class ShapeBuilder:

stubs/fpdf2/fpdf/table.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ from typing import Literal, overload
77
from PIL import Image
88

99
from .drawing import DeviceGray, DeviceRGB
10-
from .enums import Align, TableBordersLayout, TableCellFillMode, TableSpan, VAlign, WrapMode
10+
from .enums import Align, TableBordersLayout, TableCellFillMode, TableHeadingsDisplay, TableSpan, VAlign, WrapMode
1111
from .fonts import FontFace
1212
from .fpdf import FPDF
1313
from .util import Padding
@@ -40,6 +40,7 @@ class Table:
4040
padding: float | Padding | None = None,
4141
outer_border_width: float | None = None,
4242
num_heading_rows: int = 1,
43+
repeat_headings: TableHeadingsDisplay | int = 1,
4344
) -> None: ...
4445
def row(self, cells: Iterable[str] = (), style: FontFace | None = None) -> Row: ...
4546
def render(self) -> None: ...

0 commit comments

Comments
 (0)