FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[Bug]: FontManager doesn't get pinging.ttc · Issue #27705 · matplotlib/matplotlib · GitHub

Repository navigation

[Bug]: FontManager doesn't get pinging.ttc  #27705

Closed as duplicate
Closed as duplicate

Description

Bug summary

/System/Library/Fonts/PingFang.ttc is the macOS default Chinese font. The file is a collection of three family names representing three regional glyph variants, PingFang SC, PingFang HK, and PingFang TC. FontManager doesn't seem to be able to find the SC family inside; I haven't tried the others yet.

(Manually constructing a fontProperties works, as demonstrated in #20251 (comment). However, it's not a solution for well-encapsulated code from other people.)

Code for reproduction

import matplotlib
import matplotlib.pyplot as plt
matplotlib.rcParams['font.family'] = ['Ubuntu', 'PingFang SC', 'sans-serif']
plt.title('你好世界world')
plt.savefig("test.png")

Actual outcome

indfont: Font family 'PingFang SC' not found.
findfont: Font family 'PingFang SC' not found.
findfont: Font family 'PingFang SC' not found.
findfont: Font family 'PingFang SC' not found.
findfont: Font family 'PingFang SC' not found.
findfont: Font family 'PingFang SC' not found.
findfont: Font family 'PingFang SC' not found.
findfont: Font family 'PingFang SC' not found.
findfont: Font family 'PingFang SC' not found.
/private/tmp/1.py:5: UserWarning: Glyph 20320 (\N{CJK UNIFIED IDEOGRAPH-4F60}) missing from current font.
  plt.savefig("test.png")
/private/tmp/1.py:5: UserWarning: Glyph 22909 (\N{CJK UNIFIED IDEOGRAPH-597D}) missing from current font.
  plt.savefig("test.png")
/private/tmp/1.py:5: UserWarning: Glyph 19990 (\N{CJK UNIFIED IDEOGRAPH-4E16}) missing from current font.
  plt.savefig("test.png")
/private/tmp/1.py:5: UserWarning: Glyph 30028 (\N{CJK UNIFIED IDEOGRAPH-754C}) missing from current font.
  plt.savefig("test.png")
findfont: Font family 'PingFang SC' not found.
findfont: Font family 'PingFang SC' not found.
findfont: Font family 'PingFang SC' not found.
findfont: Font family 'PingFang SC' not found.
findfont: Font family 'PingFang SC' not found.
findfont: Font family 'PingFang SC' not found.
findfont: Font family 'PingFang SC' not found.
findfont: Font family 'PingFang SC' not found.
findfont: Font family 'PingFang SC' not found.
findfont: Font family 'PingFang SC' not found.
findfont: Font family 'PingFang SC' not found.
findfont: Font family 'PingFang SC' not found.
findfont: Font family 'PingFang SC' not found.

Expected outcome

The text should not be thin rectangles.

Additional information

No response

Operating system

macOS

Matplotlib Version

3.8.2

Matplotlib Backend

MacOSX

Python version

Python 3.11.6

Jupyter version

No response

Installation

pip

Activity

  1. Artoria2e5 commented on Jan 26, 2024

    Author

    Got the debug trace here:
    out.txt

    PingFang is only resolved to HK

    DEBUG:matplotlib.font_manager:findfont: score(FontEntry(fname='/System/Library/Fonts/PingFang.ttc', name='PingFang HK', style='normal', variant='normal', weight=400, stretch='normal', size='scalable')) = 10.05
    

    So the issue is probably this: addfont only adds one prop for a whole ttc. It should at least return one per unique family name. The FT2Font call upstream already ignores this possibility -- I think in FreeType2 API, the relevant thing is called a face_index.


    Indeed, PingFang HK works:

  2. ksunden commented on Jan 26, 2024

    Member

    Yes, currently we have only limited ttc support that only resolves the first font in a ttc.

    See #23293 #3135

  3. QuLogic commented on Jan 30, 2024

    Member

    I'll close as a duplicate of #3135.

  4. Artoria2e5 commented on Jan 31, 2024

    Author

    Fair enough!

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL