Fix/accent support and spacing compensation #57
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.