Composition interacts strangely with non-1x1 fonts

Issue #46 new
Steve Losh
created an issue

I'm trying to use Bearlibterminal's composition feature to draw a text box with a background all in a single layer. First I draw a background of all full-block characters, then I print the text in the box.

When all my fonts are 1x1, this works fine. But I've got a separate font I want to use for the text whose spacing is larger, for example 2x2. When I try to print some text with this font into the same layer as the full blocks, with composition turned on, only the top-left cell of each character gets drawn.

Here's some really ugly sample code (sorry it's in Lisp):

    (blt:font) "simple"
    (blt:color) (blt:hsva 1.0 1.0 0.5)
    (blt:composition) t
    (blt:cell-char 0 10) #\full_block
    (blt:cell-char 1 10) #\full_block
    (blt:cell-char 0 11) #\full_block
    (blt:cell-char 1 11) #\full_block
    (blt:cell-char 0 12) #\full_block
    (blt:cell-char 1 12) #\full_block
    (blt:cell-char 0 13) #\full_block
    (blt:cell-char 1 13) #\full_block
    (blt:cell-char 2 10) #\full_block
    (blt:cell-char 3 10) #\full_block
    (blt:cell-char 2 11) #\full_block
    (blt:cell-char 3 11) #\full_block
    (blt:cell-char 2 12) #\full_block
    (blt:cell-char 3 12) #\full_block
    (blt:cell-char 2 13) #\full_block
    (blt:cell-char 3 13) #\full_block
    (blt:color) (blt:hsva 0.2 1.0 1.0))
  (blt:print 0 10 (format nil "[font=tile]@@~%@@"))

And the result:

I tried to print two lines of @@ but only the top-left corner of each @ gets drawn.

Comments (1)

  1. Alexander Malinin repo owner

    Missed this issue somehow.

    This behavior is, well, as expected. Tiles are drawn cell by cell, left to right, top to bottom and one of the functions of layers is enforcing a Z-order between arbitrarily sized tiles. From the technical point this happens because tiles must be addressable by cells and it will be harder to keep both spatial (x, y) indexing and temporal (drawing) order. Well, not much harder, but it will cost some CPU and memory.

    Now that I think about it, the overhead may not be that high with carefully chosen data structures. Maybe I'll try to implement it as a third option for terminal_composition to test and measure things up.

  2. Log in to comment