Mathtext rendering fails with Matplotlib 3.11: glyph tuples now contain six fields
还没有人认领这个 Issue。
评估
调研方向
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 小时 新手友好度 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 天内回复
-
难度 1/5 1 小时以内 新手友好度 82/100
mw00/project-maya#1499 ·
维护者通常 2 天内回复
-
bug
难度 1/5 1 小时以内 新手友好度 88/100
维护者通常 1 天内回复