Repository navigation
Description
What happened
On an iPhone, the terminal view draws every Hangul syllable with a visible gap after it, so Korean
text looks spread out and broken into pieces ("자모가 떨어져 보임"). Japanese and Chinese have
the same problem. English is fine. Desktop Chrome on Linux shows the same pane correctly.
The text itself is intact and the grid holds: every | in the test pattern below lines up, and
NFD (decomposed) Hangul and NFD dakuten compose into whole syllables. What's wrong is where each
wide glyph sits in its two-cell slot.
Results per script (iOS 27 simulator, Safari tab, 13px terminal font, pane=w1:p1 on an
isolated herdr session):
| Script | Sample | iOS Safari | Desktop Chrome (Linux) |
|---|---|---|---|
| English | The quick brown fox… |
OK | OK |
| Korean, NFC | 다람쥐 헌 쳇바퀴에…, 값읽궯뷁쀍뚫똠 |
gap after every syllable (28% of the slot) | OK (about 1px) |
| Korean, NFD (U+1100 jamo) | 한글 자모 테스트 |
composes into syllables, same gaps as NFC | OK |
| Korean compatibility jamo | ㄱㄴㄷㅏㅑ |
same gaps | OK |
| Japanese kana and kanji | ひらがなカタカナ漢字日本語です |
same gaps, and drawn in the Korean font (see below) | OK |
| Japanese halfwidth kana | ハンカクカタカナ |
small gap (1.3px) | OK |
| Japanese, NFD dakuten | がぎぐ パピプ |
composes, same gaps | OK |
| Chinese, simplified and traditional | 简体中文测试…, 繁體中文測試… |
gaps (17% of the slot) | OK |
| Mixed | AB가나CDあいEF中文GH |
a wide glyph touches the Latin letter before it and leaves a gap after it | OK |
| Box drawing | ┌──┐│ ━┃╋ |
lines broken, heavy ━┃╋ drawn like -|+ |
also broken, so not iOS-specific and out of scope here |
Why
The terminal uses xterm's DOM renderer. For each cell it sets
letter-spacing = width × cellWidth − measuredGlyphWidth
(DomRendererRowFactory.ts, spacing = width * cellWidth - widthCache.get(chars, …)). The glyph
starts at the left edge of its slot and the spacing all lands after it.
On iOS the cell comes from Menlo (0.602em, 7.83px at 13px), so a wide slot is 1.204em (15.67px).
No font on iOS draws Hangul that wide. Measured in iOS Safari with a canvas at 100px:
| Font | 한 | あ | 漢 | 简 | W |
|---|---|---|---|---|---|
app stack (FONT_STACK) |
0.87 | 0.87 | 0.87 | 1.00 | 0.60 |
| Apple SD Gothic Neo | 0.87 | 0.87 | 0.87 | 1.00 | 0.85 |
| Hiragino Sans | 0.87 | 1.00 | 1.00 | 1.00 | 1.02 |
| PingFang SC | 0.87 | 0.87 | 1.00 | 1.00 | 0.93 |
- Hangul: every iOS font draws it at 0.87em, so each syllable gets 0.335em (4.4px at 13px)
of empty space after it. That gap is what reads as text falling apart. - Japanese: nothing in
FONT_STACKnames a Japanese font, so on this Korean-locale simulator
WebKit falls back to Apple SD Gothic Neo for kana and kanji. They get the same 0.87em width and
Korean glyph shapes. Hiragino Sans would draw them at 1em. - Chinese: PingFang is 1em, so the gap is smaller (2.7px) but still visible.
- Desktop Chrome on Linux: Noto Sans CJK is 1em against a slightly narrower cell, so the gap
is about 1px and nobody sees it.
document.fonts.check() answers true for every family on iOS Safari, including fonts that aren't
installed, so it can't be used to detect which font won.
Possible fixes (not yet evaluated)
- Center wide glyphs in their slot instead of left-aligning them. The DOM renderer has no
option for this. Check whether@xterm/addon-webglor the canvas renderer centers wide glyphs,
or whether a renderer change is needed. - Name per-script fallbacks in
FONT_STACKafter the Latin monospace fonts, for example
"Hiragino Sans"for Japanese and"PingFang SC"for Chinese. That gets kana and kanji to 1em
and the right glyph shapes on Apple devices. It doesn't help Hangul, which stays at 0.87em. - Widen the Hangul glyphs. An
@font-facewithsrc: local("Apple SD Gothic Neo"),
size-adjustand a Hangulunicode-rangewould make them wider, but also taller, so check it
against the line height. - Serve a monospace CJK font that is exactly two cells wide (Custom terminal/chat font, and app-served fonts for phones #204, part 2).
Steps to reproduce
-
Run this in a pane:
test pattern
printf '\033]0;cjk test\007'; clear; cat <<'EOF' |012345678901234567890123456789| EN |The quick brown fox jumps over| KO |한글한글한글한글한글한글한글한| NFC KO |다람쥐 헌 쳇바퀴에 타고파 띄어| NFC KO |값읽궯뷁쀍뚫똠방각하ㄱㄴㄷㅏㅑ| NFC+compat jamo KOd |한글 자모 테스트 | NFD conjoining jamo JA |ひらがなカタカナ漢字日本語です| JA |いろはにほへとちりぬるをわかよ| JAh |ハンカクカタカナ アイウエオ halfwidth | halfwidth kana JAd |がぎぐ パピプ | NFD dakuten ZHs |简体中文测试汉字显示正常吗你好| ZHt |繁體中文測試漢字顯示正常嗎妳好| MIX |AB가나CDあいEF中文GH한ア字IJKL| BOX |┌──┐│한│ア│中│└──┘ ━┃╋ | EOF
The
KOdandJAdrows must be NFD. Generate them with
python3 -c 'import unicodedata;print(unicodedata.normalize("NFD","한글 자모 테스트"))',
because pasting usually turns them back into NFC. -
Open the pane on an iPhone (or the iOS Simulator), Terminal lens.
-
Compare with desktop Chrome.
How often
Every time.
herdr web ui version
0.3.39 (87ba715, main)
How it runs
bun run server (source checkout, isolated test session)
Server PC
Linux x64, herdr 0.9.0
Device and browser
iOS Simulator: iPhone 17 Pro, iOS 27.0 runtime, Safari tab, Korean locale. Not yet checked on a
real iPhone or in the installed app. The fonts are the system ones, so the result should be the
same there.
How the device reaches the server
SSH tunnel
Agent and PC
No agent: a plain shell printing the pattern above, local PC.
Related: #204 (terminal font choice and fonts served by the app; it reports the same narrow-Hangul
gaps on Android).
Activity
devswha commentedon Oct 1, 2026
I tested more scripts with the same setup (iOS 27 simulator Safari against desktop Chrome on Linux, 13px).
e + U+0302 + U+0301)Tiếngshows asTiêng, andắ ằ ẳall show asă. The cell text holds every mark (checked in the DOM), so this is a rendering problem.น้ำ🇰🇷👨👩👧1f1f0 1f1f7 1f468 200d 1f469 200d, and 👧 (U+1F467) is missingThe new iOS-specific items are NFD Vietnamese, Thai SARA AM and emoji overflow. The lost emoji
character happens on every platform and probably needs its own issue once the cause is known.
devswha commentedon Oct 1, 2026
PRs for the parts that can be fixed now:
looks spread apart.
against herdr's own cursor reports on 62 samples; 60 agree). This fixes the 👧 lost from
👨👩👧, emoji overlapping the next letter, and stray characters left after emoji.Not covered by these PRs:
น้ำdotted circle on iPhone┌─┐ ━┃╋(desktop and iPhone)a+ U+FE0F and a lone combining mark at column 0fix(terminal): fit CJK characters and text symbols to their cells on …
fix(terminal): count emoji and sequences in cells as herdr does (#273)
devswha commentedon Oct 1, 2026
#272 and #273 are merged into main and will ship in the next release. I checked them on the iOS 27 simulator, which uses the same WebKit engine and system fonts as a real iPhone, but not on a real iPhone yet. If you have one, a quick look at a Korean, Japanese or emoji line in the terminal after the release would help. This issue stays open for the items not fixed yet: the Thai SARA AM dotted circle, box-drawing lines, and right-to-left and Indic shaping.
devswha commentedon Oct 1, 2026
Checked again on the released build, v0.3.41, against the build before the fix (0.3.39), with the test pattern from this issue: iOS 27 simulator (iPhone 17 Pro, Safari tab, Korean locale), a pane in an isolated herdr session.
AB가나CDあいEF中文GH⏺👨👩👧 🇰🇷 okok, 👧 missingokclear of themEvery row's closing
|lines up in both builds.This was the simulator, which runs the same WebKit and system fonts as an iPhone, not a real phone. If Korean still looks spread apart on a real iPhone running v0.3.40 or later, please reopen with a screenshot.
The items this issue listed as not covered (box-drawing lines, Thai SARA AM, right-to-left and Indic shaping) are now in #289.
fix(terminal): preserve IME input, drafts and attachment readiness (#334