Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added text stroking #3978

Merged
merged 2 commits into from Sep 6, 2019
Merged

Added text stroking #3978

merged 2 commits into from Sep 6, 2019

Conversation

@radarhere
Copy link
Member

radarhere commented Jul 19, 2019

Resolves #2209. Replacement for #2224

Adds strokeWidth and strokeFill arguments, such that -

from PIL import Image, ImageDraw, ImageFont

font = ImageFont.truetype("Tests/fonts/FreeMono.ttf", 40)
font.getsize_multiline("A", strokeWidth=2)
font.getsize("ABC\nAaaa", strokeWidth=2)

im = Image.new("RGB", (100, 100))
draw = ImageDraw.Draw(im)
draw.textsize("A", font, strokeWidth=2)
draw.multiline_textsize("ABC\nAaaa", font, strokeWidth=2)
draw.text((10, 10), "A", "#f00", font, strokeWidth=2, strokeFill="#0f0")
draw.multiline_text((10, 10), "A\nB", "#f00", font, strokeWidth=2, strokeFill="#0f0")

Uses FreeType's stroking. See https://www.freetype.org/freetype2/docs/reference/ft2-glyph_stroker.html for more information, and part of https://www.freetype.org/freetype2/docs/tutorial/example2.cpp for example code.

Also renames a FT_GlyphSlot variable from 'glyph' to 'glyphSlot'.

src/PIL/ImageDraw.py Outdated Show resolved Hide resolved
@radarhere radarhere force-pushed the radarhere:stroke branch 3 times, most recently from bd71070 to ac613da Jul 19, 2019
docs/reference/ImageDraw.rst Outdated Show resolved Hide resolved

.. versionadded:: 6.2.0

.. py:method:: PIL.ImageDraw.ImageDraw.multiline_textsize(text, font=None, spacing=4, direction=None, features=None, language=None, strokeWidth=0)

This comment has been minimized.

Copy link
@hugovk

hugovk Jul 24, 2019

Member

And update the py:methods for the other updated ones.

src/PIL/ImageDraw.py Outdated Show resolved Hide resolved
src/PIL/ImageDraw.py Outdated Show resolved Hide resolved
src/_imagingft.c Outdated Show resolved Hide resolved
src/_imagingft.c Outdated Show resolved Hide resolved
src/_imagingft.c Outdated Show resolved Hide resolved
src/_imagingft.c Outdated Show resolved Hide resolved
src/_imagingft.c Outdated Show resolved Hide resolved
src/_imagingft.c Outdated Show resolved Hide resolved
@radarhere radarhere force-pushed the radarhere:stroke branch 2 times, most recently from bdc7068 to 4013dbb Jul 28, 2019
@radarhere radarhere force-pushed the radarhere:stroke branch from 4013dbb to f93a5d0 Jul 28, 2019
@hugovk
hugovk approved these changes Sep 5, 2019
Copy link
Member

hugovk left a comment

Just a naming thing, then we're good to merge. Thanks!

src/PIL/ImageDraw.py Outdated Show resolved Hide resolved
src/PIL/ImageDraw.py Outdated Show resolved Hide resolved
src/PIL/ImageDraw.py Outdated Show resolved Hide resolved
src/PIL/ImageDraw.py Outdated Show resolved Hide resolved
Co-Authored-By: Hugo van Kemenade <hugovk@users.noreply.github.com>
@radarhere radarhere merged commit da39d40 into python-pillow:master Sep 6, 2019
16 checks passed
16 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
python-pillow.Pillow Build #20190905.9 succeeded
Details
python-pillow.Pillow (Lint Python37) Lint Python37 succeeded
Details
python-pillow.Pillow (alpine) alpine succeeded
Details
python-pillow.Pillow (amazon_1_amd64) amazon_1_amd64 succeeded
Details
python-pillow.Pillow (amazon_2_amd64) amazon_2_amd64 succeeded
Details
python-pillow.Pillow (arch) arch succeeded
Details
python-pillow.Pillow (centos_6_amd64) centos_6_amd64 succeeded
Details
python-pillow.Pillow (centos_7_amd64) centos_7_amd64 succeeded
Details
python-pillow.Pillow (debian_10_buster_x86) debian_10_buster_x86 succeeded
Details
python-pillow.Pillow (debian_9_stretch_x86) debian_9_stretch_x86 succeeded
Details
python-pillow.Pillow (fedora_29_amd64) fedora_29_amd64 succeeded
Details
python-pillow.Pillow (fedora_30_amd64) fedora_30_amd64 succeeded
Details
python-pillow.Pillow (ubuntu_16_04_xenial_amd64) ubuntu_16_04_xenial_amd64 succeeded
Details
python-pillow.Pillow (ubuntu_18_04_bionic_amd64) ubuntu_18_04_bionic_amd64 succeeded
Details
@radarhere radarhere deleted the radarhere:stroke branch Sep 6, 2019
@nulano nulano mentioned this pull request Sep 30, 2019
18 of 19 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

3 participants
You can’t perform that action at this time.