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

Feature request: allow mathtext fallback font other than Computer Modern for custom mathtext setup #8619

Closed
@geib7592

Description

@geib7592

Feature request

Feature summary

Allow users to specify a mathtext fallback font when custom mathtext font lacks a needed character.

More detail

Currently, a user can choose a font for the mathtext. For example, to use Open Sans for text and math, you can do:

rcParams['font.sans-serif'] = 'open sans'rcParams['mathtext.fontset'] = 'custom'rcParams['mathtext.it'] = 'sans:italic'

Open Sans has pretty good coverage of the characters needed for plots, including the Greek alphabet, but it's missing, for example, a character that maps to the latex command$\phi$ (it's phi maps to$\varphi$). If you use the above configuration with textbox containing$\phi$, the system falls back to computer modern, in accordance with thefallback_to_cm rc parameter. It would be nice, however, to be able to fall back to a similar font for that character, preferable a sans serif font in a comparable weight.

This is already implemented for the default DejaVu Sans. It falls back to Stix Sans instead of CM to get a more uniform look. (In theDejaVuFonts class, the line

self.cm_fallback = StixSansFonts(*args, **kwargs)

sets this.)

In my example with Open Sans, I can get a better result by changing the line

self.cm_fallback = BakomaFonts(*args, **kwargs)

to

self.cm_fallback = DejaVuSansFonts(*args, **kwargs)

in theUnicodeFonts class. That way, the fallback is a sans-serif font similar to the main font.

It seems like it would be fairly easy to allow users to set the fallback to one of the built-in fonts (cm, dejavuserif, dejavusans, stix, stixsans). It would be nice to also allow custom fallbacks (but then we might need to have a fallback for the fallback in case the custom choice lacks a needed character). In my example, you might want to set the main font in Open Sans, but the fallback to Noto Sans (a very similar Google font with more characters).

There are many high-quality free (and not free) fonts that would benefit from a fallback that's not computer modern. This feature would therefore increase the number of usable custom fontsets.

Implementation questions
I'd be happy to try implementing this myself, but I'm a new contributor, and I'm sure I'd mess some things up. Here are a few questions that come to mind:

  1. Is this feature worth implementing?
  2. It would probably require a change to the rc parameters. Is there a policy in place for doing so?
  3. Like I mentioned above, allowing users to choose from one of the built-in fonts would be pretty straightforward. Is it worth also allowing custom fallbacks?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp