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

Handle PCF fonts files with less than 256 characters #6386

Merged

Conversation

dawidcrivelli
Copy link
Contributor

Fixes loading fonts where a lot of basic characters are missing.

Here is an example clR4x6.pcf.gz, from the X11 misc fixed-sized fonts, found on Ubuntu at /usr/share/fonts/X11/misc/clR4x6.pcf.gz

@radarhere
Copy link
Member

We like to have tests with our PRs, so that we can guard against this change being accidentally reverted in the future.

Is the font one that we can include in our test suite and distribute under Pillow's license?

@dawidcrivelli
Copy link
Contributor Author

I believe so, it's available from X.org: https://www.x.org/releases/individual/font/font-schumacher-misc-1.0.0.tar.gz , but I'm not an expert on open-source licenses.

The copyright notice says:

Copyright 1989 Dale Schumacher, dal@syntel.mn.org
               399 Beacon Ave.
               St. Paul, MN  55104-3527

Permission to use, copy, modify, and distribute this software and
its documentation for any purpose and without fee is hereby
granted, provided that the above copyright notice appear in all
copies and that both that copyright notice and this permission
notice appear in supporting documentation, and that the name of
Dale Schumacher not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior
permission.  Dale Schumacher makes no representations about the
suitability of this software for any purpose.  It is provided "as
is" without express or implied warranty.

@nulano
Copy link
Contributor

nulano commented Jun 23, 2022

My Google search suggests this is a variant of the MIT license, so should be compatible with Pillow: https://spdx.org/licenses/MIT-CMU.html

@hugovk
Copy link
Member

hugovk commented Jun 23, 2022

With whitespace adjustments, the font's licence on the left, MIT-CMU on the right:

image

@radarhere
Copy link
Member

I've pushed a commit that adds a test, using a hexedited version of https://github.com/python-pillow/Pillow/blob/main/Tests/fonts/10x20-ISO8859-1.pcf.

I've also changed this to no longer catch the exception, but instead to not look beyond the number of characters in the first place.

@radarhere radarhere force-pushed the handle_pcf_missing_characters branch from 0b6a65a to 93805d5 Compare June 27, 2022 04:05
@radarhere radarhere changed the title Handle PCF fonts files with missing characters Handle PCF fonts files with less than 256 characters Jun 27, 2022
@hugovk hugovk merged commit 714ff4e into python-pillow:main Jun 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants