CJK: full-width punctuation renders as annotations, and half-width numbers/words get truncated to "…"
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 74/100
Direzione di ricerca
Start in MarqueeTextView.swift, especially splitTextIntoWords and buildLines, and reproduce the issue with the provided Chinese sample at varying notch widths or font sizes. Check that full-width punctuation is not treated as annotations and that half-width numbers or Latin words are not truncated; verify the rendered line against the expected script.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
In Chinese scripts, full-width punctuation (,。:「」!?()…) is rendered wrong, and half-width numbers or Latin words on the same line can be squeezed into … and disappear. Both come from the same root cause in MarqueeTextView.swift.
Environment
- Textream 1.7.1 (Homebrew cask), macOS 26.6.2, Apple Silicon
- Font: Sans, size LG, overlay: Pinned (notch width 410), mode: Word Tracking, speech locale: zh-TW
Steps to reproduce
- Paste this script:
那一年他 36 歲,搬到新的城市,而且換過三份工作。 - Start the prompter.
Expected: 那一年他 36 歲,搬到新的城市,而且換過三份工作。
Actual: 那一年他 ...歲,搬到新的城市,而且換過三份工作。 The 36 is replaced by an ellipsis, and every full-width punctuation mark is shown italic, dimmed, and preceded by an extra space.
Whether a number disappears depends on how full the line is, so it comes and goes when the notch width or font size changes.
Root cause
1. Full-width punctuation becomes a standalone "annotation" word.
Unicode.Scalar.isCJK does not cover CJK Symbols and Punctuation (U+3000–303F) or Halfwidth and Fullwidth Forms (U+FF00–FFEF). So splitTextIntoWords emits each punctuation mark as its own word, and isAnnotationWord flags it because it has no letters or numbers. It is then rendered with the annotation style (italic, cueUnreadOpacity).
Tokenizer output for the sample (〔〕 = flagged as annotation):
那|一|年|他|36|歲|〔,〕|搬|到|新|的|城|市|〔,〕|而|且|換|過|三|份|工|作|〔。〕
2. buildLines underestimates line width, so SwiftUI truncates a word.
buildLines measures each word with NSString.size(withAttributes:), but each word is rendered as a separate SwiftUI Text(word + " "). For a standalone full-width punctuation mark, the two disagree a lot. Measured on this machine with NSFont.systemFont(ofSize: 20, weight: .semibold):
| Word | NSString width (+ space) | SwiftUI Text width |
Difference |
|---|---|---|---|
CJK character, e.g. 年 |
23.72 | 24.00 | +0.28 |
36 |
29.71 | 30.00 | +0.29 |
, or 。 (standalone) |
14.32 | 25.00 | +10.68 |
| Whole sample line | 523.4 | 561.0 | +37.6 |
When the real width exceeds containerWidth, the HStack compresses its children. Single CJK characters can't shrink, so the only multi-character word on the line (36, or a Latin word like Claude) is truncated to …. I reproduced this outside the app by rendering the same HStack(spacing: 0) of Text(word + " ") views, with .lineLimit(1), at the width buildLines computed. The result matches what the prompter shows: 那一年他 ...歲,…
Suggested fix
- In
splitTextIntoWords, attach punctuation to the preceding CJK character (e.g.歲,) instead of emitting it as its own word. At minimum, add U+3000–303F and U+FF00–FFEF to the CJK handling, so these marks are never treated as annotations. - In
buildLines, measure words the same way they are rendered, or round each word width up (ceil) and keep a small safety margin, so accumulated per-word rounding can't overflow the line. - Optionally, add
.fixedSize()to the wordText, so an overflow wraps to the next line instead of silently hiding script text.
Related: #60, #95 (other Chinese support issues).
- Lingua principale
- Swift
- Stelle
- 4.1k
- Fork
- 285
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di f/textream
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 42/100
Issue simili
-
a:false-positive
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
I maintainer di solito rispondono entro 1 giorno
-
Idle CPU stays at ~8% after the "Text wasn't inserted" card is shown onceForse già presa @nickbecker l’ha presa oggi. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
altic-dev/FluidVoice#1217 ·
I maintainer di solito rispondono entro 1 giorno
-
BrainBar Watcher chart: unavailable-flow tooltip/accessibility drops the health reason for .attention/.stoppedForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
EtanHey/brainlayer#1439 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
alejandrobujan/tendedero#98 ·
I maintainer di solito rispondono entro 2 giorni
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
vorssaint/vorssaint-utils#3368 ·
I maintainer di solito rispondono entro 1 giorno