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

Let TeX handle multiline strings itself.#22360

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
jklymak merged 4 commits intomatplotlib:mainfromanntzer:multilinetex
Mar 29, 2022

Conversation

anntzer
Copy link
Contributor

@anntzeranntzer commentedJan 30, 2022
edited
Loading

PR Summary

Previously, multiline strings were split at\n and passed one at a time to TeX -- likely, this is a remnant of how multiline strings are handled for the non-TeX case, as Matplotlib also renders one line at a time. This series of commits switches things to instead pass entire multiline strings all at once to TeX, which is useful e.g. if a tex font command must apply to arbitrary strings that may contain newlines. Goes on top of#22359.

1st commit: Switch TeX baseline detection to use a dvi special.

Insert a\special at the end of the TeX output and record the baseline
position there. This should be more robust than trying to guess the
format of the dvi preamble, and more importantly this will also allow
detecting the last baseline ofmultiline TeX output, which will then
allow letting TeX handle multiline strings itself (while keeping the
correct alignment).

2nd commit: Let TeX handle newlines itself.

Note that it may be worth passing the baselineskip
(Text.get_linespacing()) as argument to texmanager, but that'll wait
for a bigger refactor... for now, let's stick to the old default of
1.25.

test_metrics_cache changes as the cache hit pattern changed for usetex
strings.


Edit: I suspect that the tests are failing on some builds because the tex cache needs to be invalidated (the minver test run is also the only one that clears the cache first). Will do something about that...

3rd commit: Pick TeX cache name based on entire TeX source.

This allows invalidating the cache when the source generation algorithm
changes.

PR Checklist

Tests and Styling

  • Has pytest style unit tests (andpytest passes).
  • IsFlake 8 compliant (installflake8-docstrings and runflake8 --docstring-convention=all).

Documentation

  • New features are documented, with examples if plot related.
  • New features have an entry indoc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented indoc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs shouldbuild without error).

@anntzer
Copy link
ContributorAuthor

rebased.

@jklymak
Copy link
Member

Is the failed doc build relevant? Moving to draft, feel free to move back when tests pass...

@jklymakjklymak marked this pull request as draftMarch 28, 2022 11:33
Insert a `\special` at the end of the TeX output and record the baselineposition there.  This should be more robust than trying to guess theformat of the dvi preamble, and more importantly this will also allowdetecting the last baseline of *multiline* TeX output, which will thenallow letting TeX handle multiline strings itself (while keeping thecorrect alignment).
Note that it may be worth passing the baselineskip(`Text.get_linespacing()`) as argument to texmanager, but that'll waitfor a bigger refactor... for now, let's stick to the old default of1.25.test_metrics_cache changes as the cache hit pattern changed for usetexstrings.
This allows invalidating the cache when the source generation algorithmchanges.
@anntzer
Copy link
ContributorAuthor

anntzer commentedMar 28, 2022
edited
Loading

It seems spurious, but let's try again...
edit: yup, it works.

@anntzeranntzer marked this pull request as ready for reviewMarch 28, 2022 13:43
@jklymakjklymak merged commit2fe38b5 intomatplotlib:mainMar 29, 2022
@QuLogicQuLogic added this to thev3.6.0 milestoneMar 29, 2022
@anntzeranntzer deleted the multilinetex branchMarch 29, 2022 08:08
timhoffm added a commit that referenced this pull requestOct 2, 2022
Revert#22360: Let TeX handle multiline strings itself
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull requestOct 2, 2022
timhoffm added a commit that referenced this pull requestOct 3, 2022
…047-on-v3.6.xBackport PR#24047 on branch v3.6.x (Revert#22360: Let TeX handle multiline strings itself)
@ksundenksunden mentioned this pull requestFeb 20, 2023
6 tasks
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@QuLogicQuLogicQuLogic approved these changes

@jklymakjklymakjklymak approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
v3.6.0
Development

Successfully merging this pull request may close these issues.

3 participants
@anntzer@jklymak@QuLogic

[8]ページ先頭

©2009-2025 Movatter.jp