+static void change_font_size(struct gui_data *inst, int increment)
+{
+ static const int conf_keys[lenof(inst->fonts)] = {
+ CONF_font, CONF_boldfont, CONF_widefont, CONF_wideboldfont,
+ };
+ FontSpec *oldfonts[lenof(inst->fonts)];
+ FontSpec *newfonts[lenof(inst->fonts)];
+ char *errmsg = NULL;
+ int i;
+
+ for (i = 0; i < lenof(newfonts); i++)
+ oldfonts[i] = newfonts[i] = NULL;
+
+ for (i = 0; i < lenof(inst->fonts); i++) {
+ if (inst->fonts[i]) {
+ char *newname = unifont_size_increment(inst->fonts[i], increment);
+ if (!newname)
+ goto cleanup;
+ newfonts[i] = fontspec_new(newname);
+ sfree(newname);
+ }
+ }
+
+ for (i = 0; i < lenof(newfonts); i++) {
+ if (newfonts[i]) {
+ oldfonts[i] = fontspec_copy(
+ conf_get_fontspec(inst->conf, conf_keys[i]));
+ conf_set_fontspec(inst->conf, conf_keys[i], newfonts[i]);
+ }
+ }
+
+ errmsg = setup_fonts_ucs(inst);
+ if (errmsg)
+ goto cleanup;
+
+ /* Success, so suppress putting everything back */
+ for (i = 0; i < lenof(newfonts); i++) {
+ if (oldfonts[i]) {
+ fontspec_free(oldfonts[i]);
+ oldfonts[i] = NULL;
+ }
+ }
+
+ set_geom_hints(inst);
+ request_resize(inst, conf_get_int(inst->conf, CONF_width),
+ conf_get_int(inst->conf, CONF_height));
+ term_invalidate(inst->term);
+ gtk_widget_queue_draw(inst->area);
+
+ cleanup:
+ for (i = 0; i < lenof(oldfonts); i++) {
+ if (oldfonts[i]) {
+ conf_set_fontspec(inst->conf, conf_keys[i], oldfonts[i]);
+ fontspec_free(oldfonts[i]);
+ }
+ if (newfonts[i])
+ fontspec_free(newfonts[i]);
+ }
+ sfree(errmsg);
+}
+