Files
SpotiFLAC-Mobile/lib
zarzetanditzSho3aib 33fe55a8c7 fix(lyrics): read each lyric line in its own direction (#844)
Finish the right-to-left lyrics from PR #844 on the current lyrics code.

A line's direction now follows the Unicode paragraph rule: its first
strong letter decides, so a Latin line with one Arabic word stays left
to right, and digits, punctuation, marks, emoji or a byte order mark
decide nothing. A line without letters (an instrumental "..." or a gap)
takes its neighbour's direction. The scan is a rune loop over sorted
ranges with an ASCII fast path, in lib/utils/text_direction.dart, and
replaces the PR's any-RTL-character regex and its re-export from
player_lyrics.dart.

- The synced view works the directions out once per set of lyrics,
  with its line keys, and lays every row out in its line's direction,
  so the row cache, reveal, scale, backing vocals and duet alignment
  follow it. Mornye's line measurement uses the same directions.
- The word sweep orders a word's runs by the line's direction and
  sweeps each run the way it is laid out, so a Latin word inside an
  Arabic line fills from its left.
- A translation or pronunciation reads in its own direction and stays
  on its line's side, timed or not. Phrase-aligned pronunciation stays
  off for right-to-left lines.
- Plain lyrics keep one text when every line shares a direction and get
  a text a line when they mix; the directions are cached per lyrics.
- The lyric line under the header reads, and slides, in the line's
  direction: a long Arabic line moves right to bring its end in.
- The editor keeps each field's direction in a notifier that changes
  only with the first letter's script, instead of rebuilding the field
  on every keystroke.
- The share card and mini player use the same rule.

In a right-to-left app a Latin line now reads left to right from the
left edge; the repaint test records that.

Co-authored-by: itzSho3aib <mamomema123@gmail.com>
2026-11-15 23:35:34 +07:00
..