diff options
-rw-r--r-- | src/layout/renderdocument.nim | 7 | ||||
-rw-r--r-- | test/layout/overlapping-double-width-chars.color.expected | 2 | ||||
-rw-r--r-- | test/layout/overlapping-double-width-chars.html | 7 |
3 files changed, 15 insertions, 1 deletions
diff --git a/src/layout/renderdocument.nim b/src/layout/renderdocument.nim index e62455e4..c6277646 100644 --- a/src/layout/renderdocument.nim +++ b/src/layout/renderdocument.nim @@ -101,7 +101,7 @@ proc setText(grid: var FlexibleGrid; linestr: string; x, y: int; format: Format; grid[y].str &= ' '.repeat(padwidth) grid[y].str &= linestr - let linestrwidth = linestr.twidth(x) + var linestrwidth = linestr.twidth(x) i = 0 var nx = x # last x of new string @@ -109,6 +109,11 @@ proc setText(grid: var FlexibleGrid; linestr: string; x, y: int; format: Format; fastRuneAt(ostr, i, r) nx += r.twidth(nx) + while x + linestrwidth < nx: + # we ate half of a double width char; pad it out with spaces. + grid[y].str &= ' ' + inc linestrwidth + if i < ostr.len: grid[y].str &= ostr.substr(i) diff --git a/test/layout/overlapping-double-width-chars.color.expected b/test/layout/overlapping-double-width-chars.color.expected new file mode 100644 index 00000000..3d30b50f --- /dev/null +++ b/test/layout/overlapping-double-width-chars.color.expected @@ -0,0 +1,2 @@ +[48;2;255;0;0mう い [49m + diff --git a/test/layout/overlapping-double-width-chars.html b/test/layout/overlapping-double-width-chars.html new file mode 100644 index 00000000..c1ee0d7d --- /dev/null +++ b/test/layout/overlapping-double-width-chars.html @@ -0,0 +1,7 @@ +<!DOCTYPE html> +<div style="background-color: red"> +<div> +xあい +</div> +<div style="margin-top: -1em"> +う |