You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Public API to get computed metrics (width/height/depth) without rendering to the DOM #3077
Any app that needs to know how big a LaTeX expression will render — before or without inserting it into the visible page — currently has to call convertLatexToMarkup(), insert the resulting markup into a hidden/off-screen element, force a layout, and read the size back with getBoundingClientRect(). This works, but it costs a synchronous forced reflow per measurement, and it means keeping a hidden DOM mirror whose styling (font, size, weight) has to stay in exact sync with wherever the real content renders.
What I found looking at the source
Internally, MathLive already computes exact width/height/depth for every box using font-metrics tables (src/core/box.ts, getCharacterMetrics, horizontalLayout) — entirely without touching the DOM. That's genuinely the hard part (accurate math typesetting metrics), and it's already solved here. The computed numbers just aren't exposed by any public export — convertLatexToMarkup and friends only return markup, not the dimensions that went into producing it.
that returns the box tree's already-computed dimensions directly, with no DOM node created. Naming/shape totally open to whatever fits MathLive's existing conventions better.
Who would use this
Anyone doing custom layout around math content — canvas/SVG-based renderers, print layout, custom editors — that needs a size before deciding where/how to place the expression, without paying for a DOM round-trip for a number MathLive already calculated internally.
Additional context
Happy to put together a PR if this direction seems reasonable — wanted to check on the API shape first per the contributing guide.
Activity