Rasterize dvi files without dvipng. #30039
Open
+125
−10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This patch drops the reliance on dvipng to rasterize dvi files prior to inclusion by agg, instead performing the rasterization ourselves (as a consequence, the rasterization output also becomes dependent of the freetype version used). Note that this approach will be needed anyways to support xetex and luatex, as dvipng doesn't support dvi files generated by these engines.
Baseline images change slightly, for the better or the worse. The top-left blue cross text in test_rotation.py ("Myrt0") seems to be better top-aligned against the blue line (the old version overshot a bit); the bounding box of the formulas in test_usetex.py seems a bit worse.
Small API point that needs to be discussed: do we want to keep the old dvipng-based codepath? (likely, at least temporarily) If so, what kind of switch do we want to expose to the end-user? I would suggest already looking forward to the future support for xetex/luatex which would likely be implemented using
rcParams["text.latex.engine"] = {"latex", "xelatex", "lualatex"}
and further add a possible "latex+dvipng" value in there, which would correspond to the old default; "latex" would be the dvipng-less codepath; both "latex" and "latex+dvipng" would behave the same for backends other than agg. (Also note that if we decide later to remove that dvipng codepath, it is easier to deprecate an allowable value from a rcParams entry than to completely deprecate an entry.)I will either implement the switch or strip out the dvipng code, and write the corresponding docs, depending on the decision above.
PR summary
PR checklist