Merge branch 'main' into harfbuzz

This commit is contained in:
Hugo van Kemenade 2025-09-04 13:36:29 +03:00 committed by GitHub
commit b4e36e267f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 93 additions and 74 deletions

View File

@ -96,13 +96,12 @@ ARCHIVE_SDIR=pillow-depends-main
FREETYPE_VERSION=2.13.3
HARFBUZZ_VERSION=11.4.5
LIBPNG_VERSION=1.6.50
JPEGTURBO_VERSION=3.1.1
JPEGTURBO_VERSION=3.1.2
OPENJPEG_VERSION=2.5.3
XZ_VERSION=5.8.1
TIFF_VERSION=4.7.0
LCMS2_VERSION=2.17
ZLIB_VERSION=1.3.1
ZLIB_NG_VERSION=2.2.4
ZLIB_NG_VERSION=2.2.5
LIBWEBP_VERSION=1.6.0
BZIP2_VERSION=1.0.8
LIBXCB_VERSION=1.17.0
@ -259,11 +258,7 @@ function build {
if [ -z "$IS_ALPINE" ] && [ -z "$SANITIZER" ] && [ -z "$IS_MACOS" ]; then
yum remove -y zlib-devel
fi
if [[ -n "$IS_MACOS" ]] && [[ "$MACOSX_DEPLOYMENT_TARGET" == "10.10" || "$MACOSX_DEPLOYMENT_TARGET" == "10.13" ]]; then
build_new_zlib
else
build_zlib_ng
fi
build_zlib_ng
build_simple xcb-proto 1.17.0 https://xorg.freedesktop.org/archive/individual/proto
if [[ -n "$IS_MACOS" ]]; then

View File

@ -1,6 +1,6 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.12.7
rev: v0.12.11
hooks:
- id: ruff-check
args: [--exit-non-zero-on-fix]
@ -24,7 +24,7 @@ repos:
exclude: (Makefile$|\.bat$|\.cmake$|\.eps$|\.fits$|\.gd$|\.opt$|\.patch$)
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v20.1.8
rev: v21.1.0
hooks:
- id: clang-format
types: [c]
@ -36,7 +36,7 @@ repos:
- id: rst-backticks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
rev: v6.0.0
hooks:
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
@ -51,14 +51,14 @@ repos:
exclude: ^.github/.*TEMPLATE|^Tests/(fonts|images)/|\.patch$
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.33.2
rev: 0.33.3
hooks:
- id: check-github-workflows
- id: check-readthedocs
- id: check-renovate
- repo: https://github.com/zizmorcore/zizmor-pre-commit
rev: v1.11.0
rev: v1.12.1
hooks:
- id: zizmor

View File

@ -2,7 +2,7 @@ from __future__ import annotations
import pytest
from PIL import Image, ImageDraw, ImageFont
from PIL import ImageFont
from .helper import skip_unless_feature
@ -12,10 +12,6 @@ class TestFontCrash:
# from fuzzers.fuzz_font
font.getbbox("ABC")
font.getmask("test text")
with Image.new(mode="RGBA", size=(200, 200)) as im:
draw = ImageDraw.Draw(im)
draw.multiline_textbbox((10, 10), "ABC\nAaaa", font, stroke_width=2)
draw.text((10, 10), "Test Text", font=font, fill="#000")
@skip_unless_feature("freetype2")
def test_segfault(self) -> None:

View File

@ -7,7 +7,7 @@ import pytest
from PIL import Image, ImageMorph, _imagingmorph
from .helper import assert_image_equal_tofile, hopper
from .helper import assert_image_equal_tofile, hopper, timeout_unless_slower_valgrind
def string_to_img(image_string: str) -> Image.Image:
@ -266,16 +266,18 @@ def test_unknown_pattern() -> None:
ImageMorph.LutBuilder(op_name="unknown")
def test_pattern_syntax_error() -> None:
@pytest.mark.parametrize(
"pattern", ("a pattern with a syntax error", "4:(" + "X" * 30000)
)
@timeout_unless_slower_valgrind(1)
def test_pattern_syntax_error(pattern: str) -> None:
# Arrange
lb = ImageMorph.LutBuilder(op_name="corner")
new_patterns = ["a pattern with a syntax error"]
new_patterns = [pattern]
lb.add_patterns(new_patterns)
# Act / Assert
with pytest.raises(
Exception, match='Syntax error in pattern "a pattern with a syntax error"'
):
with pytest.raises(Exception, match='Syntax error in pattern "'):
lb.build_lut()

View File

@ -4,7 +4,6 @@ import platform
import sys
from PIL import features
from Tests.helper import is_pypy
def test_wheel_modules() -> None:
@ -48,8 +47,6 @@ def test_wheel_features() -> None:
if sys.platform == "win32":
expected_features.remove("xcb")
elif sys.platform == "darwin" and not is_pypy() and platform.processor() != "arm":
expected_features.remove("zlib_ng")
elif sys.platform == "ios":
# Can't distribute raqm due to licensing, and there's no system version;
# fribidi and harfbuzz won't be available if raqm isn't available.

View File

@ -2,7 +2,7 @@
# install raqm
archive=libraqm-0.10.2
archive=libraqm-0.10.3
./download-and-extract.sh $archive https://raw.githubusercontent.com/python-pillow/pillow-depends/main/$archive.tar.gz

View File

@ -150,3 +150,10 @@ others prepare for 3.14, and to ensure Pillow could be used immediately at the r
of 3.14.0 final (2025-10-07, :pep:`745`).
Pillow 12.0.0 now officially supports Python 3.14.
ImageMorph operations must have length 1
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Valid ImageMorph operations are 4, N, 1 and M. By limiting the length to 1 character
within Pillow, long execution times can be avoided if a user provided long pattern
strings. Reported by Jang Choi.

View File

@ -150,7 +150,7 @@ class LutBuilder:
# Parse and create symmetries of the patterns strings
for p in self.patterns:
m = re.search(r"(\w*):?\s*\((.+?)\)\s*->\s*(\d)", p.replace("\n", ""))
m = re.search(r"(\w):?\s*\((.+?)\)\s*->\s*(\d)", p.replace("\n", ""))
if not m:
msg = 'Syntax error in pattern "' + p + '"'
raise Exception(msg)

View File

@ -148,7 +148,7 @@ ImagingPaletteDelete(ImagingPalette palette) {
#define BOX 8
#define BOXVOLUME BOX *BOX *BOX
#define BOXVOLUME BOX * BOX * BOX
void
ImagingPaletteCacheUpdate(ImagingPalette palette, int r, int g, int b) {

View File

@ -1,7 +1,7 @@
The MIT License (MIT)
Copyright © 2015 Information Technology Authority (ITA) <foss@ita.gov.om>
Copyright © 2016-2023 Khaled Hosny <khaled@aliftype.com>
Copyright © 2016-2025 Khaled Hosny <khaled@aliftype.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -1,3 +1,19 @@
Overview of changes leading to 0.10.3
Tuesday, August 5, 2025
====================================
Fix raqm_set_text_utf8/utf16 reading beyond len for multibyte.
Support building against SheenBidi 2.9.
Fix deprecation warning with latest HarfBuzz.
Overview of changes leading to 0.10.2
Sunday, September 22, 2024
====================================
Fix Unicode codepoint conversion from UTF-16.
Overview of changes leading to 0.10.1
Wednesday, April 12, 2023
====================================

View File

@ -33,9 +33,9 @@
#define RAQM_VERSION_MAJOR 0
#define RAQM_VERSION_MINOR 10
#define RAQM_VERSION_MICRO 1
#define RAQM_VERSION_MICRO 3
#define RAQM_VERSION_STRING "0.10.1"
#define RAQM_VERSION_STRING "0.10.3"
#define RAQM_VERSION_ATLEAST(major,minor,micro) \
((major)*10000+(minor)*100+(micro) <= \

View File

@ -30,7 +30,11 @@
#include <string.h>
#ifdef RAQM_SHEENBIDI
#ifdef RAQM_SHEENBIDI_GT_2_9
#include <SheenBidi/SheenBidi.h>
#else
#include <SheenBidi.h>
#endif
#else
#ifdef HAVE_FRIBIDI_SYSTEM
#include <fribidi.h>
@ -546,34 +550,32 @@ raqm_set_text (raqm_t *rq,
return true;
}
static void *
_raqm_get_utf8_codepoint (const void *str,
static const char *
_raqm_get_utf8_codepoint (const char *str,
uint32_t *out_codepoint)
{
const char *s = (const char *)str;
if (0xf0 == (0xf8 & s[0]))
if (0xf0 == (0xf8 & str[0]))
{
*out_codepoint = ((0x07 & s[0]) << 18) | ((0x3f & s[1]) << 12) | ((0x3f & s[2]) << 6) | (0x3f & s[3]);
s += 4;
*out_codepoint = ((0x07 & str[0]) << 18) | ((0x3f & str[1]) << 12) | ((0x3f & str[2]) << 6) | (0x3f & str[3]);
str += 4;
}
else if (0xe0 == (0xf0 & s[0]))
else if (0xe0 == (0xf0 & str[0]))
{
*out_codepoint = ((0x0f & s[0]) << 12) | ((0x3f & s[1]) << 6) | (0x3f & s[2]);
s += 3;
*out_codepoint = ((0x0f & str[0]) << 12) | ((0x3f & str[1]) << 6) | (0x3f & str[2]);
str += 3;
}
else if (0xc0 == (0xe0 & s[0]))
else if (0xc0 == (0xe0 & str[0]))
{
*out_codepoint = ((0x1f & s[0]) << 6) | (0x3f & s[1]);
s += 2;
*out_codepoint = ((0x1f & str[0]) << 6) | (0x3f & str[1]);
str += 2;
}
else
{
*out_codepoint = s[0];
s += 1;
*out_codepoint = str[0];
str += 1;
}
return (void *)s;
return str;
}
static size_t
@ -585,42 +587,41 @@ _raqm_u8_to_u32 (const char *text, size_t len, uint32_t *unicode)
while ((*in_utf8 != '\0') && (in_len < len))
{
in_utf8 = _raqm_get_utf8_codepoint (in_utf8, out_utf32);
const char *out_utf8 = _raqm_get_utf8_codepoint (in_utf8, out_utf32);
in_len += out_utf8 - in_utf8;
in_utf8 = out_utf8;
++out_utf32;
++in_len;
}
return (out_utf32 - unicode);
}
static void *
_raqm_get_utf16_codepoint (const void *str,
uint32_t *out_codepoint)
static const uint16_t *
_raqm_get_utf16_codepoint (const uint16_t *str,
uint32_t *out_codepoint)
{
const uint16_t *s = (const uint16_t *)str;
if (s[0] > 0xD800 && s[0] < 0xDBFF)
if (str[0] >= 0xD800 && str[0] <= 0xDBFF)
{
if (s[1] > 0xDC00 && s[1] < 0xDFFF)
if (str[1] >= 0xDC00 && str[1] <= 0xDFFF)
{
uint32_t X = ((s[0] & ((1 << 6) -1)) << 10) | (s[1] & ((1 << 10) -1));
uint32_t W = (s[0] >> 6) & ((1 << 5) - 1);
uint32_t X = ((str[0] & ((1 << 6) -1)) << 10) | (str[1] & ((1 << 10) -1));
uint32_t W = (str[0] >> 6) & ((1 << 5) - 1);
*out_codepoint = (W+1) << 16 | X;
s += 2;
str += 2;
}
else
{
/* A single high surrogate, this is an error. */
*out_codepoint = s[0];
s += 1;
*out_codepoint = str[0];
str += 1;
}
}
else
{
*out_codepoint = s[0];
s += 1;
*out_codepoint = str[0];
str += 1;
}
return (void *)s;
return str;
}
static size_t
@ -632,9 +633,10 @@ _raqm_u16_to_u32 (const uint16_t *text, size_t len, uint32_t *unicode)
while ((*in_utf16 != '\0') && (in_len < len))
{
in_utf16 = _raqm_get_utf16_codepoint (in_utf16, out_utf32);
const uint16_t *out_utf16 = _raqm_get_utf16_codepoint (in_utf16, out_utf32);
in_len += (out_utf16 - in_utf16);
in_utf16 = out_utf16;
++out_utf32;
++in_len;
}
return (out_utf32 - unicode);
@ -1114,12 +1116,12 @@ _raqm_set_spacing (raqm_t *rq,
{
if (_raqm_allowed_grapheme_boundary (rq->text[i], rq->text[i+1]))
{
/* CSS word seperators, word spacing is only applied on these.*/
/* CSS word separators, word spacing is only applied on these.*/
if (rq->text[i] == 0x0020 || /* Space */
rq->text[i] == 0x00A0 || /* No Break Space */
rq->text[i] == 0x1361 || /* Ethiopic Word Space */
rq->text[i] == 0x10100 || /* Aegean Word Seperator Line */
rq->text[i] == 0x10101 || /* Aegean Word Seperator Dot */
rq->text[i] == 0x10100 || /* Aegean Word Separator Line */
rq->text[i] == 0x10101 || /* Aegean Word Separator Dot */
rq->text[i] == 0x1039F || /* Ugaric Word Divider */
rq->text[i] == 0x1091F) /* Phoenician Word Separator */
{
@ -2167,6 +2169,10 @@ _raqm_ft_transform (int *x,
*y = vector.y;
}
#if !HB_VERSION_ATLEAST (10, 4, 0)
# define hb_ft_font_get_ft_face hb_ft_font_get_face
#endif
static bool
_raqm_shape (raqm_t *rq)
{
@ -2199,7 +2205,7 @@ _raqm_shape (raqm_t *rq)
hb_glyph_position_t *pos;
unsigned int len;
FT_Get_Transform (hb_ft_font_get_face (run->font), &matrix, NULL);
FT_Get_Transform (hb_ft_font_get_ft_face (run->font), &matrix, NULL);
pos = hb_buffer_get_glyph_positions (run->buffer, &len);
info = hb_buffer_get_glyph_infos (run->buffer, &len);

View File

@ -117,7 +117,7 @@ V = {
"FREETYPE": "2.13.3",
"FRIBIDI": "1.0.16",
"HARFBUZZ": "11.4.5",
"JPEGTURBO": "3.1.1",
"JPEGTURBO": "3.1.2",
"LCMS2": "2.17",
"LIBAVIF": "1.3.0",
"LIBIMAGEQUANT": "4.4.0",
@ -126,7 +126,7 @@ V = {
"OPENJPEG": "2.5.3",
"TIFF": "4.7.0",
"XZ": "5.8.1",
"ZLIBNG": "2.2.4",
"ZLIBNG": "2.2.5",
}
V["LIBPNG_XY"] = "".join(V["LIBPNG"].split(".")[:2])