From 7acdb3a0dd5633ac79aa7664df300b1fdbe715f0 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sat, 26 Dec 2020 16:24:16 +0100 Subject: box-drawing: add infrastructure for rendering box drawing characters ourselves MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ‘term’ struct contains an array of 160 fcft glyph pointers * the glyph pointers are lazily allocated when we need to draw a box drawings character * Filtering out box drawings characters is easy - they are (except unicode 13, which isn’t handled yet )all in a single range. --- render.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'render.c') diff --git a/render.c b/render.c index f66e277e..77e6ba5f 100644 --- a/render.c +++ b/render.c @@ -16,6 +16,7 @@ #define LOG_MODULE "render" #define LOG_ENABLE_DBG 0 #include "log.h" +#include "box-drawing.h" #include "config.h" #include "grid.h" #include "hsl.h" @@ -449,7 +450,26 @@ render_cell(struct terminal *term, pixman_image_t *pix, base = composed->base; } - glyph = fcft_glyph_rasterize(font, base, term->font_subpixel); + if (unlikely(base >= 0x2500 && base <= 0x259f)) { + /* Box drawing characters */ + size_t idx = base - 0x2500; + assert(idx < ALEN(term->box_drawing)); + + if (likely(term->box_drawing[idx] != NULL)) + glyph = term->box_drawing[idx]; + else { + mtx_lock(&term->render.workers.lock); + + /* Parallel thread may have instantiated it while we took the lock */ + if (term->box_drawing[idx] == NULL) + term->box_drawing[idx] = box_drawing(term, base); + mtx_unlock(&term->render.workers.lock); + + glyph = term->box_drawing[idx]; + assert(glyph != NULL); + } + } else + glyph = fcft_glyph_rasterize(font, base, term->font_subpixel); } const int cols_left = term->cols - col; -- cgit v1.3