mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
document and add tests for SBIX color font support
This commit is contained in:
parent
058b8d3d12
commit
61ee8ec03c
2
.github/workflows/test-windows.yml
vendored
2
.github/workflows/test-windows.yml
vendored
|
@ -110,7 +110,7 @@ jobs:
|
|||
if: steps.build-cache.outputs.cache-hit != 'true'
|
||||
run: "& winbuild\\build\\build_dep_libwebp.cmd"
|
||||
|
||||
# for FreeType CBDT font support
|
||||
# for FreeType CBDT/SBIX font support
|
||||
- name: Build dependencies / libpng
|
||||
if: steps.build-cache.outputs.cache-hit != 'true'
|
||||
run: "& winbuild\\build\\build_dep_libpng.cmd"
|
||||
|
|
|
@ -15,6 +15,8 @@ FreeMono.ttf is licensed under GPLv3, with the GPL font exception.
|
|||
|
||||
OpenSansCondensed-LightItalic.tt, from https://fonts.google.com/specimen/Open+Sans, under Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
|
||||
|
||||
chromacheck-sbix.woff, from https://github.com/RoelN/ChromaCheck, under The MIT License (MIT), Copyright (c) 2018 Roel Nieskens, https://pixelambacht.nl Copyright (c) 2018 Google LLC
|
||||
|
||||
DejaVuSans-24-{1,2,4,8}-stripped.ttf are based on DejaVuSans.ttf converted using FontForge to add bitmap strikes and keep only the ASCII range.
|
||||
|
||||
|
||||
|
|
BIN
Tests/fonts/chromacheck-sbix.woff
Normal file
BIN
Tests/fonts/chromacheck-sbix.woff
Normal file
Binary file not shown.
BIN
Tests/images/chromacheck-sbix.png
Normal file
BIN
Tests/images/chromacheck-sbix.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
BIN
Tests/images/chromacheck-sbix_mask.png
Normal file
BIN
Tests/images/chromacheck-sbix_mask.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
|
@ -897,6 +897,46 @@ class TestImageFont:
|
|||
assert str(e) in ("unimplemented feature", "unknown file format")
|
||||
pytest.skip("freetype compiled without libpng or unsupported")
|
||||
|
||||
@skip_unless_feature_version("freetype2", "2.5.1")
|
||||
def test_sbix(self):
|
||||
try:
|
||||
font = ImageFont.truetype(
|
||||
"Tests/fonts/chromacheck-sbix.woff",
|
||||
size=300,
|
||||
layout_engine=self.LAYOUT_ENGINE,
|
||||
)
|
||||
|
||||
im = Image.new("RGB", (400, 400), "white")
|
||||
d = ImageDraw.Draw(im)
|
||||
|
||||
d.text((50, 50), "\uE901", embedded_color=True, font=font)
|
||||
|
||||
with Image.open("Tests/images/chromacheck-sbix.png") as expected:
|
||||
assert_image_similar(im, expected, 1)
|
||||
except IOError as e:
|
||||
assert str(e) in ("unimplemented feature", "unknown file format")
|
||||
pytest.skip("freetype compiled without libpng or unsupported")
|
||||
|
||||
@skip_unless_feature_version("freetype2", "2.5.1")
|
||||
def test_sbix_mask(self):
|
||||
try:
|
||||
font = ImageFont.truetype(
|
||||
"Tests/fonts/chromacheck-sbix.woff",
|
||||
size=300,
|
||||
layout_engine=self.LAYOUT_ENGINE,
|
||||
)
|
||||
|
||||
im = Image.new("RGB", (400, 400), "white")
|
||||
d = ImageDraw.Draw(im)
|
||||
|
||||
d.text((50, 50), "\uE901", (100, 0, 0), font=font)
|
||||
|
||||
with Image.open("Tests/images/chromacheck-sbix_mask.png") as expected:
|
||||
assert_image_similar(im, expected, 1)
|
||||
except IOError as e:
|
||||
assert str(e) in ("unimplemented feature", "unknown file format")
|
||||
pytest.skip("freetype compiled without libpng or unsupported")
|
||||
|
||||
@skip_unless_feature_version("freetype2", "2.10.0")
|
||||
def test_colr(self):
|
||||
font = ImageFont.truetype(
|
||||
|
|
|
@ -352,7 +352,7 @@ Methods
|
|||
|
||||
.. versionadded:: 6.2.0
|
||||
|
||||
:param embedded_color: Whether to use font embedded color glyphs (COLR or CBDT).
|
||||
:param embedded_color: Whether to use font embedded color glyphs (COLR, CBDT, SBIX).
|
||||
|
||||
.. versionadded:: 8.0.0
|
||||
|
||||
|
@ -413,7 +413,7 @@ Methods
|
|||
|
||||
.. versionadded:: 6.2.0
|
||||
|
||||
:param embedded_color: Whether to use font embedded color glyphs (COLR or CBDT).
|
||||
:param embedded_color: Whether to use font embedded color glyphs (COLR, CBDT, SBIX).
|
||||
|
||||
.. versionadded:: 8.0.0
|
||||
|
||||
|
@ -577,7 +577,7 @@ Methods
|
|||
correct substitutions as appropriate, if available.
|
||||
It should be a `BCP 47 language code`_.
|
||||
Requires libraqm.
|
||||
:param embedded_color: Whether to use font embedded color glyphs (COLR or CBDT).
|
||||
:param embedded_color: Whether to use font embedded color glyphs (COLR, CBDT, SBIX).
|
||||
|
||||
.. py:method:: ImageDraw.textbbox(xy, text, font=None, anchor=None, spacing=4, align="left", direction=None, features=None, language=None, stroke_width=0, embedded_color=False)
|
||||
|
||||
|
@ -626,7 +626,7 @@ Methods
|
|||
It should be a `BCP 47 language code`_.
|
||||
Requires libraqm.
|
||||
:param stroke_width: The width of the text stroke.
|
||||
:param embedded_color: Whether to use font embedded color glyphs (COLR or CBDT).
|
||||
:param embedded_color: Whether to use font embedded color glyphs (COLR, CBDT, SBIX).
|
||||
|
||||
.. py:method:: ImageDraw.multiline_textbbox(xy, text, font=None, anchor=None, spacing=4, align="left", direction=None, features=None, language=None, stroke_width=0, embedded_color=False)
|
||||
|
||||
|
@ -669,7 +669,7 @@ Methods
|
|||
It should be a `BCP 47 language code`_.
|
||||
Requires libraqm.
|
||||
:param stroke_width: The width of the text stroke.
|
||||
:param embedded_color: Whether to use font embedded color glyphs (COLR or CBDT).
|
||||
:param embedded_color: Whether to use font embedded color glyphs (COLR, CBDT, SBIX).
|
||||
|
||||
.. py:method:: getdraw(im=None, hints=None)
|
||||
|
||||
|
|
|
@ -115,8 +115,9 @@ now support fonts with embedded color data.
|
|||
To render text with embedded color data, use the parameter ``embedded_color=True``.
|
||||
|
||||
Support for CBDT fonts requires FreeType 2.5 compiled with libpng.
|
||||
Support for SBIX fonts requires FreeType 2.5.1 compiled with libpng.
|
||||
Support for COLR fonts requires FreeType 2.10.
|
||||
SBIX and SVG fonts are not yet supported.
|
||||
SVG fonts are not yet supported.
|
||||
|
||||
ImageDraw.textlength
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
Loading…
Reference in New Issue
Block a user