Skip to content

[Bug]: Font fallback bugs #32063

Description

@dragoneptech

Bug summary

If the global font size is set with plt.rcParams["font.size"] and the size value >12, the Chinese charaters will show, else the Chinese characteres will disappear.

Code for reproduction

import numpy as np
import matplotlib.pyplot as plt

plt.rcParams["font.family"] = ["Times New Roman", "SimSun"]
plt.rcParams["font.serif"] = ["Times New Roman", "SimSun"]
plt.rcParams["font.sans-serif"] = ["Times New Roman", "SimSun", "Arial", "SimHei"]

plt.rcParams["mathtext.fontset"] = "custom"
plt.rcParams["axes.unicode_minus"] = False
plt.rcParams["font.size"] = 13  # If font size <= 12, the Chinese characters will not show.

x = np.array([1, 2, 3, 4, 5])
y = np.array([1, 4, 9, 16, 25])

plt.plot(x, y)
plt.xlabel('X-axis / X 轴')
plt.ylabel('Y-axis / Y 轴')
plt.title('Font Style Example / 字体样式示例')
plt.show()

Actual outcome

"# plt.rcParams["font.size"] = 13"

Image

"plt.rcParams["font.size"] = 13"
Image

Expected outcome

Font fallback can work correctly. The text containing Chinese characters and Non-Chinese characters can be diplayed with SimSun font and Time New Roman font, respectively.

Additional information

Font fallback is incompatible for SimSun and Times New Roman fonts.

Operating system

Windows

Matplotlib Version

3.11.0

Matplotlib Backend

tkagg

Python version

3.14.6

Jupyter version

No response

Installation

uv

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions