Repository navigation
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
Metadata
Metadata
Assignees
Labels
No labels

Activity
Artoria2e5 commentedon Jan 26, 2024
Got the debug trace here:
out.txt
PingFang is only resolved to HK
So the issue is probably this:
addfontonly adds onepropfor a whole ttc. It should at least return one per unique family name. TheFT2Fontcall upstream already ignores this possibility -- I think in FreeType2 API, the relevant thing is called aface_index.Indeed, PingFang HK works:

ksunden commentedon Jan 26, 2024
Yes, currently we have only limited ttc support that only resolves the first font in a ttc.
See #23293 #3135
QuLogic commentedon Jan 30, 2024
I'll close as a duplicate of #3135.
Artoria2e5 commentedon Jan 31, 2024
Fair enough!