Commit 349f867
committed
Replace MathtextBackend mechanism.
The MathtextBackend ("MB") mechanism was previously used to let actual
backends customize how they received mathtext results -- either as lists
of glyphs and rectangles (for vector backends: MathtextBackendPath),
or a bitmap (for raster backends: MathtextBackendAgg); in both cases,
metrics are also provided. MBs also controlled font hinting. Note that
the MB mechanism was not publically user-extendable (this would require
touching the private MathTextParser._backend_mapping dict), so third
parties could not meaningfully provide their own backends.
MBs were attached to _mathtext.Fonts objects, which were central to
the "shipping" stage of the parse (ship(), which converts the nested
parse tree created by pyparsing into flat calls to render_glyph and
render_rect_filled). This led to a slightly curious API, where
the old MathtextBackendAgg.get_results() (for example) calls
`_mathtext.ship(0, 0, box)` and this somehow magically mutates self --
this is because self is indirectly attached to sub-elements of box.
This PR changes the implementation to instead detach output logic
from Fonts (which become restricted to providing glyph metrics and
related info), and makes ship() instead return a simple Output object
(lists of glyphs and rects) which is itself able either to convert to
a VectorParse or a RasterParse -- namedtuples that are backcompatible
with the tuples previously returned by MathTextParser.parse(). (While
technically these are "new" classes in the API, they are simply there to
(slightly) better document the return value of MathtextBackend.parse().)
In summary, this patch
- removes the non-extensible MB system,
- detaches output logic from Fonts objects, thus avoiding "action at
distance" where `ship(0, 0, box)` would mutate the calling MB,
- (weakly) documents the return value of MathtextBackend.parse().
Unrelatedly, also deprecate the unused MathTextWarning.1 parent 69cf385 commit 349f867
File tree
3 files changed
+175
-92
lines changed- doc/api/next_api_changes/deprecations
- lib/matplotlib
3 files changed
+175
-92
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
0 commit comments