Use anchor and direction in ImageFont

This commit is contained in:
Andrew Murray 2025-01-26 13:52:43 +11:00
parent 83c19d8f3e
commit dd7e092513
2 changed files with 14 additions and 13 deletions

View File

@ -37,7 +37,7 @@ from types import ModuleType
from typing import IO, TYPE_CHECKING, Any, BinaryIO, TypedDict, cast
from . import Image, features
from ._typing import StrOrBytesPath
from ._typing import Anchor, Direction, StrOrBytesPath
from ._util import DeferredError, is_path
if TYPE_CHECKING:
@ -313,7 +313,7 @@ class FreeTypeFont:
self,
text: str | bytes,
mode: str = "",
direction: str | None = None,
direction: Direction | None = None,
features: list[str] | None = None,
language: str | None = None,
) -> float:
@ -392,11 +392,11 @@ class FreeTypeFont:
self,
text: str | bytes,
mode: str = "",
direction: str | None = None,
direction: Direction | None = None,
features: list[str] | None = None,
language: str | None = None,
stroke_width: float = 0,
anchor: str | None = None,
anchor: Anchor | None = None,
) -> tuple[float, float, float, float]:
"""
Returns bounding box (in pixels) of given text relative to given anchor
@ -458,11 +458,11 @@ class FreeTypeFont:
self,
text: str | bytes,
mode: str = "",
direction: str | None = None,
direction: Direction | None = None,
features: list[str] | None = None,
language: str | None = None,
stroke_width: float = 0,
anchor: str | None = None,
anchor: Anchor | None = None,
ink: int = 0,
start: tuple[float, float] | None = None,
) -> Image.core.ImagingCore:
@ -549,11 +549,11 @@ class FreeTypeFont:
self,
text: str | bytes,
mode: str = "",
direction: str | None = None,
direction: Direction | None = None,
features: list[str] | None = None,
language: str | None = None,
stroke_width: float = 0,
anchor: str | None = None,
anchor: Anchor | None = None,
ink: int = 0,
start: tuple[float, float] | None = None,
*args: Any,

View File

@ -1,6 +1,7 @@
from typing import Any, Callable
from . import ImageFont, _imaging
from ._typing import Anchor, Direction
class Font:
@property
@ -24,11 +25,11 @@ class Font:
string: str | bytes,
fill: Callable[[int, int], _imaging.ImagingCore],
mode: str,
dir: str | None,
dir: Direction | None,
features: list[str] | None,
lang: str | None,
stroke_width: float,
anchor: str | None,
anchor: Anchor | None,
foreground_ink_long: int,
x_start: float,
y_start: float,
@ -38,17 +39,17 @@ class Font:
self,
string: str | bytes | bytearray,
mode: str,
dir: str | None,
dir: Direction | None,
features: list[str] | None,
lang: str | None,
anchor: str | None,
anchor: Anchor | None,
/,
) -> tuple[tuple[int, int], tuple[int, int]]: ...
def getlength(
self,
string: str | bytes,
mode: str,
dir: str | None,
dir: Direction | None,
features: list[str] | None,
lang: str | None,
/,