Skip to content
Myr

render: add function to set/update font

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Daniel Eklöf · committed by Daniel Eklöf · parent 13cac43 · Browse files · 3 files+24 added−10 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+24 added−10 removed

  • other:+24 added−10 removed

3 files+24 added−10 removed

modified:main.c+4 added-3 removed
401 unmodified lines
402 else403 xdg_find_programs(terminal, apps);404 read_cache(apps);405406 icon_reload_application_icons(themes, font->height, apps);407408 if ((render = render_init(font, &render_options,406 if ((render = render_init(&render_options,407 wayl_subpixel(wayl))) == NULL)408 goto out;409410 if ((prompt = prompt_init(L"> ")) == NULL)
2 unmodified lines
413 if ((matches = matches_init(apps)) == NULL)414 goto out;415416 matches_max_matches_set(matches, max_matches);417 icon_reload_application_icons(themes, font->height, apps);418 render_set_font(render, font);419420 matches_update(matches, prompt);421 wayl_configure(wayl, render, prompt, matches, dmenu_mode);422 wayl_refresh(wayl);423
26 unmodified lines
modified:render.c+16 added-5 removed
108 unmodified lines
109render_prompt(const struct render *render, struct buffer *buf,110 const struct prompt *prompt)111{112 struct fcft_font *font = render->font;113 assert(font != NULL);114115 const wchar_t *pprompt = prompt_prompt(prompt);116 const size_t prompt_len = wcslen(pprompt);117
68 unmodified lines
186render_match_list(const struct render *render, struct buffer *buf,187 const struct prompt *prompt, const struct matches *matches)188{189 struct fcft_font *font = render->font;190 assert(font != NULL);191192 const double x_margin = render->options.x_margin;193 const double y_margin = render->options.y_margin;194 const double border_size = render->options.border_size;195 const size_t match_count = matches_get_count(matches);
132 unmodified lines
328 /* Application title */329 render_match_text(330 buf, &cur_x, y,331 match->application->title, match->start_title, wcslen(prompt_text(prompt)),329 render->font, subpixel,332 font, subpixel,333 render->options.pix_text_color, render->options.pix_match_color);334335 y += row_height;336 }337}338339struct render *337render_init(struct fcft_font *font, const struct render_options *options,340render_init(const struct render_options *options,341 enum fcft_subpixel subpixel)342{343 struct render *render = calloc(1, sizeof(*render));341 render->options = *options;342 render->font = font;343 render->subpixel = subpixel;344 *render = (struct render){345 .options = *options,346 .subpixel = subpixel,347 };348349 /* TODO: the one providing the options should calculate these */350 render->options.pix_background_color = rgba2pixman(render->options.background_color);351 render->options.pix_border_color = rgba2pixman(render->options.border_color);
3 unmodified lines
355 return render;356}357358void359render_set_font(struct render *render, struct fcft_font *font)360{361 fcft_destroy(render->font);362 render->font = font;363}364365void366render_destroy(struct render *render)367{368 if (render == NULL)369 return;
4 unmodified lines
modified:render.h+4 added-2 removed
32 unmodified lines
33 pixman_color_t pix_selection_color;34};3536struct render;37struct render *render_init(struct fcft_font *font, const struct render_options *options,38 enum fcft_subpixel subpixel);37struct render *render_init(38 const struct render_options *options, enum fcft_subpixel subpixel);39void render_destroy(struct render *render);4041void render_set_font(struct render *render, struct fcft_font *font);4243void render_background(const struct render *render, struct buffer *buf);4445void render_prompt(46 const struct render *render, struct buffer *buf,
5 unmodified lines