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

Fix default font loading for 'add_grid' #24

Merged
merged 5 commits into from
Jan 4, 2019

Conversation

djhoese
Copy link
Member

@djhoese djhoese commented Jan 3, 2019

I think this has always been an issue but has become very apparent in my own code after switching to the AGG contour writer by default. The main issue is that the _add_grid method in the base writer will try to load a default font object if one is not provided. It was using PIL.ImageFont.load_default() to get an ImageFont object to use. The issue with that is that aggdraw does not handle ImageFont objects, it only handles aggdraw.Font objects.

This PR adds a font loading method implemented by the writer subclasses. It also moves the font loading in to the label adding method so it isn't loaded unless labels are actually going to be written.

This is a short term fix. The long term fix should some how handle the differences between ImageFont which accepts font path and size only and Font accepts color (outline), font path, and size. Even worse the ImageFont.load_default() returned font can't have its size specified or changed which is...not very useful.

  • Tests added
  • Tests passed
  • Passes git diff origin/develop **/*py | flake8 --diff

@djhoese djhoese added the bug label Jan 3, 2019
@djhoese djhoese self-assigned this Jan 3, 2019
@coveralls
Copy link

coveralls commented Jan 3, 2019

Coverage Status

Coverage decreased (-0.3%) to 79.464% when pulling 765b3e6 on djhoese:bugfix-font-loading into eb186a0 on pytroll:master.

@djhoese
Copy link
Member Author

djhoese commented Jan 4, 2019

The only reason the coverage went down for this is because I moved code that shouldn't have been tested (font loading) to the location where it is actually used. Previously fonts were loaded and then not used. I plan on merging this later today.

@djhoese djhoese merged commit 7cae716 into pytroll:master Jan 4, 2019
@djhoese djhoese deleted the bugfix-font-loading branch January 4, 2019 18:48
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.

None yet

2 participants