Thanks to visit codestin.com
Credit goes to github.com

Skip to content

FIX: Check for fontsize smaller than 1 pt and round up #10010

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

Merged
merged 1 commit into from
Jan 15, 2018

Conversation

jklymak
Copy link
Member

@jklymak jklymak commented Dec 14, 2017

PR Summary

FreeType doesn't allow fonts to get smaller than 1 pt, so all Agg backends were silently rounding up to 1 pt. PDF (other vector backends?) were letting us write fonts that were less than 1 pt, but they could not be placed properly because position information comes from FreeType. This change makes it so no backends can use fonts smaller than 1 pt, consistent with FreeType and ensuring more consistent results across backends.

A message is logged at the logger.INFO level. Could be convinced this should be higher level or a warning.warn

The argument against this is that small fonts can currently be written in PDF, but given that their positioning is all borked, this doesn't seem like a good thing to offer.

Its not clear why FreeType doesn't allow smaller fonts.

This addresses, if it doesn't solve #9963

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@jklymak jklymak added this to the v2.2 milestone Dec 15, 2017
@@ -878,6 +878,10 @@ def set_size(self, size):
+ ", ".join(map(str, font_scalings)))
else:
size = scale * FontManager.get_default_size()
if size < 1.0:
_log.info('Fontsize %1.2f < 1.0 pt not allowed by FreeType. '
'Setting fontsize = 1 pt' % size)
Copy link
Member

Choose a reason for hiding this comment

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

You should not be doing the formatting, but passing a separate arg to _log.info, no?

@jklymak jklymak force-pushed the fix-check-fontsize branch from 8a6e4f8 to 6c6ef7e Compare January 9, 2018 01:29
@jklymak jklymak force-pushed the fix-check-fontsize branch from 6c6ef7e to 8d1f597 Compare January 11, 2018 00:30
@QuLogic QuLogic merged commit 12a3b4f into matplotlib:master Jan 15, 2018
@QuLogic QuLogic modified the milestones: needs sorting, v2.2.0 Feb 12, 2018
@jklymak jklymak deleted the fix-check-fontsize branch March 5, 2019 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants