Skip to content

Fix mathtext rendering of \| and sizing of | and \| #24239

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 1 commit into from
Oct 31, 2022

Conversation

oscargus
Copy link
Member

@oscargus oscargus commented Oct 21, 2022

PR Summary

Closes #23250

(Implements the less controversial part of #23685)

PR Checklist

Tests and Styling

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • New features are documented, with examples if plot related.
  • 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).
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).

@tacaswell tacaswell added this to the v3.7.0 milestone Oct 21, 2022
@QuLogic
Copy link
Member

QuLogic commented Oct 21, 2022

Since we have to update the test image, maybe we can drop the extra \Vert and \vert at the end? At least, I think those are redundant with the first two.

@oscargus
Copy link
Member Author

I think the idea is to test \left and \right in combination with these. However, it doesn't really make sense for a single letter. I'll update the first to consider a fraction instead (to clearly illustrate a bug in | not being resized).

@oscargus
Copy link
Member Author

oscargus commented Oct 24, 2022

The new test images illustrates some of the issues, but others are missed. So the question is if we should also add tests for a single letter with \left/\right etc? For cm the bars are adjusted down in size for a.

Maybe @anntzer can weigh in on relevant test cases?

@oscargus
Copy link
Member Author

oscargus commented Oct 24, 2022

It seems like getting rid of the following line sorts out the sizing, but I have not checked what else it breaks...

if state.font != 0:

@anntzer
Copy link
Contributor

anntzer commented Oct 24, 2022

I'll try to have a look, but can't do it right now.

@oscargus
Copy link
Member Author

Figured out a way to get the vertical bar size correct. #23250 (comment)

Added a second commit with that change so that one can see the differences. The rationale is to scale if there are no alternatives (or rather only a single alternative).

(Make sure to squash the commits.)

@oscargus oscargus changed the title Fix mathtext rendering of \| Fix mathtext rendering of \| and sizing of | and \| Oct 24, 2022
@oscargus
Copy link
Member Author

The drawback of the current approach of getting the size right is that the font size is changed, so wider bars, but probably still better than having too short ones...

@anntzer
Copy link
Contributor

anntzer commented Oct 29, 2022

Looks good to me; just need a squash.

@anntzer anntzer merged commit ea98aec into matplotlib:main Oct 31, 2022
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.

[Bug]: Incorrect mathtext rendering of r"$\|$" with default (dejavu) math fontfamily
4 participants