Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/textkit/src/engines/linebreaker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { AttributedString, Attributes, LayoutOptions } from '../../types';
import { Node } from './types';

const HYPHEN = 0x002d;
// CJK characters: Hiragana, Katakana, CJK Ideographs, CJK punctuation, fullwidth forms
const CJK_RANGE = /[\u3000-\u9fff\uf900-\ufaff\uff00-\uffef]/;
const TOLERANCE_STEPS = 5;
const TOLERANCE_LIMIT = 50;

Expand Down Expand Up @@ -46,7 +48,11 @@ const breakLines = (

line = slice(start, end, attributedString);

line = insertGlyph(line.string.length, HYPHEN, line);
// Skip hyphen insertion for CJK characters — they wrap without hyphens
const charAtBreak = attributedString.string.charAt(end - 1);
if (!CJK_RANGE.test(charAtBreak)) {
line = insertGlyph(line.string.length, HYPHEN, line);
}
} else {
end = node.end;
line = slice(start, end, attributedString);
Expand Down