FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Set mathtext.fontset per element · Issue #17906 · matplotlib/matplotlib · GitHub

Repository navigation

Set mathtext.fontset per element #17906

Closed

Description

How can we set mathtext font without manipulating RC per Text element. Text objects cannot take in this parameter, as apparently the only way to set "mathtext.fontset"="Serif" is to make it global (not per some Text element).

Activity

  1. changed the title [-]How to set mathtex.fontspec per element?[/-] [+]How to set mathtext.fontspec per element?[/+] on Jul 13, 2020
  2. isentropic commented on Jul 13, 2020

    Author

    The only way is to set it globally according to docs

  3. isentropic commented on Jul 13, 2020

    Author

    This does not help a lot too

  4. changed the title [-]How to set mathtext.fontspec per element?[/-] [+]How to set mathtext.fontset per element?[/+] on Jul 13, 2020
  5. timhoffm commented on Jul 13, 2020

    Member

    AFAICS this is a global setting that cannot be modified per Text element. ping @anntzer

  6. isentropic commented on Jul 14, 2020

    Author

    This would be a very useful feature for packages using matplotlib as a backend. For example at JuliaPlots/Plots.jl we have user settable fonts per every plot element, hence mathfont should also change per each element.

  7. anntzer commented on Jul 14, 2020

    Contributor

    I don't think it should be "particularly" hard to add a per-Text property to set this (I guess we can't really reuse FontProperties for that because they are not precise enough for mathtext); as usual someone needs to give it a try :)

  8. added
    🌱 Good first issueOpen a pull request against these issues if there are no active ones!
    Difficulty: Mediumhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issues
    on Jul 14, 2020
  9. timhoffm commented on Jul 14, 2020

    Member

    👉 Things to do:

    • Find the (only) usage of rcParams['mathtext.fontset'] in MathTextParser.parse().
    • Trace the call hirachy back to find out how a Text rendering finally calls parse().
    • Add a parameter to define the font for Text objects.
    • Pass this parameter down the call hirachy so that is can be used in parse()
    • Check that the parameter can be passed from relevant functions such as Axes.title() and Axes.text() (This is likely the case because keyword arguments are passed).
  10. changed the title [-]How to set mathtext.fontset per element?[/-] [+]Set mathtext.fontset per element[/+] on Jul 14, 2020
  11. timhoffm commented on Jul 14, 2020

    Member

    Related: #6518, #7107

  12. diegopetrola commented on Jul 27, 2020

    Contributor

    While trying to solve this I realised that the fontset passed to rcParams is validated and the methods to make this validation are all private to the rcsetup.py and the init from matplotlib.
    I think the fontset used in a Text should have the same validations as if it were an rcParam, but I see no easy way of doing that.

    Edit: well I could just import _validators from rcsetup.py and do the validations myself, it would be 3 lines of code, but I think using a private variable (one that starts with _) outside of its domain would be considered a bad practice, I am not sure.

    If someone has a suggestion or want to discuss any change I made, feel free to contact me.
    I am working on the problem here:
    https://github.com/diegoleal/matplotlib/tree/issue%2317906

  13. timhoffm commented on Jul 27, 2020

    Member

    The topic of validator availability is still an open issue. Historically, validators were only used by the rcParams parser. But I agree that they can be useful in other parts of the library as well. We should solve this on a fundamental level from the library side. This needs careful consideration regarding import order. For now, you may import _validators. As long as the import of _validators is only within the library, it's ok-ish. The important aspect is that it's not public API for users of Matplotlib.

  14. added this to the v3.4.0 milestone on Aug 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Difficulty: Mediumhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issuestopic: text🌱 Good first issueOpen a pull request against these issues if there are no active ones!

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL