about summary refs log tree commit diff stats
path: root/src/layout
diff options
context:
space:
mode:
Diffstat (limited to 'src/layout')
-rw-r--r--src/layout/box.nim4
-rw-r--r--src/layout/engine.nim9
2 files changed, 7 insertions, 6 deletions
diff --git a/src/layout/box.nim b/src/layout/box.nim
index bee93363..07bc5f5b 100644
--- a/src/layout/box.nim
+++ b/src/layout/box.nim
@@ -1,5 +1,3 @@
-import unicode
-
 import types/enums
 import css/style
 import html/dom
@@ -50,7 +48,7 @@ type
     fontstyle*: CSSFontStyle
     fontweight*: int
     textdecoration*: CSSTextDecoration
-    runes*: seq[Rune]
+    str*: string
     nodes*: seq[Node]
 
   CSSInlineBox* = ref CSSInlineBoxObj
diff --git a/src/layout/engine.nim b/src/layout/engine.nim
index 506770b9..71dab4c2 100644
--- a/src/layout/engine.nim
+++ b/src/layout/engine.nim
@@ -84,8 +84,10 @@ proc processInlineBox(parent: CSSBox, str: string): CSSBox =
   rowbox.setup(ibox.cssvalues, ibox.bcontext.nodes)
   var r: Rune
   while i < str.len:
+    var rw = 0
     case str[i]
     of ' ', '\n', '\t':
+      rw = 1
       inc i
       let wsr = ibox.cssvalues[PROPERTY_WHITESPACE].whitespace
       if ibox.context.whitespace:
@@ -113,12 +115,13 @@ proc processInlineBox(parent: CSSBox, str: string): CSSBox =
     else:
       ibox.context.whitespace = false
       fastRuneAt(str, i, r)
+      rw = r.width()
       if rowbox.width + r.width() > ibox.width:
         inlineWrap(ibox, rowi, fromx, rowbox)
 
-    rowbox.width += r.width()
-    rowbox.runes.add(r)
-  if rowbox.runes.len > 0:
+    rowbox.width += rw
+    rowbox.str &= $r
+  if rowbox.str.len > 0:
     ibox.content.add(rowbox)
     ibox.context.fromx = fromx + rowbox.width
     ibox.context.conty = true