Mathtext rendering fails with Matplotlib 3.11: glyph tuples now contain six fields
還沒有人認領這個 Issue。
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 72/100
研究方向
Start by tracing how mplcairo handles MathTextParser("path").parse(...).glyphs and compare its expected tuples with Matplotlib 3.11's six-field tuples. Use the reproducer to confirm the rendering failure, then check both canvas drawing and MultiPage PDF output. Done means the mathtext annotation renders and multipage saving succeeds with Matplotlib 3.11.
由索引模型根據 Issue 內容生成。
描述
Bug summary
Rendering a figure containing mathtext with mplcairo 0.6.1 and
Matplotlib 3.11.2 fails with a C++ type-casting error. This also
affects saving such figures with mplcairo.multipage.MultiPage.
Reproducer
import matplotlib
matplotlib.use("module://mplcairo.base")
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot([1, 2])
ax.annotate(r"$\sigma_f=1.4\times 10^{-8}$", (1, 1))
fig.canvas.draw()
Actual result
RuntimeError: Unable to cast Python instance of type <class 'tuple'>
to C++ type '?' (#define PYBIND11_DETAILED_ERROR_MESSAGES or
compile in debug mode for details)
Expected result
The figure renders with the mathtext annotation.
Likely cause
Matplotlib 3.11 added a glyph index to each tuple in
MathTextParser("path").parse(...).glyphs. The tuples now contain:
(font, fontsize, character_code, glyph_index, x, y)
The mplcairo renderer appears to cast each tuple to the previous
five-field form. Matplotlib documents the change here:
As a local experiment, adapting the parser result to remove the added
glyph-index field allowed both canvas rendering and multipage PDF
output to complete. This was a compatibility experiment, not a
tested upstream patch.
Environment
Python: 3.15.2
Matplotlib: 3.11.2
mplcairo: 0.6.1
Fedora Linux 45
- 主要語言
- C++
- 星號
- 120
- 分支
- 23
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
matplotlib/mplcairo 的其他 Issue
-
難度 4/5 3-5 天 新手友好度 30/100
matplotlib/mplcairo#55 · 18 則留言 ·
-
workaround for low dpi when rasterizing (pcolormesh saved as pdf)可能重新可做 關聯的 PR 已關閉且未合併。 未關閉
難度 4/5 3-5 天 新手友好度 25/100
matplotlib/mplcairo#19 · 5 則留言 ·
查看 matplotlib/mplcairo 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 74/100
維護者通常 1 天內回覆
-
area:tests kind:test
難度 2/5 1-3 小時 新手友好度 70/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 86/100
維護者通常 1 天內回覆
-
? - Needs Triage bot_watch bug
難度 2/5 1-3 小時 新手友好度 78/100
NVIDIA/cudf-spark-jni#5594 ·
維護者通常 1 天內回覆
-
Branch-master
難度 2/5 1-3 小時 新手友好度 78/100
TrinityCore/TrinityCore#32177 ·
維護者通常 10 天內回覆