Skip to content

Commit 8bb74e0

Browse files
committed
Compat in extension module for pre&post-mpl3.11 mathtext parses.
1 parent cf43a5f commit 8bb74e0

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

ext/_mplcairo.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,9 +1477,13 @@ void GraphicsContextRenderer::draw_text(
14771477
// because the symbol may have been synthesized by
14781478
// FT2Font::get_glyph_name for a font without FT_FACE_FLAG_GLYPH_NAMES
14791479
// (e.g. arial.ttf), which FT_Get_Name_Index can't know about.
1480-
auto const& [font, size, codepoint, ox, oy] =
1481-
spec.cast<
1482-
std::tuple<py::object, double, unsigned long, double, double>>();
1480+
// Support both pre and post Matplotlib 3.11 formats.
1481+
auto const& glyph = spec.cast<py::tuple>();
1482+
auto const& font = glyph[0].cast<py::object>();
1483+
auto const& size = glyph[1].cast<double>();
1484+
auto const& codepoint = glyph[2].cast<uint32_t>();
1485+
auto const& ox = glyph[glyph.size() - 2].cast<double>(),
1486+
& oy = glyph[glyph.size() - 1].cast<double>();
14831487
mb.add_glyph(ox, -oy,
14841488
font.attr("fname").cast<std::string>(), size,
14851489
codepoint);

0 commit comments

Comments
 (0)