aboutsummaryrefslogtreecommitdiff
path: root/terminal.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-01-07 16:00:58 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-01-11 08:31:08 +0000
commita6fc8b5da4a3bfc9b1d3994797826518103879ac (patch)
tree7ee4333c53847900a895b566d5414ee375ba23fd /terminal.c
parentconfig: str_to_color(): use LOG_AND_NOTIFY(), not just LOG() (diff)
config: line-height, letter-spacing: values are in pt by default, but we allow px
If the value is specified without a unit, then the value is assumed to be in points, subject to DPI scaling. The value can optionally have a ‘px’ suffix, in which case the value is treated as a raw pixel count.
Diffstat (limited to 'terminal.c')
-rw-r--r--terminal.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/terminal.c b/terminal.c
index c23450fb..676f0cb4 100644
--- a/terminal.c
+++ b/terminal.c
@@ -629,15 +629,30 @@ term_set_fonts(struct terminal *term, struct fcft_font *fonts[static 4])
const int old_cell_width = term->cell_width;
const int old_cell_height = term->cell_height;
- term->cell_width = (term->fonts[0]->space_advance.x > 0
- ? term->fonts[0]->space_advance.x
- : term->fonts[0]->max_advance.x)
- + term->conf->letter_spacing;
+ const struct config *conf = term->conf;
- term->cell_height = term->conf->line_height >= 0
- ? term->conf->line_height
+ term->cell_width =
+ (term->fonts[0]->space_advance.x > 0
+ ? term->fonts[0]->space_advance.x
+ : term->fonts[0]->max_advance.x)
+ + (conf->letter_spacing.px > 0
+ ? conf->letter_spacing.px
+ : conf->letter_spacing.pt * term->font_dpi / 72.);
+
+ term->cell_height = conf->line_height.px >= 0
+ ? (conf->line_height.px > 0
+ ? conf->line_height.px
+ : conf->line_height.pt * term->font_dpi / 72.)
: max(term->fonts[0]->height,
term->fonts[0]->ascent + term->fonts[0]->descent);
+
+ term->font_x_ofs = conf->horizontal_letter_offset.px > 0
+ ? conf->horizontal_letter_offset.px
+ : conf->horizontal_letter_offset.pt * term->font_dpi / 72.;
+ term->font_y_ofs = conf->vertical_letter_offset.px > 0
+ ? conf->vertical_letter_offset.px
+ : conf->vertical_letter_offset.pt * term->font_dpi / 72.;
+
LOG_INFO("cell width=%d, height=%d", term->cell_width, term->cell_height);
if (term->cell_width < old_cell_width ||