Skip to content

Light font variants cannot be accessed by common name #4822

Closed

Description

@EdwinChan

The following Ubuntu fonts are installed on my system:

/home/edwin/.fonts/Ubuntu-LI.ttf: Ubuntu,Ubuntu Light:style=Light Italic,Italic
/home/edwin/.fonts/Ubuntu-L.ttf: Ubuntu,Ubuntu Light:style=Light,Regular
/home/edwin/.fonts/Ubuntu-M.ttf: Ubuntu,Ubuntu Light:style=Medium,Bold
/home/edwin/.fonts/Ubuntu-BI.ttf: Ubuntu:style=Bold Italic
/home/edwin/.fonts/Ubuntu-RI.ttf: Ubuntu:style=Italic
/home/edwin/.fonts/Ubuntu-R.ttf: Ubuntu:style=Regular
/home/edwin/.fonts/Ubuntu-MI.ttf: Ubuntu,Ubuntu Light:style=Medium Italic,Bold Italic
/home/edwin/.fonts/Ubuntu-B.ttf: Ubuntu:style=Bold

Ubuntu Light is shown with two family names: Ubuntu and Ubuntu Light. In XeTeX I can select the font directly by naming Ubuntu Light, but I cannot do the same in matplotlib:

matplotlib.rcParams['font.family'] = 'Ubuntu Light'

Instead, I must use a more obscure (albeit more technically correct) method:

matplotlib.rcParams['font.family'] = 'Ubuntu'
matplotlib.rcParams['font.weight'] = 200

It would be convenient if Ubuntu Light could be addressed directly by its 'common' name.

Activity

  1. WeatherGod commented on Jul 29, 2015

    @WeatherGod
    Member

    It might be that you need to clear your matplotlib font cache.

    On Wed, Jul 29, 2015 at 4:05 PM, Edwin Chan [email protected]
    wrote:

    The following Ubuntu fonts are installed on my system:

    /home/edwin/.fonts/Ubuntu-LI.ttf: Ubuntu,Ubuntu Light:style=Light Italic,Italic
    /home/edwin/.fonts/Ubuntu-L.ttf: Ubuntu,Ubuntu Light:style=Light,Regular
    /home/edwin/.fonts/Ubuntu-M.ttf: Ubuntu,Ubuntu Light:style=Medium,Bold
    /home/edwin/.fonts/Ubuntu-BI.ttf: Ubuntu:style=Bold Italic
    /home/edwin/.fonts/Ubuntu-RI.ttf: Ubuntu:style=Italic
    /home/edwin/.fonts/Ubuntu-R.ttf: Ubuntu:style=Regular
    /home/edwin/.fonts/Ubuntu-MI.ttf: Ubuntu,Ubuntu Light:style=Medium Italic,Bold Italic
    /home/edwin/.fonts/Ubuntu-B.ttf: Ubuntu:style=Bold

    Ubuntu Light is shown with two family names: Ubuntu and Ubuntu Light. In
    XeTeX I can select the font directly by naming 'Ubuntu Light', but I cannot
    do the same in matplotlib:

    matplotlib.rcParams['font.family'] = 'Ubuntu Light'

    Instead, I must use a more obscure (albeit more technically correct)
    method:

    matplotlib.rcParams['font.family'] = 'Ubuntu'
    matplotlib.rcParams['font.weight'] = 200

    It would be convenient if Ubuntu Light could be addressed directly by its
    'common' name.

    —
    Reply to this email directly or view it on GitHub
    #4822.

  2. EdwinChan commented on Jul 29, 2015

    @EdwinChan
    Author

    @WeatherGod That was the first thing I tried; before doing that, I couldn't even load the plain Ubuntu font.

  3. WeatherGod commented on Aug 7, 2015

    @WeatherGod
    Member

    I am wondering if this is addressed by #4689

    On Wed, Jul 29, 2015 at 6:05 PM, Edwin Chan [email protected]
    wrote:

    @WeatherGod https://github.com/WeatherGod That was the first thing I
    tried; before doing that, I couldn't even load the plain Ubuntu font.

    —
    Reply to this email directly or view it on GitHub
    #4822 (comment)
    .

  4. added this to the milestone on Aug 14, 2015
  5. EdwinChan commented on Aug 14, 2015

    @EdwinChan
    Author

    @WeatherGod Apparently not, according to testing I did with the commit. I'm not an expert in the code, so I'm just reporting my observations below and making educated guesses.

    The patch you mentioned seems to be about font family aliasing. The font Ubuntu-L.ttf is only known to matplotlib as Ubuntu (this being, for example, the value of family2 in FontManager.score_family()), not Ubuntu Light, so the issue of aliasing doesn't apply here.

    The two relevant parameters considered by the scoring algorithm in this case is family and weight. If I just say

    matplotlib.rcParams['font.family'] = 'Ubuntu Light'
    

    the algorithm tries to find a font called Ubuntu Light at 400 weight. The font VeraSe.ttf has name Bitstream Vera Serif and weight 400, while the font Ubuntu-L.ttf has name Ubuntu and weight 200; as a result, and somewhat illogically, the algorithm finds a better match in the first font. But since the score is 10 because of a mismatch in family name, the algorithm gives up anyway and falls back to the default font, which is Bitstream Vera Sans.

  6. QuLogic commented on May 15, 2017

    @QuLogic
    Member

    Might be related to #8551 or #8587.

  7. modified the milestones: , on Oct 3, 2017
  8. anntzer commented on Jan 14, 2018

    @anntzer
    Contributor

    It is indeed similar to the font weight retrieval issue: a ttf file can have its name stored in a bunch of different places and we currently only check for one of them (https://cgit.freedesktop.org/fontconfig/tree/src/fcfreetype.c#n1368 for all places where fontconfig looks).

    In the specific case of Ubuntu-L, "Ubuntu" is the TT_NAME_ID_FONT_FAMILY whereas "Ubuntu Light" is the TT_NAME_ID_TYPOGRAPHIC_FAMILY.

    Fixing this will require either depending on fontconfig or extracting all the names ourselves, which is unlikely to happen before 2.2...

  9. modified the milestones: , on Jan 14, 2018
  10. modified the milestones: v3.0, v3.1 on Aug 11, 2018
  11. removed this from the v3.1.0 milestone on Feb 25, 2019
  12. 16 remaining items

  13. github-actions commented on May 1, 2024

    @github-actions

    This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

  14. liuzhenqi77 commented on May 1, 2024

    @liuzhenqi77

    Guess still persists?

  15. added
    keepItems to be ignored by the “Stale” Github Action
    and removed
    status: inactiveMarked by the “Stale” Github Action
    on May 1, 2024
  16. anntzer commented on May 1, 2024

    @anntzer
    Contributor

    I think this is fairly actionable and self-contained, so labeling as good first issue, although fixing this will require being able to read some C and learning about font metadata (I can't provide any help on that), thus medium difficulty. The fixes are

    • Port fontconfig's font family name extractor to python and make (a variant of) ttfFontProperty report all family names for a font, so that we can record each of them in the json fontlist.
    • Port fontconfig's stretch (weight) detector to python and use it similarly to what I did for the weights.
  17. added
    Difficulty: Mediumhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issues
    🌱 Good first issueOpen a pull request against these issues if there are no active ones!
    on May 1, 2024
  18. github-actions commented on May 1, 2024

    @github-actions

    Good first issue - notes for new contributors

    This issue is suited to new contributors because it does not require understanding of the
    Matplotlib internals. To get started, please see our contributing
    guide
    .

    We do not assign issues. Check the Development section in the sidebar for linked pull
    requests (PRs). If there are none, feel free to start working on it. If there is an open PR, please
    collaborate on the work by reviewing it rather than duplicating it in a competing PR.

    If something is unclear, please reach out on any of our communication
    channels
    .

  19. QuLogic commented on Apr 11, 2026

    @QuLogic
    Member

    This was fixed by #31183.

  20. removed
    keepItems to be ignored by the “Stale” Github Action
    on Apr 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Difficulty: Mediumhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issuestopic: text/fonts🌱 Good first issueOpen a pull request against these issues if there are no active ones!

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions