diff options
author | bptato <nincsnevem662@gmail.com> | 2022-12-19 23:36:16 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2022-12-19 23:36:16 +0100 |
commit | 91d18d27e4eeebb5aa685b18b28130f3f1b4f513 (patch) | |
tree | 1bc2e19608b576582bb1edc3f0b18aed0eef477c /src/layout | |
parent | ea9df035a294bf1cfa715c140d0d22aa018e262e (diff) | |
download | chawan-91d18d27e4eeebb5aa685b18b28130f3f1b4f513.tar.gz |
Add unicode normalization, etc
Diffstat (limited to 'src/layout')
-rw-r--r-- | src/layout/engine.nim | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/layout/engine.nim b/src/layout/engine.nim index fbee9f6f..4b8e4784 100644 --- a/src/layout/engine.nim +++ b/src/layout/engine.nim @@ -258,6 +258,7 @@ proc addAtom(ictx: InlineContext, atom: InlineAtom, maxwidth: int, pcomputed, co proc addWord(state: var InlineState) = if state.word.str != "": var word = state.word + word.str.mnormalize() #TODO this may break on EOL. word.height = state.ictx.cellheight word.baseline = word.height state.ictx.addAtom(word, state.maxwidth, state.computed, state.computed) @@ -273,16 +274,21 @@ proc checkWrap(state: var InlineState, r: Rune) = return let shift = state.ictx.computeShift(state.computed) case state.computed{"word-break"} + of WORD_BREAK_NORMAL: + if r.width() == 2: # break cjk + if state.ictx.currentLine.width + state.word.width + shift + r.width() * state.ictx.cellwidth > state.maxwidth: + state.addWord() + state.ictx.finishLine(state.computed, state.maxwidth) + state.ictx.whitespacenum = 0 of WORD_BREAK_BREAK_ALL: if state.ictx.currentLine.width + state.word.width + shift + r.width() * state.ictx.cellwidth > state.maxwidth: state.addWord() - state.ictx.finishLine(state.computed, state.maxwidth, false) + state.ictx.finishLine(state.computed, state.maxwidth) state.ictx.whitespacenum = 0 of WORD_BREAK_KEEP_ALL: if state.ictx.currentLine.width + state.word.width + shift + r.width() * state.ictx.cellwidth > state.maxwidth: - state.ictx.finishLine(state.computed, state.maxwidth, false) + state.ictx.finishLine(state.computed, state.maxwidth) state.ictx.whitespacenum = 0 - else: discard proc processWhitespace(state: var InlineState, c: char) = state.addWord() |