Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitf1b16f2

Browse files
committed
Support {lua,xe}tex as alternative usetex engine.
Currently, this PR is mostly a proof of concept; it only implements thedvi generation and parsing parts, but does not implement rendering inany of the builtin backends, except svg (under rcParams["svg.fonttype"]= "none", the default). However, there is a companion branch on themplcairo repository, also named "luadvi", which implements support.Example (requiring both this PR, and mplcairo installed from its luadvibranch):```import matplotlib as mpl; mpl.use("module://mplcairo.qt")from matplotlib import pyplot as pltplt.rcParams["text.latex.engine"] = "lualatex" # or "xelatex"plt.rcParams["text.latex.preamble"] = ( # {lua,xe}tex can use any font installed on the system, spec'd using its # "normal" name. Try e.g. DejaVu Sans instead. r"\usepackage{fontspec}\setmainfont{TeX Gyre Pagella}")plt.figtext(.5, .5, r"\textrm{gff\textwon}", usetex=True)plt.show()```TODO:- Fix many likely remaining bugs.- Rework font selection in texmanager, which is currently very ad-hoc due to the limited number of fonts supported by latex.- Implement rendering support in the (other) builtin backends. In particular, the Agg (and, if we care, cairo) backend will require significant reworking because dvipng, currently used to rasterize dvi to png, doesn't support luatex-generated dvi; instead we will need to proceed as with the other backends, reading the glyphs one at a time from the dvi file and rasterizing them one at a time to the output buffer. Working on the other backends is not very high on my priority list (as I already have mplcairo as playground...) so it would be nice if others showed some interest for it :-)
1 parentc1dba8e commitf1b16f2

File tree

6 files changed

+254
-86
lines changed

6 files changed

+254
-86
lines changed

‎lib/matplotlib/backends/backend_pdf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -991,10 +991,10 @@ def _embedTeXFont(self, fontinfo):
991991

992992
# Widths
993993
widthsObject=self.reserveObject('font widths')
994-
tfm=fontinfo.dvifont._tfm
994+
whds=fontinfo.dvifont._metrics._whds
995995
# convert from TeX's 12.20 representation to 1/1000 text space units.
996-
widths= [(1000*tfm.width.get(char,0))>>20
997-
forcharinrange(max(tfm.width,default=-1)+1)]
996+
widths= [(1000*whds[char].width)>>20ifcharinwhdselse0
997+
forcharinrange(max(whds,default=-1)+1)]
998998
self.writeObject(widthsObject,widths)
999999

10001000
# Font dictionary

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp