mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-26 07:57:59 -04:00
render: render_osd(): pass font as argument
This commit is contained in:
parent
3d9536caff
commit
5fe23c0215
1 changed files with 9 additions and 5 deletions
14
render.c
14
render.c
|
|
@ -1579,7 +1579,7 @@ render_csd_part(struct terminal *term,
|
||||||
static void
|
static void
|
||||||
render_osd(struct terminal *term,
|
render_osd(struct terminal *term,
|
||||||
struct wl_surface *surf, struct wl_subsurface *sub_surf,
|
struct wl_surface *surf, struct wl_subsurface *sub_surf,
|
||||||
struct buffer *buf,
|
struct fcft_font *font, struct buffer *buf,
|
||||||
const wchar_t *text, uint32_t _fg, uint32_t _bg,
|
const wchar_t *text, uint32_t _fg, uint32_t _bg,
|
||||||
unsigned x, unsigned y)
|
unsigned x, unsigned y)
|
||||||
{
|
{
|
||||||
|
|
@ -1594,11 +1594,15 @@ render_osd(struct terminal *term,
|
||||||
PIXMAN_OP_SRC, buf->pix[0], &bg, 1,
|
PIXMAN_OP_SRC, buf->pix[0], &bg, 1,
|
||||||
&(pixman_rectangle16_t){0, 0, buf->width, buf->height});
|
&(pixman_rectangle16_t){0, 0, buf->width, buf->height});
|
||||||
|
|
||||||
struct fcft_font *font = term->fonts[0];
|
|
||||||
pixman_color_t fg = color_hex_to_pixman(_fg);
|
pixman_color_t fg = color_hex_to_pixman(_fg);
|
||||||
|
|
||||||
const int x_ofs = term->font_x_ofs;
|
const int x_ofs = term->font_x_ofs;
|
||||||
|
|
||||||
|
const int advance =
|
||||||
|
(font->space_advance.x > 0
|
||||||
|
? font->space_advance.x
|
||||||
|
: font->max_advance.x)
|
||||||
|
+ term_pt_or_px_as_pixels(term, &term->conf->letter_spacing);
|
||||||
|
|
||||||
for (size_t i = 0; i < wcslen(text); i++) {
|
for (size_t i = 0; i < wcslen(text); i++) {
|
||||||
const struct fcft_glyph *glyph = fcft_glyph_rasterize(
|
const struct fcft_glyph *glyph = fcft_glyph_rasterize(
|
||||||
font, text[i], term->font_subpixel);
|
font, text[i], term->font_subpixel);
|
||||||
|
|
@ -1609,11 +1613,11 @@ render_osd(struct terminal *term,
|
||||||
pixman_image_t *src = pixman_image_create_solid_fill(&fg);
|
pixman_image_t *src = pixman_image_create_solid_fill(&fg);
|
||||||
pixman_image_composite32(
|
pixman_image_composite32(
|
||||||
PIXMAN_OP_OVER, src, glyph->pix, buf->pix[0], 0, 0, 0, 0,
|
PIXMAN_OP_OVER, src, glyph->pix, buf->pix[0], 0, 0, 0, 0,
|
||||||
x + x_ofs + glyph->x, y + font_baseline(term) - glyph->y,
|
x + x_ofs + glyph->x, y + term->font_y_ofs + font->ascent - glyph->y,
|
||||||
glyph->width, glyph->height);
|
glyph->width, glyph->height);
|
||||||
pixman_image_unref(src);
|
pixman_image_unref(src);
|
||||||
|
|
||||||
x += term->cell_width;
|
x += advance;
|
||||||
}
|
}
|
||||||
|
|
||||||
pixman_image_set_clip_region32(buf->pix[0], NULL);
|
pixman_image_set_clip_region32(buf->pix[0], NULL);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue