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

Implement Font-Fallback for Agg backend #20740

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

@aitikgupta
Copy link
Contributor

@aitikgupta aitikgupta commented Jul 25, 2021

PR Summary

This PR modifies the internal structure of FT2Font (the interface between fonts and Matplotlib) in favor of implementing Font Fallback for the Agg backend.
It builds on the previous PR: #20549, which was the 'first-step', i.e., "parsing multiple families".. this PR implements using those families for font fallback.

This would help us in multi-language support, for example (Previous / After):

^the fonts are chosen such that the difference is visually noticeable.
Here's the script:

import matplotlib.pyplot as plt
# "Authentic" is a fancy font, whereas "SimHei" is a CJK font
plt.rcParams['font.family'] = ['Authentic', 'SimHei']
plt.rcParams['font.size'] = 30

plt.figtext(0.18, 0.45, "There are 多个汉字 in between!")
plt.show()

Fixes #18883, #15260

PR Checklist

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (run flake8 on changed files to check).
  • New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • Conforms to Matplotlib style conventions (install flake8-docstrings and run flake8 --docstring-convention=all).
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
@aitikgupta
Copy link
Contributor Author

@aitikgupta aitikgupta commented Jul 25, 2021

To actually trigger this workflow, I'll push similar commits similar to #20549..
Note: this is only tested against Agg backend (since agg is pretty straightforward in terms of font usage)

Also, there's a lot of print/debug statements throughout, I'll remove them once this moves ahead..

@aitikgupta aitikgupta marked this pull request as draft Jul 26, 2021
@aitikgupta aitikgupta force-pushed the aitikgupta:fallback-revamp branch 2 times, most recently from 9aee34b to 9fabbc7 Aug 6, 2021
@aitikgupta aitikgupta changed the title Implement Font-Fallback in Matplotlib Implement Font-Fallback for Agg backend Aug 6, 2021
@aitikgupta
Copy link
Contributor Author

@aitikgupta aitikgupta commented Aug 7, 2021

Note: There's some structural changes to how FT2Font is handling stuff in #20804, which builds on this PR..

EDIT: I've merged the FT2Font changes together for both PRs

@aitikgupta aitikgupta force-pushed the aitikgupta:fallback-revamp branch from 0703566 to 0fa0625 Aug 7, 2021
@aitikgupta aitikgupta force-pushed the aitikgupta:fallback-revamp branch from 0fa0625 to e868fbc Aug 7, 2021
@aitikgupta aitikgupta marked this pull request as ready for review Aug 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

1 participant