Commit Graph

6 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
8ce6da114c code cleaning: remove print statement 2025-11-18 09:01:00 +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
43c69240bd Fix word breaking: prevent splitting words with accented characters
Fixed line breaking that would split words like "équivaut" into "é" on one
  line and "quivaut" on the next line, even though they're part of the same word.

  Root cause analysis (from debug logging):
  When text contains accented characters in decomposed form (e + combining
  accent), the system processes them as separate atoms:
    1. "é" is processed as an accent atom, composed, and added to currentLine
    2. "quivaut " is processed as the next ordinary atom
    3. Before adding "quivaut ", checkAndPerformInteratomLineBreak() is called
    4. This function sees that adding "quivaut " would exceed maxWidth
    5. It breaks and flushes the line with "é" at the end
    6. "quivaut " starts on a new line

  Result: "é" appears alone at the end of one line, "quivaut " on the next.

  The fix:
  Modified checkAndPerformInteratomLineBreak() in MTTypesetter.swift to detect
  when we're about to break in the middle of a word.
2025-11-17 10:45:32 +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