Commit Graph

10 Commits

Author SHA1 Message Date
Nicolas Guillot
9da5aba6b2 multiline fix with square root on second line 2025-11-21 15:49:27 +01:00
Nicolas Guillot
3aa6c6c98b Fix line width calculation for expressions with superscripts/subscripts
The typesetter was incorrectly measuring line width when expressions contained
  superscripts or subscripts (e.g., b²). After rendering a superscript, the line
  is split into multiple display segments, but the width checking code was only
  measuring the current segment, not the total visual line width.

  Key changes:
  - Use currentPosition.x to track actual horizontal position across all segments
  - Calculate visualLineWidth = currentPosition.x + currentSegmentWidth
  - Pass remainingWidth (maxWidth - currentPosition.x) to findBestBreakPoint
  - Apply fix to both interatom breaking and inline text breaking

  This fixes truncation issues where content like "Δ=b²-4ac avec a=1..." was
  being clipped instead of wrapped to a new line.

  Before: Each segment checked in isolation → segments appeared to fit individually
          but total visual width exceeded maxWidth → content truncated/clipped

  After:  Total visual width tracked correctly → line breaking triggered when
          actual visual width exceeds maxWidth → content wraps properly
2025-11-17 17:51:30 +01:00
Nicolas Guillot
cb890fb787 Fix assert failures for unhandled atom types in inter-element spacing
Replace fatal asserts with explicit handling for all MTMathAtomType cases
  in getInterElementSpaceArrayIndexForType(). Previously, unhandled types
  (accent, number, variable, unaryOperator, underline, overline, boundary,
  space, style, table) would trigger assert failures and return Int.max,
  causing array out-of-bounds crashes.
2025-11-17 09:37:59 +01:00
Nicolas Guillot
15269e87e5 Fix large operator positioning causing incorrect atom ordering
When rendering large operators (e.g., sum, integral) with scripts in text
  mode, the operator glyph was incorrectly positioned after its subscripts
  and superscripts instead of before them. This caused expressions like
  \sum_{i=1}^{n} i = \frac{n(n+1)}{2} to render with the equals sign
  appearing visually misplaced.

  Root cause:
  The line-breaking refactoring introduced double-positioning of large
  operators. makeLargeOp() internally sets the operator position, advances
  currentPosition.x, and adds script displays. However, the calling code
  then overwrote the position and advanced currentPosition.x again, causing:
  - Double-advancement leading to incorrect width calculations
  - Scripts positioned before the operator instead of after

  Solution:
  Save and restore typesetter state before/after line break dimension checks,
  then call makeLargeOp() once at the correct position after handling line
  breaks and inter-element spacing.
2025-11-14 10:32:10 +01:00
Nicolas Guillot
ca0e514505 [multi line display] Fix line wrapping to respect width constraints and prevent text truncation 2025-10-27 13:33:29 +01:00
Nicolas Guillot
c7198ad9af [UI] add line wrapping functionality 2025-10-02 16:42:31 +02:00
Michael Griebling
07b110d07f Update internal changes. 2024-12-15 12:21:08 -05:00
Michael Griebling
f23a5b9fb5 Updated comments and minor fixes. 2023-01-20 10:54:45 -05:00
Michael Griebling
deb723691c Fix crash on displayList. 2023-01-18 16:35:19 -05:00
Michael Griebling
c129258845 Renamed the package. 2023-01-18 11:42:38 -05:00