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

[Doc] Font Types and Font Subsetting #20450

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

Merged
merged 7 commits into from
Jul 13, 2021

Conversation

aitikgupta
Copy link
Contributor

@aitikgupta aitikgupta commented Jun 16, 2021

PR Summary

A new entry to User Guide - Fonts! (modelled after interactive_guide)

All About Matplotlib and Fonts!

This document would contain everything Matplotlib knows about fonts, and is bootstrapped with the different types of fonts and font subsetting with this PR. This guide would especially be useful for issues related to font subsetting. (for eg., scverse/scanpy#1720)

Also the first time we're mentioning anything about 'fonttypes' in docs.

Related issues: #127

PR Checklist

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (run flake8 on changed files to check).
  • New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • Conforms to Matplotlib style conventions (install flake8-docstrings and run flake8 --docstring-convention=all).
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).

@aitikgupta aitikgupta changed the title Document the types of Fonts and Subsetting [Doc] Font Types and Font Subsetting Jun 16, 2021
@aitikgupta
Copy link
Contributor Author

aitikgupta commented Jun 16, 2021

EDIT: Updated the link
Rendered at:https://60897-1385122-gh.circle-artifacts.com/0/doc/build/html/users/fonts.html
(needs proper linking from user's guide)

doc/users/fonts.rst Outdated Show resolved Hide resolved
doc/users/fonts.rst Outdated Show resolved Hide resolved
doc/users/fonts.rst Outdated Show resolved Hide resolved
@jklymak
Copy link
Member

jklymak commented Jun 16, 2021

This seems helpful. Is this where you decided it belongs? Most other font info is in tutorials, and users seems to have become a dumping ground for random bits like this.

I think for some of the more technical details we should link out to more definitive resources rather than become bogged down in rewriting the specs for each type of font.

I think it would be helpful to give some examples of what type of fonts correspond to what type of downloads (briefly). i.e. some of those fonts are always available (Type 1)? Many are often present on systems (TrueType?) or more commonly downloaded. I appreciate this is complicated, and I don't think you need to go into laborious detail, but I think this guide could be more practical for the end user as opposed to developers.

@jkseppan
Copy link
Member

I think it would be helpful to give some examples of what type of fonts
correspond to what type of downloads (briefly). i.e. some of those
fonts are always available (Type 1)?

Right, so there is one more kind of font that is always available
without downloading but is of limited use: PostScript interpreters and
PDF consumer applications must have a set of predefined core fonts
available. Matplotlib calls them "AFM fonts" which is a bit of a
misnomer, since AFM is a format for font metrics. The reason is that
Matplotlib distributes only the metrics needed for rendering these
fonts, and the viewer application supplies the glyph definitions.

I believe this applies to the 14 PDF core fonts but am not sure what the
PS backend does. It seems that recent versions have many more built-in
fonts:

https://en.wikipedia.org/wiki/PostScript_fonts#Core_Font_Set

The downside of using "AFM fonts" is that they cannot be rendered in
other backends.

I believe Type 1 fonts mainly enter the system via usetex/dviread, but
you could probably specify a pfa file in plotting commands and it would
work.

Many are often present on
systems (TrueType?) or more commonly downloaded.

Also present on the system are the old MacOS resource-fork fonts and the
newer OpenType fonts, which are basically TrueType with extensions. I
don't think Matplotlib supports either.

A related question that I don't immediately know the answer to is how
the search path for fonts is specified and which operating-system
facilities are used for font lookup.

@jklymak jklymak marked this pull request as draft June 17, 2021 14:47
@QuLogic
Copy link
Member

QuLogic commented Jun 18, 2021

The reason is that
Matplotlib distributes only the metrics needed for rendering these
fonts, and the viewer application supplies the glyph definitions.

I believe this applies to the 14 PDF core fonts but am not sure what the
PS backend does.

It's still recommended to embed some version of the core fonts if you're using them, and I believe we do. That's toggled by the pdf.use14corefonts rcParam:

# Add "pdf.use14corefonts: True" in your configuration file to use only
# the 14 PDF core fonts. These fonts do not need to be embedded; every
# PDF viewing application is required to have them. This results in very
# light PDF files you can use directly in LaTeX or ConTeXt documents
# generated with pdfTeX, without any conversion.

PS doesn't have such a flag, so I'm not sure which way it falls.

@QuLogic
Copy link
Member

QuLogic commented Jun 18, 2021

Ah, for PostScript, non-embedding might be triggered by ps.useafm.

@aitikgupta aitikgupta marked this pull request as ready for review June 19, 2021 18:52
@aitikgupta
Copy link
Contributor Author

This seems helpful. Is this where you decided it belongs?

Yeah, @tacaswell pointed out we could model it after this user guide.

And I think it's at the right place, since all other information around fonts is more on the technical side: "how to use/modify this font with Matplotlib?" vs "okay what does Matplotlib has to do with fonts at all?"

doc/users/fonts.rst Outdated Show resolved Hide resolved
doc/users/fonts.rst Outdated Show resolved Hide resolved
doc/users/fonts.rst Show resolved Hide resolved
Copy link
Member

@jklymak jklymak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks promising. Some in-line comments.

If I was a new user I'd be pretty frustrated by this not telling me how to actually change my font, which is all anyone really wants to know. The context is very useful when things go wrong.

doc/users/fonts.rst Outdated Show resolved Hide resolved
doc/users/fonts.rst Outdated Show resolved Hide resolved
doc/users/fonts.rst Outdated Show resolved Hide resolved
doc/users/fonts.rst Outdated Show resolved Hide resolved
doc/users/fonts.rst Outdated Show resolved Hide resolved
doc/users/fonts.rst Outdated Show resolved Hide resolved
doc/users/fonts.rst Outdated Show resolved Hide resolved
@tacaswell tacaswell added this to the v3.5.0 milestone Jun 29, 2021
Co-authored-by: Jody Klymak <jklymak@gmail.com>
@jkseppan
Copy link
Member

As discussed on the call, it is easy to find more things to add, but this definitely passes the bar of "is it better than before?".

@jkseppan jkseppan merged commit e18701d into matplotlib:master Jul 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.