diff --git a/src/PIL/ImageFont.py b/src/PIL/ImageFont.py index d8c265560..46a620271 100644 --- a/src/PIL/ImageFont.py +++ b/src/PIL/ImageFont.py @@ -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, diff --git a/src/PIL/_imagingft.pyi b/src/PIL/_imagingft.pyi index 9cc9822f5..a33df7621 100644 --- a/src/PIL/_imagingft.pyi +++ b/src/PIL/_imagingft.pyi @@ -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, /,