Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Add font feature API to FontProperties and Text#29695
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Open
QuLogic wants to merge1 commit intomatplotlib:mainChoose a base branch fromQuLogic:font-features
base:main
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
+140 −17
Open
Changes fromall commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
40 changes: 40 additions & 0 deletionsdoc/users/next_whats_new/font_features.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
Specifying font feature tags | ||
---------------------------- | ||
OpenType fonts may support feature tags that specify alternate glyph shapes or | ||
substitutions to be made optionally. The text API now supports setting a list of feature | ||
tags to be used with the associated font. Feature tags can be set/get with: | ||
- `matplotlib.text.Text.set_fontfeatures` / `matplotlib.text.Text.get_fontfeatures` | ||
- Any API that creates a `.Text` object by passing the *fontfeatures* argument (e.g., | ||
``plt.xlabel(..., fontfeatures=...)``) | ||
Font feature strings are eventually passed to HarfBuzz, and so all `string formats | ||
supported by hb_feature_from_string() | ||
<https://harfbuzz.github.io/harfbuzz-hb-common.html#hb-feature-from-string>`__ are | ||
supported. | ||
For example, the default font ``DejaVu Sans`` enables Standard Ligatures (the ``'liga'`` | ||
tag) by default, and also provides optional Discretionary Ligatures (the ``dlig`` tag.) | ||
These may be toggled with ``+`` or ``-``. | ||
.. plot:: | ||
:include-source: | ||
fig = plt.figure(figsize=(7, 3)) | ||
fig.text(0.5, 0.85, 'Ligatures', fontsize=40, horizontalalignment='center') | ||
# Default has Standard Ligatures (liga). | ||
fig.text(0, 0.6, 'Default: fi ffi fl st', fontsize=40) | ||
# Disable Standard Ligatures with -liga. | ||
fig.text(0, 0.35, 'Disabled: fi ffi fl st', fontsize=40, | ||
fontfeatures=['-liga']) | ||
# Enable Discretionary Ligatures with dlig. | ||
fig.text(0, 0.1, 'Discretionary: fi ffi fl st', fontsize=40, | ||
fontfeatures=['dlig']) | ||
Available font feature tags may be found at | ||
https://learn.microsoft.com/en-us/typography/opentype/spec/featurelist |
6 changes: 4 additions & 2 deletionslib/matplotlib/_text_helpers.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletionlib/matplotlib/backends/backend_agg.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletionslib/matplotlib/backends/backend_pdf.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletionlib/matplotlib/backends/backend_ps.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletionlib/matplotlib/font_manager.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
7 changes: 6 additions & 1 deletionlib/matplotlib/ft2font.pyi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletionslib/matplotlib/tests/test_ft2font.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletionslib/matplotlib/text.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletionslib/matplotlib/text.pyi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
9 changes: 5 additions & 4 deletionslib/matplotlib/textpath.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
9 changes: 8 additions & 1 deletionlib/matplotlib/textpath.pyi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletionsrc/ft2font.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletionssrc/ft2font.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
13 changes: 10 additions & 3 deletionssrc/ft2font_wrapper.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.