render: don’t use the full line height for icons
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Subtract the font’s descent from the line height, and use that as the maximum height for icons.
authored by Daniel Eklöf · committed by Daniel Eklöf · parent 43bf8bd · Browse files · 2 files·+17 added−5 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+17 added−5 removed
- other:+17 added−5 removed
Provenance
- Commit
411fb8c- Tree
2b31bdb- Author
Daniel Eklöf <daniel@ekloef.se>- Committer
Daniel Eklöf <daniel@ekloef.se>- Parent
43bf8bd
2 files changed+17 added−5 removed
modified:CHANGELOG.md+6 added
8 unmodified lines91011121314151617181920212273 unmodified lines8 unmodified lines
## Unreleased### Added### Changed
* Maximum icon height reduced, from the `line height`, to the `line height` minus the font's `descent`. This ensures a margin between icons.
### Deprecated### Removed### Fixed
73 unmodified linesmodified:render.c+11 added-5 removed
23 unmodified lines24 unsigned x_margin;25 unsigned y_margin;26 unsigned border_size;27 unsigned row_height;28+ unsigned icon_height;29 };30 31 static pixman_color_t32 rgba2pixman(struct rgba rgba)217 unmodified lines250 251 const int row_height = render->row_height;252 const int first_row = 1 * border_size + y_margin + row_height;253 const int sel_margin = x_margin / 3;254+ const int icon_height = render->icon_height;255 256 int y = first_row + (row_height + font->height) / 2 - font->descent;257 258 for (size_t i = 0; i < match_count; i++) {77 unmodified lines336 pixman_format_code_t fmt = pixman_image_get_format(png);337 int height = pixman_image_get_height(png);338 int width = pixman_image_get_width(png);339 338- if (height > min(row_height, font->height)) {339- double scale = (double)min(row_height, font->height) / height;340+ if (height > icon_height) {341+ double scale = (double)icon_height / height;342 343 pixman_f_transform_t _scale_transform;344 pixman_f_transform_init_scale(345 &_scale_transform, 1. / scale, 1. / scale);56 unmodified lines402 #if defined(FUZZEL_ENABLE_SVG)403 RsvgDimensionData dim;404 rsvg_handle_get_dimensions(icon->svg, &dim);405 404- double height = min(row_height, font->height);406+ double height = icon_height;407 double scale = height / dim.height;408 409 double img_x = cur_x;410 double img_y = first_row + i * row_height + (row_height - height) / 2;82 unmodified lines493 const unsigned row_height = render->options.line_height.px >= 0494 ? pt_or_px_as_pixels(&render->options.line_height, dpi)495 : font->height;496 497+ const unsigned icon_height = max(0, (row_height - font->descent) * scale);498+499 const unsigned height =500 border_size + /* Top border */501 y_margin +502 row_height + /* The prompt */10 unmodified lines513 x_margin +514 border_size;515 516 LOG_DBG("x-margin: %d, y-margin: %d, border: %d, row-height: %d, "513- "height: %d, width: %d, scale: %d",514- x_margin, y_margin, border_size, row_height, height, width, scale);517+ "icon-height: %d, height: %d, width: %d, scale: %d",518+ x_margin, y_margin, border_size, row_height, icon_height,519+ height, width, scale);520 521 render->y_margin = y_margin;522 render->x_margin = x_margin;523 render->border_size = border_size;524 render->row_height = row_height;525+ render->icon_height = icon_height;526 render->dpi = dpi;527 528 if (new_width != NULL)529 *new_width = width;15 unmodified lines