diff options
author | M Stoeckl <code@mstoeckl.com> | 2024-10-31 10:27:47 -0400 |
---|---|---|
committer | adnano <adnano@noreply.codeberg.org> | 2024-11-01 23:33:53 +0000 |
commit | 0947765fc9a4f6fc4287acfcd2efcaf4fef1ffb8 (patch) | |
tree | e123c7fe7ded1913957731c5a91d3d6eba4fd431 /render.c | |
parent | 260eaba88ec8f54fe2bdbe391b18fcd2db70836f (diff) | |
download | wmenu-0947765fc9a4f6fc4287acfcd2efcaf4fef1ffb8.tar.gz |
Only call render_menu once per frame
An actual surface is not needed to estimate font sizes; a 1x1 image
will do, as long as the cairo context has the same options.
Diffstat (limited to 'render.c')
-rw-r--r-- | render.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -13,8 +13,13 @@ // Calculate text widths. void calc_widths(struct menu *menu) { struct wl_context *context = menu->context; - struct pool_buffer *current = context_get_current_buffer(context); - cairo_t *cairo = current->cairo; + int scale = context_get_scale(context); + cairo_surface_set_device_scale(menu->test_surface, scale, scale); + cairo_set_antialias(menu->test_cairo, CAIRO_ANTIALIAS_BEST); + cairo_font_options_t *fo = cairo_font_options_create(); + cairo_set_font_options(menu->test_cairo, fo); + cairo_font_options_destroy(fo); + cairo_t *cairo = menu->test_cairo; // Calculate prompt width if (menu->prompt) { |