Severity: LOW
Status: ✅ FIXED
Files: src/thai.zig, src/grid.zig
When libthai is not installed or available on the host system, szn falls back to its internal rule-based Thai cluster and syllable reflow heuristic in src/grid.zig. While grapheme cluster integrity and MAI HAN AKAT protection were already enforced, two orthographic edge cases remained:
Mai Yamok (ๆ U+0E46) and Paiyannoi (ฯ U+0E2F) with Spaces:
Standard Thai typography and newspaper stylebooks (Royal Institute / Daily News StyleBook) require a space before Mai Yamok (e.g., ต่าง ๆ). During grid resizing, rewrap treated any space adjacent to Thai characters as a valid word boundary (space_wb = j + 1). If the line filled up right after the space, ๆ was placed at column 0 of the new line. In Thai typography, starting a line with ๆ or ฯ is strictly prohibited (ห้ามขึ้นต้นบรรทัดด้วยไม้ยมกหรือไปยาลน้อย).
Thanthakhat / Garan (◌์ U+0E4C) Orphan Coda:
In words ending with a silent letter (e.g., สัตว์, แพทย์, ศุกร์, จันทร์), if the physical line boundary landed right before the silent letter, the silent letter and its Thanthakhat mark wrapped alone to column 0 of the next line (e.g. สัต on line 1, and ว์ on line 2). A consonant marked with Thanthakhat represents the silent coda of a syllable and can never begin a syllable or a line.
src/thai.zig:
cellHasThanthakhat(cell: Cell) bool to identify Thanthakhat (U+0E4C) in comb1/comb2 or as an unattached base cell.cellHasVowelMark(cell: Cell) bool and isThaiVowelMark(cp: u21) bool to identify upper/lower Thai vowel marks.findThaiSyllableStart(cells: []const Cell, pos: usize, min_idx: usize) usize to scan backward from a coda or right-attaching mark to locate the syllable’s initial consonant or leading vowel.cellHasThanthakhat, cellHasVowelMark, and findThaiSyllableStart.src/grid.zig:
rewrap:
thai.isThaiRightAttaching), causing the space scanner to skip it and search for a preceding word boundary.ๆ or ฯ at column 0, rewrap backtracks before the preceding word using findThaiSyllableStart.i would place a silent letter (or double-silent cluster like ทร์) at column 0 of the next line, rewrap backtracks before the syllable start using findThaiSyllableStart."setSize reflow Thai right-attaching mark (ๆ) with space — bug #541""setSize reflow Thai Thanthakhat (์) protection — bug #541"