[fpdf2] Update to 2.7.9 (#11953)

This commit is contained in:
Sebastian Rittau
2024-05-18 12:51:24 +02:00
committed by GitHub
parent 9a7ff272cc
commit 8bd6cebbb4
11 changed files with 82 additions and 45 deletions

View File

@@ -1,4 +1,4 @@
version = "2.7.8"
version = "2.7.9"
upstream_repository = "https://github.com/PyFPDF/fpdf2"
requires = ["Pillow>=10.3.0"]

View File

@@ -3,6 +3,8 @@ from collections.abc import Sequence
from dataclasses import dataclass
from typing import Final, Literal, TypedDict, type_check_only
from .enums import TextDirection
MAX_DEPTH: Final = 125
@type_check_only
@@ -40,17 +42,17 @@ class IsolatingRun:
def resolve_neutral_types(self) -> None: ...
def resolve_implicit_levels(self) -> None: ...
def auto_detect_base_direction(string: str, stop_at_pdi: bool = False, debug: bool = False) -> Literal["L", "R"]: ...
def auto_detect_base_direction(string: str, stop_at_pdi: bool = False, debug: bool = False) -> TextDirection: ...
def calculate_isolate_runs(paragraph: Sequence[BidiCharacter]) -> list[IsolatingRun]: ...
class BidiParagraph:
text: str
base_direction: Literal["L", "R"]
base_direction: TextDirection
debug: bool
base_embedding_level: int
characters: list[BidiCharacter]
def __init__(self, text: str, base_direction: Literal["L", "R"] | None = None, debug: bool = False) -> None: ...
def __init__(self, text: str, base_direction: TextDirection | None = None, debug: bool = False) -> None: ...
def get_characters(self) -> list[BidiCharacter]: ...
def get_characters_with_embedding_level(self) -> list[BidiCharacter]: ...
def get_reordered_characters(self) -> list[BidiCharacter]: ...

View File

@@ -41,6 +41,8 @@ class DeviceRGB(_DeviceRGBBase):
def __new__(cls, r: Number, g: Number, b: Number, a: Number | None = None) -> Self: ...
@property
def colors(self) -> tuple[Number, Number, Number]: ...
@property
def colors255(self) -> tuple[Number, Number, Number]: ...
def serialize(self) -> str: ...
class _DeviceGrayBase(NamedTuple):
@@ -51,7 +53,9 @@ class DeviceGray(_DeviceGrayBase):
OPERATOR: ClassVar[str]
def __new__(cls, g: Number, a: Number | None = None) -> Self: ...
@property
def colors(self) -> tuple[Number]: ...
def colors(self) -> tuple[Number, Number, Number]: ...
@property
def colors255(self) -> tuple[Number, Number, Number]: ...
def serialize(self) -> str: ...
class _DeviceCMYKBase(NamedTuple):

View File

@@ -44,6 +44,7 @@ class VAlign(CoerciveEnum):
B = "BOTTOM"
class TextEmphasis(CoerciveIntFlag):
NONE = 0
B = 1
I = 2
U = 4
@@ -70,6 +71,8 @@ class TableCellFillMode(CoerciveEnum):
ALL = "ALL"
ROWS = "ROWS"
COLUMNS = "COLUMNS"
EVEN_ROWS = "EVEN_ROWS"
EVEN_COLUMNS = "EVEN_COLUMNS"
def should_fill_cell(self, i: int, j: int) -> bool: ...
@@ -77,6 +80,10 @@ class TableSpan(CoerciveEnum):
ROW: Literal["ROW"]
COL: Literal["COL"]
class TableHeadingsDisplay(CoerciveIntEnum):
NONE = 0
ON_TOP_OF_EVERY_PAGE = 1
class RenderStyle(CoerciveEnum):
D = "DRAW"
F = "FILL"
@@ -259,3 +266,9 @@ class EncryptionMethod(Enum):
RC4 = 1
AES_128 = 2
AES_256 = 3
class TextDirection(CoerciveEnum):
LTR = "LTR"
RTL = "RTL"
TTB = "TTB"
BTT = "BTT"

View File

@@ -25,6 +25,7 @@ from .enums import (
RenderStyle,
TableBordersLayout,
TableCellFillMode,
TextDirection,
TextMarkupType,
TextMode as TextMode,
WrapMode as WrapMode,
@@ -207,7 +208,7 @@ class FPDF(GraphicsStateMixin):
self,
use_shaping_engine: bool = True,
features: dict[str, bool] | None = None,
direction: Literal["ltr", "rtl"] | None = None,
direction: Literal["ltr", "rtl"] | TextDirection | None = None,
script: str | None = None,
language: str | None = None,
) -> None: ...

View File

@@ -1,63 +1,70 @@
from _typeshed import Incomplete, SupportsKeysAndGetItem, Unused
from collections.abc import Callable, Iterable
from _typeshed import Incomplete, SupportsItemAccess, SupportsKeysAndGetItem, Unused
from collections.abc import Callable, Iterable, Mapping
from html.parser import HTMLParser
from logging import Logger
from typing import ClassVar, Final
from typing import ClassVar, Final, Literal, TypedDict, type_check_only
from typing_extensions import TypeAlias
from fpdf import FPDF
from .fonts import FontFace
from .table import Row, Table
__author__: Final[str]
__copyright__: Final[str]
_OLType: TypeAlias = Literal["1", "a", "A", "I", "i"]
LOGGER: Logger
BULLET_WIN1252: Final[str]
DEFAULT_HEADING_SIZES: dict[str, int]
DEGREE_WIN1252: Final[str]
HEADING_TAGS: Final[tuple[str, ...]]
DEFAULT_TAG_STYLES: Final[dict[str, FontFace]]
DEFAULT_TAG_INDENTS: Final[dict[str, int]]
COLOR_DICT: Final[dict[str, str]]
def color_as_decimal(color: str | None = "#000000") -> tuple[int, int, int] | None: ...
def parse_style(elem_attrs: SupportsItemAccess[str, str]) -> None: ...
@type_check_only
class _Emphasis(TypedDict):
b: bool
i: bool
u: bool
class HTML2FPDF(HTMLParser):
HTML_UNCLOSED_TAGS: ClassVar[tuple[str, ...]]
TABLE_LINE_HEIGHT: ClassVar[float]
pdf: FPDF
image_map: Incomplete
li_tag_indent: int
dd_tag_indent: int
image_map: Callable[[str], str]
ul_bullet_char: str
heading_sizes: dict[str, int]
pre_code_font: str
li_prefix_color: tuple[int, int, int]
warn_on_tags_not_matching: bool
style: Incomplete
font_size: Incomplete
emphasis: _Emphasis
font_size: float
follows_trailing_space: bool
follows_heading: bool
href: str
align: str
page_links: Incomplete
font_stack: Incomplete
style_stack: list[FontFace]
indent: int
bullet: Incomplete
font_color: Incomplete
table: Incomplete
table_col_width: Incomplete
table_col_index: Incomplete
td: Incomplete
th: Incomplete
tr: Incomplete
thead: Incomplete
tfoot: Incomplete
tr_index: Incomplete
theader: Incomplete
tfooter: Incomplete
theader_out: bool
table_row_height: int
heading_level: Incomplete
ol_type: list[_OLType]
bullet: list[Incomplete]
font_color: tuple[int, int, int]
heading_level: Incomplete | None
heading_above: float
heading_below: float
table_line_separators: bool
table: Table | None
table_row: Row | None
tr: dict[str, str] | None
td_th: dict[str, str] | None
tag_indents: dict[str, int]
tag_styles: dict[str, FontFace]
# Not initialized in __init__:
font_face: Incomplete
font_family: str
h: float
def __init__(
@@ -68,20 +75,26 @@ class HTML2FPDF(HTMLParser):
dd_tag_indent: int = 10,
table_line_separators: bool = False,
ul_bullet_char: str = "\x95",
li_prefix_color: tuple[int, int, int] = (190, 0, 0),
heading_sizes: SupportsKeysAndGetItem[str, int] | Iterable[tuple[str, int]] | None = None,
pre_code_font: str = "courier",
pre_code_font: str = ...,
warn_on_tags_not_matching: bool = True,
tag_indents: dict[str, int] | None = None,
tag_styles: Mapping[str, FontFace] | None = None,
**_: Unused,
): ...
def handle_data(self, data) -> None: ...
def handle_starttag(self, tag, attrs) -> None: ...
def handle_endtag(self, tag) -> None: ...
def set_font(self, face: Incomplete | None = None, size: Incomplete | None = None, set_default: bool = False) -> None: ...
def set_font(self, family: str | None = None, size: float | None = None, set_default: bool = False) -> None: ...
def set_style(self, tag: Incomplete | None = None, enable: bool = False) -> None: ...
def set_text_color(self, r: Incomplete | None = None, g: int = 0, b: int = 0) -> None: ...
def put_link(self, text) -> None: ...
def render_toc(self, pdf, outline) -> None: ...
def error(self, message: str) -> None: ...
def ul_prefix(ul_type: str) -> str: ...
def ol_prefix(ol_type: _OLType, index: int) -> str: ...
class HTMLMixin:
def __init__(self, *args, **kwargs) -> None: ...

View File

@@ -1,8 +1,8 @@
from _typeshed import Incomplete
from collections.abc import Callable, Sequence
from typing import Final, Literal, NamedTuple
from typing import Final, NamedTuple
from .enums import Align, WrapMode
from .enums import Align, TextDirection, WrapMode
SOFT_HYPHEN: Final[str]
HYPHEN: Final[str]
@@ -60,9 +60,9 @@ class Fragment:
@property
def text_shaping_parameters(self): ...
@property
def paragraph_direction(self) -> Literal["L", "R"]: ...
def paragraph_direction(self) -> TextDirection: ...
@property
def fragment_direction(self) -> Literal["L", "R"]: ...
def fragment_direction(self) -> TextDirection: ...
def trim(self, index: int) -> None: ...
def __eq__(self, other: Fragment) -> bool: ... # type: ignore[override]
def get_width(self, start: int = 0, end: int | None = None, chars: str | None = None, initial_cs: bool = True) -> float: ...

View File

@@ -7,7 +7,7 @@ from .syntax import Destination, PDFObject, PDFString
class OutlineSection(NamedTuple):
name: str
level: str
level: int
page_number: int
dest: Destination
struct_elem: StructElem | None = ...

View File

@@ -42,7 +42,6 @@ def optional(value, converter=...): ...
svg_attr_map: dict[str, Callable[[Incomplete], tuple[str, Incomplete]]]
def parse_style(svg_element) -> None: ...
def apply_styles(stylable, svg_element) -> None: ...
class ShapeBuilder:

View File

@@ -7,7 +7,7 @@ from typing import Literal, overload
from PIL import Image
from .drawing import DeviceGray, DeviceRGB
from .enums import Align, TableBordersLayout, TableCellFillMode, TableSpan, VAlign, WrapMode
from .enums import Align, TableBordersLayout, TableCellFillMode, TableHeadingsDisplay, TableSpan, VAlign, WrapMode
from .fonts import FontFace
from .fpdf import FPDF
from .util import Padding
@@ -40,6 +40,7 @@ class Table:
padding: float | Padding | None = None,
outer_border_width: float | None = None,
num_heading_rows: int = 1,
repeat_headings: TableHeadingsDisplay | int = 1,
) -> None: ...
def row(self, cells: Iterable[str] = (), style: FontFace | None = None) -> Row: ...
def render(self) -> None: ...

View File

@@ -23,6 +23,10 @@ def convert_unit(
old_unit: str | float,
new_unit: str | float,
) -> float | tuple[float, ...]: ...
ROMAN_NUMERAL_MAP: Final[tuple[tuple[str, int], ...]]
def int2roman(n: int) -> str: ...
def print_mem_usage(prefix: str) -> None: ...
def get_mem_usage(prefix: str) -> str: ...
def get_process_rss() -> str: ...