Skip to content

Conversation

@nguillot
Copy link

@nguillot nguillot commented Dec 9, 2025

Description

This PR fixes multiple rendering issues related to accent placement and spacing in mathematical typesetting, and adds spacing compensation logic to improve alignment across complex atoms (fractions, radicals, scripts). It addresses reported visual issues where combining accents and adjacent complex elements could produce incorrect offsets or uneven spacing. The changes improve baseline alignment, protect against mid-word breaks, and adjust spacing heuristics to reduce visual collisions and better match expected TeX-like layout.

Key changes:

Accent handling

Corrects placement and baseline computation for combining/diacritic accents so they align consistently with the nucleus across fonts and grapheme clusters.
Protects textual/letter sequences from being split mid-word when accented characters are present.

Spacing compensation

Adds compensation logic when placing atoms adjacent to complex displays (fractions, radicals, large operators) so horizontal spacing and baseline alignment remain visually consistent.
Improves width estimation for atoms with scripts (sub/superscripts) to avoid premature line breaks or overflow.

Breaking and wrapping

Tightens number protection rules so numeric tokens (including locale-specific separators) are never split across a break.
Refines look-ahead/penalty decision to avoid operator strandeding and to prefer operator-adjacent breaks.

Typesetter robustness

Fixes edge cases in MTTypesetter where visual x-position tracking could diverge from accumulated text width after adding complex displays.
Adds conservative early-exit and estimation safeguards so common single-line cases are still fast.

Tests and docs

Adds/updates unit tests exercising accented characters, accent+fraction interactions, number protection, and spacing compensation cases.

- Implement LaTeX commands: \vec, \overrightarrow, \overleftarrow, \overleftrightarrow
- Add isStretchy property to MTAccent to distinguish stretchy vs non-stretchy arrows
  - Support display delimiters: \[...\], 1288...1288
  - Support inline delimiters: \(...\), $...$
  - Add buildWithStyle() API to return mathList and detected style
  - Add 18 comprehensive tests for all delimiter types
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.

2 participants