term: remove get_font_scale()

get_font_scale() was used to get the new scaling factor when loading
fonts. This was then compared to the last seen font scaling factor. If
there was no difference, the fonts were not reloaded.

The problem was, the initial term->scale was set differently. This
sometimes led to term->scale=2, while get_font_scale() return 1. That
meant, fonts were initially scaled by 2 (when dpi-aware=no). Later,
when mapped on an output (and thus term->scale being set to 1), the
fonts weren’t reloaded with the correct scaling factor since the
cached term->font_scale value was already 1.

Since term->scale always reflects the *new* scaling factor when
term_font_dpi_changed() is called, use that directly, and remove
get_font_scale().

Also rename the following functions:

* font_should_size_by_dpi() -> font_size_by_dpi_for_scale()
* font_size_by_dpi() -> font_sized_by_dpi()
* font_size_by_scale() -> font_sized_by_scale()
This commit is contained in:
Daniel Eklöf 2021-05-13 00:15:00 +02:00
parent 3405a9c81c
commit 0935428695
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 14 additions and 39 deletions

View file

@ -320,7 +320,7 @@ struct terminal {
struct config_font *font_sizes[4];
struct pt_or_px font_line_height;
float font_dpi;
int font_scale;
int font_scale; /* scaling factor last time we loaded fonts */
int16_t font_x_ofs;
int16_t font_y_ofs;
enum fcft_subpixel font_subpixel;