about summary refs log tree commit diff stats
path: root/src/render
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2022-12-16 19:01:56 +0100
committerbptato <nincsnevem662@gmail.com>2022-12-16 19:13:53 +0100
commit7146419b06c87eb00a51b16d5bec3e22b7d0a949 (patch)
treee34dde3ed3887aa21c77cd2444e463c12458f429 /src/render
parentffee0d78c9bcbf04b41892dee613ebdc7ae0b95d (diff)
downloadchawan-7146419b06c87eb00a51b16d5bec3e22b7d0a949.tar.gz
Display text for img tag, background-image
Diffstat (limited to 'src/render')
-rw-r--r--src/render/renderdocument.nim12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/render/renderdocument.nim b/src/render/renderdocument.nim
index 914ada85..bdcf4df8 100644
--- a/src/render/renderdocument.nim
+++ b/src/render/renderdocument.nim
@@ -300,6 +300,18 @@ proc renderBlockContext(grid: var FlexibleGrid, ctx: BlockBox, x, y: int, window
 
     if ctx.computed{"background-color"}.a != 0: #TODO color blending
       grid.paintBackground(ctx.computed{"background-color"}, x, y, x + ctx.width, y + ctx.height, window)
+    if ctx.computed{"background-image"}.t == CONTENT_IMAGE:
+      # ugly hack for background-image display... TODO actually implement images
+      let s = ctx.computed{"background-image"}.s # [img]
+      let w = s.len * window.ppc
+      var x = x
+      if ctx.width < w:
+        # text is larger than image; center it to minimize error
+        x -= w div 2
+        x += ctx.width div 2
+      x = x div window.ppc
+      y = y div window.ppl
+      grid.setText(s, ComputedFormat(node: ctx.node), x, y)
 
     if ctx of ListItemBox:
       let ctx = ListItemBox(ctx)