Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 349f867

Browse filesBrowse files
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
Copy full SHA for 349f867

File tree

Expand file treeCollapse file tree

3 files changed

+175
-92
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+175
-92
lines changed
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
``MathtextBackend``, ``MathtextBackendAgg``, ``MathtextBackendPath``, ``MathTextWarning``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
... are deprecated with no replacement.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.