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
feat: accurate Equation
measurements
#1445
Conversation
Deploying with Cloudflare Pages
|
Equation
to match fontSize
settingEquation
measurements
Equation
measurementsEquation
measurements
± Registry diff
📊 PerformanceKeyNote that each bar component rounds up to the nearest 100ms, so each full bar is an overestimate by up to 400ms.
If a row has only one bar instead of four, that means it's not a trio and the bar just shows the total time spent for that example, again rounded up to the nearest 100ms. Data
|
Note on relative units: although I'm not sure if this has any implications to Penrose, but I am erring on the safer side of not providing support for it for now. More experimentation is needed to find out how |
Glancing at the registry diff, what's going on with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me! Thanks so much for doing this deep dive 😃
Description
Resolves #1438, resolves #1448.
Related: #842
For #340, we introduced a way to scale MathJax-generated SVGs such that
Equations
have visually-consistent sizes in a single diagram. However, #1438 points out that this scaling conversion doesn't produce labels of accurate font size. This PR does exact conversion from MathJax SVG units to pixels forwidth
,height
,descent
, andascent
of ourEquation
shape.Implementation strategy and design decisions
The CSS standard defines all the units, which is implemented by the MathJax source code.
When MathJax generates an SVG, the
width
,height
,viewBox
, andvertical-align
is computed in https://github.com/mathjax/MathJax-src/blob/a5ae9485cb7441fdd5ea59645cfbd1c12b7d53e1/ts/output/svg.ts#L239.Our implementation computes the
width
,height
,descent
, andascent
by using these values from above. See inline comments for more details.Examples with steps to reproduce them
https://tex-measure.penrose-72l.pages.dev/try/?gist=5c192c1186607e52d56b86e48ab7c3f5
https://tex-measure.penrose-72l.pages.dev/try/?gist=5e4f9cd917276e11ebaa8e798a4a62c2
Checklist
Open questions
fontSize
ofEquation
, only absolute units are accepted for now. The conversion to relative units such asem
andpt
needs font-specific information, and there's no guarantee thatText
is going to render the same way. It is possible to support them, but this is requires careful work on bothText
andEquation
. Would love some help on supporting them! Given my own time constraints I'm inclined to convert existing relativefontSize
s to absolute units so we can merge this PR.