Skip to content
Myr

main: set optimal icon size from the font height

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

When searching for icons, we use the font height as-is. I.e. don't try to find icons that are exactly the size of a whole line, as that looks ugly. However, when rendering, we *do* allow icons that are larger than the font height, but still within the line height. This is to avoid scaling. When we do have to scale, we scale it to the font height, not the line height.

authored by Daniel Eklöf · committed by Daniel Eklöf · parent 0d7b79c · Browse files · 2 files+12 added−2 removed
This commit

State

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

Diff stats

2 files+12 added−2 removed

  • other:+12 added−2 removed

2 files+12 added−2 removed

modified:main.c+11 added-1 removed
915 unmodified lines
916 thrd_t keyboard_repeater_id;917 thrd_create(&keyboard_repeater_id, &keyboard_repeater, &c);918919 cairo_scaled_font_t *font = font_from_name(font_name);920 cairo_surface_t *surf = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1);921 cairo_t *cr = cairo_create(surf);922 cairo_font_extents_t fextents;923 cairo_set_scaled_font(cr, font);924 cairo_font_extents(cr, &fextents);925 cairo_destroy(cr);926 cairo_surface_destroy(surf);927928 LOG_DBG("height: %f, ascent: %f, descent: %f",929 fextents.height, fextents.ascent, fextents.descent);930931 //find_programs();922 xdg_find_programs(16, &c.applications);932 xdg_find_programs(fextents.height, &c.applications);933 c.matches = malloc(tll_length(c.applications) * sizeof(c.matches[0]));934 update_matches(&c);935936 c.wl.display = wl_display_connect(NULL);
198 unmodified lines
modified:render.c+1 added-1 removed
232 unmodified lines
233 double size = match->application->icon.size;234 double scale = 1.0;235236 if (size > row_height) {237 scale = row_height / size;237 scale = (row_height - 2 * y_margin) / size;238 LOG_DBG("%s: scaling: %f (row-height: %f, size=%f",239 match->application->title, scale, row_height, size);240241 size *= scale;
46 unmodified lines