Skip to content

Allow default ImageDraw font to be set#6484

Merged
hugovk merged 3 commits intopython-pillow:mainfrom
radarhere:imagedraw_font
Aug 15, 2022
Merged

Allow default ImageDraw font to be set#6484
hugovk merged 3 commits intopython-pillow:mainfrom
radarhere:imagedraw_font

Conversation

@radarhere
Copy link
Copy Markdown
Member

Resolves #6480

By raising ImageDraw.ImageDraw.font from an instance variable to a class variable, a default ImageDraw font can be set by the user.

from PIL import ImageDraw, ImageFont
ImageDraw.ImageDraw.font = ImageFont.truetype("Tests/fonts/FreeMono.ttf", 120)

From then on, ImageDraw operations would use that font as the default, instead of the ImageFont.load_default() font.

Copy link
Copy Markdown
Member

@hugovk hugovk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough, let's add this to the release notes.

@radarhere
Copy link
Copy Markdown
Member Author

Ok, done

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
@hugovk hugovk merged commit 87ecd01 into python-pillow:main Aug 15, 2022
@radarhere radarhere deleted the imagedraw_font branch August 15, 2022 05:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support setting a default font

2 participants