From ef37b1119ec78801ab72a76dc750c0b8bfd52af5 Mon Sep 17 00:00:00 2001 From: bptato Date: Wed, 26 Jan 2022 15:49:41 +0100 Subject: Fix whitespace styling --- src/layout/box.nim | 3 +++ src/layout/engine.nim | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'src/layout') diff --git a/src/layout/box.nim b/src/layout/box.nim index d461f0f5..d7ae3400 100644 --- a/src/layout/box.nim +++ b/src/layout/box.nim @@ -23,6 +23,9 @@ type width*: int height*: int + InlineSpacing* = ref object of InlineAtom + word*: InlineWord + InlineWord* = ref object of InlineAtom str*: string fontstyle*: CSSFontStyle diff --git a/src/layout/engine.nim b/src/layout/engine.nim index 9b1e9363..45aef6de 100644 --- a/src/layout/engine.nim +++ b/src/layout/engine.nim @@ -80,9 +80,13 @@ proc addAtom(ictx: InlineContext, atom: InlineAtom, maxwidth: int, specified: CS shift = ictx.computeShift(specified) ictx.whitespace = false - ictx.thisrow.width += shift + if atom.width > 0 and atom.height > 0: + if shift > 0: + let spacing = InlineSpacing(width: shift, height: atom.height) + spacing.relx = ictx.thisrow.width + ictx.thisrow.width += spacing.width + ictx.thisrow.atoms.add(spacing) - if atom.width > 0: atom.relx += ictx.thisrow.width ictx.thisrow.width += atom.width ictx.thisrow.height = max(ictx.thisrow.height, atom.height) -- cgit 1.4.1-2-gfad0