Skip to content

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

Merged
anntzer merged 1 commit into
matplotlib:mainfrom
oscargus:mathtextbar
Oct 31, 2022
Merged

Fix mathtext rendering of \| and sizing of | and \|#24239
anntzer merged 1 commit into
matplotlib:mainfrom
oscargus:mathtextbar

Conversation

@oscargus

@oscargus oscargus commented Oct 21, 2022

Copy link
Copy Markdown
Member

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

QuLogic commented Oct 21, 2022

Copy link
Copy Markdown
Member

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
Copy Markdown
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

oscargus commented Oct 24, 2022

Copy link
Copy Markdown
Member Author

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

oscargus commented Oct 24, 2022

Copy link
Copy Markdown
Member Author

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

anntzer commented Oct 24, 2022

Copy link
Copy Markdown
Contributor

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

@oscargus

Copy link
Copy Markdown
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
Copy Markdown
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

anntzer commented Oct 29, 2022

Copy link
Copy Markdown
Contributor

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