Skip to content

Deprecate various vector-backend-specific mathtext helpers. #18002

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 2, 2020

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Jul 21, 2020

A single mathtext "backend" yielding a list of glyphs and rectangles is
enough; renderer-specific logic can be implemented in the renderer
themselves.

(MathtextBackendAgg needs to stay separate because it uses a different
font hinting flag.)

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/next_api_changes/* if API changed in a backward-incompatible way

@anntzer anntzer added this to the v3.4.0 milestone Jul 21, 2020
@anntzer anntzer force-pushed the unmathtext branch 2 times, most recently from 46d9fd6 to ea114bb Compare July 21, 2020 22:18
@@ -2072,6 +2078,7 @@ def draw_mathtext(self, gc, x, y, s, prop, angle):
0.001 * fontsize, 0,
0, 0.001 * fontsize,
ox, oy, Op.concat_matrix)
symbol_name = font.get_glyph_name(font.get_char_index(num))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some fallbacks; do we need to worry about those here:

if font is not None:
gid = font.get_char_index(num)
if gid != 0:
symbol_name = font.get_glyph_name(gid)
if symbol_name is None:
return self._stix_fallback._get_glyph(
fontname, font_class, sym, fontsize, math)

Copy link
Contributor Author

@anntzer anntzer Jul 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because _stix_fallback._get_glyph(...) will return a different font object (for which the glyph exists). This can be checked e.g. with

rcParams["mathtext.fontset"] = "cm"; figtext(.5, .5, "$\\perp$"); savefig("/tmp/out.pdf")

adding a print to check that fallback occurs. (Actually it looks like this should not fallback as there's a \perp sign in cmsy10.ttf? but that's a separate issue.)

A single mathtext "backend" yielding a list of glyphs and rectangles is
enough; renderer-specific logic can be implemented in the renderer
themselves.

(MathtextBackendAgg needs to stay separate because it uses a different
font hinting flag.)
@jkseppan jkseppan merged commit a0b9fe3 into matplotlib:master Aug 2, 2020
@anntzer anntzer deleted the unmathtext branch August 2, 2020 09:06
@anntzer anntzer mentioned this pull request Oct 16, 2020
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants