about summary refs log tree commit diff stats
path: root/src/render
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2022-01-28 18:58:45 +0100
committerbptato <nincsnevem662@gmail.com>2022-01-28 18:58:45 +0100
commita42f0b169f5f612b3b14026618bcb26a2afeedca (patch)
treec5cf1ee21ad32444ef74b4e06ed5c4bd16c09abc /src/render
parent876f5e9c64992ffef8630cd2bafa8c5ba9431f01 (diff)
downloadchawan-a42f0b169f5f612b3b14026618bcb26a2afeedca.tar.gz
Implement line-height, vertical-align
Diffstat (limited to 'src/render')
-rw-r--r--src/render/renderdocument.nim13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/render/renderdocument.nim b/src/render/renderdocument.nim
index 13cd7b0c..732bcf47 100644
--- a/src/render/renderdocument.nim
+++ b/src/render/renderdocument.nim
@@ -27,7 +27,9 @@ func formatFromWord(computed: ComputedFormat): Format =
 proc setRowWord(lines: var FlexibleGrid, word: InlineWord, x, y: int, term: TermAttributes) =
   var r: Rune
 
-  let y = y div term.ppl
+  var y = (y + word.rely) div term.ppl
+  if y < 0: y = 0
+
   var x = (x + word.relx) div term.ppc
   var i = 0
   while x < 0:
@@ -72,7 +74,9 @@ proc setRowWord(lines: var FlexibleGrid, word: InlineWord, x, y: int, term: Term
 proc setSpacing(lines: var FlexibleGrid, spacing: InlineSpacing, x, y: int, term: TermAttributes) =
   var r: Rune
 
-  let y = y div term.ppl
+  var y = (y + spacing.rely) div term.ppl
+  if y < 0: y = 0
+
   var x = (x + spacing.relx) div term.ppc
   let width = spacing.width div term.ppc
 
@@ -123,11 +127,8 @@ proc renderInlineContext(grid: var FlexibleGrid, ctx: InlineContext, x, y: int,
   let y = y + ctx.rely
   for row in ctx.rows:
     let x = x + row.relx
-    let y = y + row.rely + row.height
+    let y = y + row.rely
     for atom in row.atoms:
-      # This aligns atoms with the baseline.
-      # (other alignment types in progress)
-      let y = y - atom.height
       if atom of BlockContext:
         let ctx = BlockContext(atom)
         grid.renderBlockContext(ctx, x, y, term)