Skip to content

Unconfuse fontsize calculation#4696

Open
rambip wants to merge 37 commits intoManimCommunity:mainfrom
rambip:main
Open

Unconfuse fontsize calculation#4696
rambip wants to merge 37 commits intoManimCommunity:mainfrom
rambip:main

Conversation

@rambip
Copy link
Copy Markdown

@rambip rambip commented Apr 16, 2026

Overview: What does this pull request change?

Motivation and Explanation: Why and how do your changes improve the library?

This is my attempt to fix #4690 : clarify the fontsize calculation logic so that future contributors and maintainers can reason about it.

Links to added or changed documentation pages

N/A

Further Information and Comments

Existing tests should already cover this refactor, and I explain my reasoning in the issue. But it might be good to add tests clarifying what "DEFAULT_FONTSIZE_IN_WORLD_SPACE" is: just render a "—" in Text and Latex, and check size in world space. What do you think ?

@uwezi do you think it's clearer now ?

rambip and others added 30 commits April 16, 2026 20:45
Updated text scaling and font size handling in text_mobject.py.
Refactor font size handling in SingleStringMathTex class to use initial font size for calculations.
Updated DEFAULT_FONT_SIZE_IN_WOLRD_SPACE value and corrected its description.
Refactor imports in tex_mobject.py to use wildcard import for constants.
Agent-Logs-Url: https://github.com/rambip/manim/sessions/e8302477-8de0-4944-8d6d-bf2a4da1945f

Co-authored-by: rambip <62420525+rambip@users.noreply.github.com>
Agent-Logs-Url: https://github.com/rambip/manim/sessions/e8302477-8de0-4944-8d6d-bf2a4da1945f

Co-authored-by: rambip <62420525+rambip@users.noreply.github.com>
…ests

Add regression tests for EM dash world-space width in Text and MathTex
Change precision of width assertion for em dash in test.
Update test for em dash width with specific font.
@rambip
Copy link
Copy Markdown
Author

rambip commented Apr 20, 2026

I'm now happy with the implementation. All previous tests pass and I added a few tests to measure the size of the reference EM on the screen. It matches to at least two decimal points.

and I ended up with a naming I'm actually happy with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Font size calculation for text and MathTex is very confusing

2 participants