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
8 changes: 8 additions & 0 deletions Tests/test_imagefont.py
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,14 @@ def test_variation_set_by_name(font: ImageFont.FreeTypeFont) -> None:
_check_text(font, "Tests/images/variation_tiny_name.png", 40)


def test_truetype_bytes() -> None:
# Ensure bytestrings with the high bit set do not cause sign extension
font = ImageFont.truetype(
"Tests/fonts/FreeMono.ttf", 20, layout_engine=ImageFont.Layout.BASIC
)
assert font.getbbox(b"\xe9") == font.getbbox("\u00e9")


def test_variation_set_by_axes(font: ImageFont.FreeTypeFont) -> None:
with pytest.raises(OSError):
font.set_variation_by_axes([500, 50])
Expand Down
7 changes: 7 additions & 0 deletions docs/releasenotes/13.1.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,10 @@ not bundled into the wheels, so the system zlib was used at runtime instead, and
Pillow 13.0.0 also failed to import on systems where ``libz.so.1`` was not on the
default library search path, such as NixOS. Linux wheels no longer require a
system zlib, and gain the speed of zlib-ng as macOS and Windows wheels already did.

Kerning in the basic layout engine
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

When libraqm is not available, kerning was applied at 1/64th of its intended size,
because a value in pixels was added to an advance in 26.6 fixed point precision.
The full kerning value is now applied even when libraqm is not available.
6 changes: 3 additions & 3 deletions src/_imagingft.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ text_layout_fallback(
}
for (i = 0; i < count; i++) {
if (buffer) {
ch = buffer[i];
ch = (unsigned char)buffer[i];
} else {
ch = PyUnicode_READ_CHAR(string, i);
}
Expand All @@ -454,8 +454,8 @@ text_layout_fallback(
ft_kerning_default,
&delta
) == 0) {
(*glyph_info)[i - 1].x_advance += PIXEL(delta.x);
(*glyph_info)[i - 1].y_advance += PIXEL(delta.y);
(*glyph_info)[i - 1].x_advance += delta.x;
(*glyph_info)[i - 1].y_advance += delta.y;
}
}

Expand Down
Loading