aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--terminal.c66
1 files changed, 27 insertions, 39 deletions
diff --git a/terminal.c b/terminal.c
index a34ecb1a..f931ba7d 100644
--- a/terminal.c
+++ b/terminal.c
@@ -605,12 +605,38 @@ term_set_fonts(struct terminal *term, struct fcft_font *fonts[static 4])
term->fonts[i] = fonts[i];
}
+ 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->cell_height = max(term->fonts[0]->height,
term->fonts[0]->ascent + term->fonts[0]->descent);
LOG_INFO("cell width=%d, height=%d", term->cell_width, term->cell_height);
+ if (term->cell_width < old_cell_width ||
+ term->cell_height < old_cell_height)
+ {
+ /*
+ * The cell size has decreased.
+ *
+ * This means sixels, which we cannot resize, no longer fit
+ * into their "allocated" grid space.
+ *
+ * To be able to fit them, we would have to change the grid
+ * content. Inserting empty lines _might_ seem acceptable, but
+ * we'd also need to insert empty columns, which would break
+ * existing layout completely.
+ *
+ * So we delete them.
+ */
+ sixel_destroy_all(term);
+ } else if (term->cell_width != old_cell_width ||
+ term->cell_height != old_cell_height)
+ {
+ sixel_cell_size_changed(term);
+ }
+
/* Use force, since cell-width/height may have changed */
render_resize_force(term, term->width / term->scale, term->height / term->scale);
return true;
@@ -1501,45 +1527,7 @@ term_font_size_adjust(struct terminal *term, double amount)
term->font_sizes[i].px_size = -1;
}
- const int old_cell_width = term->cell_width;
- const int old_cell_height = term->cell_height;
-
- if (!reload_fonts(term))
- return false;
-
- if (term->cell_width < old_cell_width ||
- term->cell_height < old_cell_height)
- {
- /*
- * The cell size has decreased.
- *
- * This means sixels, which we cannot resize, no longer fit
- * into their "allocated" grid space.
- *
- * To be able to fit them, we would have to change the grid
- * content. Inserting empty lines _might_ seem acceptable, but
- * we'd also need to insert empty columns, which would break
- * existing layout completely.
- *
- * So we delete them.
- */
- sixel_destroy_all(term);
- } else if (term->cell_width != old_cell_width ||
- term->cell_height != old_cell_height)
- {
- tll_foreach(term->normal.sixel_images, it) {
- struct sixel *six = &it->item;
- six->rows = (six->height + term->cell_height - 1) / term->cell_height;
- six->cols = (six->width + term->cell_width - 1) / term->cell_width;
- }
-
- tll_foreach(term->alt.sixel_images, it) {
- struct sixel *six = &it->item;
- six->rows = (six->height + term->cell_height - 1) / term->cell_height;
- six->cols = (six->width + term->cell_width - 1) / term->cell_width;
- }
- }
- return true;
+ return reload_fonts(term);
}
bool