term: don't use deprecated fcft_size_adjust()

When resizing the font on-the-fly, we now do a complete
font-reload (this is basically what fcft_size_adjust() did anyway).

To get the correct size, we maintain the current size ourselves.

We get the initial size from the user-provided font pattern, by
converting the string to an FcPattern, and using FcPatternGet() to
retrieve both the FC_SIZE and FC_PIXEL_SIZE attributes. These
attributes are then removed from the pattern, and the pattern is
converted back to a string.

The terminal struct maintains a copy of the font sizes. These are
initially set to the sizes from the config.

When the user resizes the font, the terminal-local sizes are
adjusted. To ensure the primary and user-configured fallback fonts are
resizes equally much, convert any pixel sizes to point sizes at this
point.

When the font size is reset, we reload the font sizes from the
config (thus once again returning actual pixel-sizes, if that's what
the user has configured).
This commit is contained in:
Daniel Eklöf 2020-07-07 10:44:55 +02:00
parent 3063204289
commit 69e4213e4a
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
7 changed files with 126 additions and 107 deletions

View file

@ -7,6 +7,12 @@
#include "terminal.h"
struct config_font {
char *pattern;
double pt_size;
int px_size;
};
struct config {
char *term;
char *shell;
@ -19,7 +25,7 @@ struct config {
unsigned pad_y;
enum { STARTUP_WINDOWED, STARTUP_MAXIMIZED, STARTUP_FULLSCREEN } startup_mode;
tll(char *) fonts;
tll(struct config_font) fonts;
int scrollback_lines;
@ -87,3 +93,6 @@ struct config {
bool config_load(struct config *conf, const char *path);
void config_free(struct config conf);
struct config_font config_font_parse(const char *pattern);
void config_font_destroy(struct config_font *font);