pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/matplotlib/matplotlib/pull/31434

global-0bd78641c0a1f3e0.css" /> ft2font: Add internal API for accessing font variations by QuLogic · Pull Request #31434 · matplotlib/matplotlib · GitHub
Skip to content

ft2font: Add internal API for accessing font variations#31434

Open
QuLogic wants to merge 1 commit intomatplotlib:text-overhaulfrom
QuLogic:font-variations
Open

ft2font: Add internal API for accessing font variations#31434
QuLogic wants to merge 1 commit intomatplotlib:text-overhaulfrom
QuLogic:font-variations

Conversation

@QuLogic
Copy link
Copy Markdown
Member

@QuLogic QuLogic commented Apr 1, 2026

PR summary

This is internal API for querying font variations and setting them. FreeType sometimes calls them MM (multiple master) vars or variation axes, but I tried to stick to variations/variation axis. For the named styles, FreeType sometimes calls that a named style or a named instance, and I tried to use named style everywhere.

Font variations essentially allow fonts to have multiple styles in one by varying some parameter along an "Axis". For example, one font can contain all weights with a Weight axis ranging from Thin to Extra Bold, or an upright and italic font with a Slant axis for the angle. Some fonts may contain named styles which group some specific settings together under a a name (e.g., Bold may be Weight=700 or whatever the designer decides.)

Current internal API additions are:

  • FT2Font.get_variation_descriptor which returns a list of the variation axes and a list of the named styles.
  • FT2Font.get_default_variation_style which returns the index of the default name style (in the above list.)
  • FT2Font.get_variations which returns the float values for each axis (in the order of the above list.)
  • FT2Font.set_variations which allows setting the float values for each axis as a list, or selecting a named style by index.

This does not contain any public API; for that there are some questions that we might need to think about:

  • Should users select a font (by name or otherwise) and then apply variations with something like Text.set_fontvariations and/or FontProperties.set_variations?
  • Or, should variable fonts match anything within their range?
    • That is, if a variable font has a Weight axis between 100 and 1000, should that font automatically match ("FontName", weight="bold") / ("FontName", weight="regular"), etc.
    • If a variable font has a named style for, e.g., Bold, should that automatically add a name of "FontName Bold" as well (as in ENH: Allow fonts to be addressed by any of their SFNT family names #31183)?

I do not expect this to be ready for 3.11 until we discuss some of these options.

AI Disclosure

None

PR checklist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Waiting for other PR

Development

Successfully merging this pull request may close these issues.

1 participant

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy