diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2021-07-22 21:35:00 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2021-07-24 09:02:43 +0000 |
| commit | 7714fcde83c223f8143bb406eb2e2541ee932c4a (patch) | |
| tree | 204f65c173de95394f9c3369caa5d7bcc019f4a7 /render.c | |
| parent | render: render_osd(): fix rendering of color bitmap glyphs (diff) | |
render: render_osd(): use fcft_text_run_rasterize(), if available
Diffstat (limited to 'render.c')
| -rw-r--r-- | render.c | 38 |
1 files changed, 32 insertions, 6 deletions
@@ -1597,14 +1597,39 @@ render_osd(struct terminal *term, pixman_color_t fg = color_hex_to_pixman(_fg); const int x_ofs = term->font_x_ofs; - pixman_image_t *src = pixman_image_create_solid_fill(&fg); + const size_t len = wcslen(text); + struct fcft_text_run *text_run = NULL; + const struct fcft_glyph **glyphs = NULL; + const struct fcft_glyph *_glyphs[len]; + size_t glyph_count = 0; - for (size_t i = 0; i < wcslen(text); i++) { - const struct fcft_glyph *glyph = fcft_glyph_rasterize( - font, text[i], term->font_subpixel); + if (fcft_capabilities() & FCFT_CAPABILITY_TEXT_RUN_SHAPING) { + text_run = fcft_text_run_rasterize(font, len, text, term->font_subpixel); - if (glyph == NULL) - continue; + if (text_run != NULL) { + glyphs = text_run->glyphs; + glyph_count = text_run->count; + } + } + + if (glyphs == NULL) { + for (size_t i = 0; i < len; i++) { + const struct fcft_glyph *glyph = fcft_glyph_rasterize( + font, text[i], term->font_subpixel); + + if (glyph == NULL) + continue; + + _glyphs[glyph_count++] = glyph; + } + + glyphs = _glyphs; + } + + pixman_image_t *src = pixman_image_create_solid_fill(&fg); + + for (size_t i = 0; i < glyph_count; i++) { + const struct fcft_glyph *glyph = glyphs[i]; if (pixman_image_get_format(glyph->pix) == PIXMAN_a8r8g8b8) { pixman_image_composite32( @@ -1621,6 +1646,7 @@ render_osd(struct terminal *term, x += glyph->advance.x; } + fcft_text_run_destroy(text_run); pixman_image_unref(src); pixman_image_set_clip_region32(buf->pix[0], NULL); |
