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

Why not ship with a default font able to change font size in ImageDraw.Draw.text? #6622

Closed
wikiwen opened this issue Sep 27, 2022 · 8 comments · Fixed by #7354
Closed

Why not ship with a default font able to change font size in ImageDraw.Draw.text? #6622

wikiwen opened this issue Sep 27, 2022 · 8 comments · Fixed by #7354
Labels

Comments

@wikiwen
Copy link

wikiwen commented Sep 27, 2022

What did you do?

Hello, every author of Pillow! Thank you create this powerful tool in image processing.
I want to draw a text in a image. But I found so inconvenient to change font size. As the default font is unsupported to change font size, I need to download a truetype font file, and define a object ImageFont to change font size. Why not shipped with a default font able to change font size in ImageDraw.Draw.text like opencv?

What are your OS, Python and Pillow versions?

  • OS: CentOS
  • Python: 3.7
  • Pillow: 9.2.0
# Now: default font. can't change font size. Often so small in a image.
draw.text((10, 25), "world", font=None)

# Now: need download arial.ttf to change font size
font = ImageFont.truetype("arial.ttf", 15)
draw.text((10, 25), "world", font=font)

# Expected: default font, set font_size
draw.text((10, 25), "world", font_size=15)
@wikiwen
Copy link
Author

wikiwen commented Sep 27, 2022

similiar issue in 2017 #2695

@radarhere radarhere changed the title Why not shipped with a default font able to change font size in ImageDraw.Draw.text? Why not ship with a default font able to change font size in ImageDraw.Draw.text? Sep 28, 2022
@nulano
Copy link
Contributor

nulano commented Feb 2, 2023

I think the main reason this has not yet been done are concerns over file size.

The current default font has about 6.5KB, but uses 8.7KB due to base64 encoding.

Using this website, I found a monospace TrueType font Share Tech Mono that has about 42KB (about 57KB with base64 encoding, ~2.5% of current Pillow wheels) and is licensed under the Open Font License, which might be acceptable for including in Pillow.

@Yay295
Copy link
Contributor

Yay295 commented Feb 2, 2023

Share Tech Mono is only 16.3KB when converted to WOFF2, if that works. 21.6KB for WOFF.

@nulano
Copy link
Contributor

nulano commented Feb 2, 2023

WOFF2 support was added to Pillow wheels in 9.4.0, so that would probably be fine: #6562 / python-pillow/pillow-wheels#320 / python-pillow/pillow-wheels#322

@radarhere radarhere added the Fonts label Jun 7, 2023
@dandv

This comment was marked as off-topic.

@radarhere

This comment was marked as off-topic.

@aclark4life

This comment was marked as off-topic.

@radarhere
Copy link
Member

radarhere commented Aug 26, 2023

Using this website, I found a monospace TrueType font Share Tech Mono

sharetechmono

In my entirely subjective opinion, Share Tech Mono doesn't look quite "normal". I have instead found Aileron Regular, a CC0 font from https://dotcolon.net/font/aileron.

aileron

I've created PR #7354 as a possible solution to this.

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 a pull request may close this issue.

6 participants