Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Tests/test_imagefont.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def test_font_properties(font: ImageFont.FreeTypeFont) -> None:
font_copy = font.font_variant()
assert font_copy.path == FONT_PATH
assert font_copy.size == FONT_SIZE
assert font_copy.layout_engine == font.layout_engine

font_copy = font.font_variant(size=FONT_SIZE + 1)
assert font_copy.size == FONT_SIZE + 1
Expand All @@ -75,6 +76,20 @@ def test_font_properties(font: ImageFont.FreeTypeFont) -> None:
assert font_copy.path == second_font_path


@pytest.mark.parametrize(
"variant_layout_engine",
(
ImageFont.Layout.BASIC,
pytest.param(ImageFont.Layout.RAQM, marks=skip_unless_feature("raqm")),
),
)
def test_font_variant_layout_engine(
font: ImageFont.FreeTypeFont, variant_layout_engine: ImageFont.Layout
) -> None:
font_copy = font.font_variant(layout_engine=variant_layout_engine)
assert font_copy.layout_engine == variant_layout_engine


def _render(
font: StrOrBytesPath | BinaryIO, layout_engine: ImageFont.Layout
) -> Image.Image:
Expand Down
4 changes: 3 additions & 1 deletion src/PIL/ImageFont.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,9 @@ def font_variant(
size=self.size if size is None else size,
index=self.index if index is None else index,
encoding=self.encoding if encoding is None else encoding,
layout_engine=layout_engine or self.layout_engine,
layout_engine=(
layout_engine if layout_engine is not None else self.layout_engine
),
)

def get_variation_names(self) -> list[bytes]:
Expand Down
Loading