Skip to content

Commit

Permalink
Partial fix for Matplotlib 3.9's test suite.
Browse files Browse the repository at this point in the history
  • Loading branch information
anntzer committed May 2, 2024
1 parent 4a940ee commit cff22e0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions ext/_mplcairo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1588,10 +1588,12 @@ void GraphicsContextRenderer::draw_text(
next_glyphs_pos = glyphs_pos + cluster.num_glyphs;
for (auto j = glyphs_pos; j < next_glyphs_pos; ++j) {
if (!gac.glyphs[j].index) {
auto missing =
py::cast(s.substr(bytes_pos, cluster.num_bytes))
.attr("encode")("ascii", "namereplace");
warn_on_missing_glyph(missing.cast<std::string>());
auto missing = py::cast(s.substr(bytes_pos, cluster.num_bytes));
warn_on_missing_glyph( // Format forced by test_mathtext_ticks.
"{} ({})"_format(
py::module::import("builtins").attr("ord")(missing),
missing.attr("encode")("ascii", "namereplace").attr("decode")())
.cast<std::string>());
}
}
bytes_pos = next_bytes_pos;
Expand Down
4 changes: 2 additions & 2 deletions ext/_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -903,8 +903,8 @@ void warn_on_missing_glyph(std::string s)
{
PY_CHECK(
PyErr_WarnEx,
nullptr,
"Requested glyph ({}) missing from current font."_format(s)
PyExc_UserWarning,
"Glyph {} missing from current font."_format(s)
.cast<std::string>().c_str(),
1);
}
Expand Down

0 comments on commit cff22e0

Please sign in to comment.