-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Prepare for MetaFont/PK font support. #30514
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
base: main
Are you sure you want to change the base?
Conversation
3fee17f
to
76d704f
Compare
lib/matplotlib/dviread.py
Outdated
# PK fonts have no encoding information; report glyphs as ASCII but | ||
# with a "?" to indicate that this is just a guess. | ||
return (f"{chr(self.glyph)}?" if chr(self.glyph).isprintable() else | ||
"??") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we fall back to something like f'pk{self.glyph:x}'
so that they are all unique? (the pk
prefix is something like the uni
prefix on Unicode-encoded glyphs)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, went for a variant.
lib/matplotlib/dviread.py
Outdated
try: | ||
psfont = PsfontsMap(find_tex_file("pdftex.map"))[self.texname] | ||
except LookupError as exc: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume it would never had generated a LookupError
anyway, but the PsfontsMap
constructor seems like a lot to put in this try
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, took it out. (Also removed an unrelated and now unused PsfontsMap call.)
TeX MetaFont (.mf) fonts (e.g., from `\usepackage{concmath}`) need to be converted to raster (.pk) fonts before usage. In dvipng or pdftex this is done by invoking mktexpk via kpsewhich. This patch ensures that our calls to kpsewhich likewise also generate and finds the raster files (in Matplotlib's own temporary cache) when needed. The resolution (600dpi) is the documented default (see e.g. the -D option in `man kpsewhich`). Note that this is only a preliminary step towards full MF/PK font support, which would also require parsing the PK file and embedding the glyphs into our final output.
TeX MetaFont (.mf) fonts (e.g., from
\usepackage{concmath}
) need to be converted to raster (.pk) fonts before usage. In dvipng or pdftex this is done by invoking mktexpk via kpsewhich.This patch ensures that our calls to kpsewhich likewise also generate and finds the raster files (in Matplotlib's own temporary cache) when needed. The resolution (600dpi) is the documented default (see e.g. the -D option in
man kpsewhich
). Note that this is only a preliminary step towards full MF/PK font support, which would also require parsing the PK file (which I have implemented elsewhere) and embedding the glyphs into our final output (for which I have a preliminary version in mplcairo).Work towards fixing #20469.
PR summary
PR checklist