From bf133a73a78d9ea39ff5cd50dfea926253ec021a Mon Sep 17 00:00:00 2001 From: simon Date: Thu, 21 Aug 2003 18:39:17 +0000 Subject: [PATCH] Richard B's patch to enable users to explicitly request shadow bold by disabling bold-font-name guessing (if their bold fonts are ugly). I've turned the UI inside out, but the meat is pretty much the same. git-svn-id: svn://svn.tartarus.org/sgt/putty@3410 cda61777-01e9-0310-a592-d414129be87e --- putty.h | 1 + settings.c | 2 ++ unix/pterm.c | 91 +++++++++++++++++++++++++++++++++--------------------------- unix/uxcfg.c | 11 +++++--- 4 files changed, 60 insertions(+), 45 deletions(-) diff --git a/putty.h b/putty.h index 46d6dc6d..9a35849e 100644 --- a/putty.h +++ b/putty.h @@ -470,6 +470,7 @@ struct config_tag { int stamp_utmp; int login_shell; int scrollbar_on_left; + int shadowbold; FontSpec boldfont; FontSpec widefont; FontSpec wideboldfont; diff --git a/settings.c b/settings.c index 0087b0f6..be43f31c 100644 --- a/settings.c +++ b/settings.c @@ -351,6 +351,7 @@ void save_open_settings(void *sesskey, int do_host, Config *cfg) write_setting_i(sesskey, "LoginShell", cfg->login_shell); write_setting_i(sesskey, "ScrollbarOnLeft", cfg->scrollbar_on_left); write_setting_fontspec(sesskey, "BoldFont", cfg->boldfont); + write_setting_i(sesskey, "ShadowBold", cfg->shadowbold); write_setting_i(sesskey, "ShadowBoldOffset", cfg->shadowboldoffset); } @@ -644,6 +645,7 @@ void load_open_settings(void *sesskey, int do_host, Config *cfg) gppi(sesskey, "StampUtmp", 1, &cfg->stamp_utmp); gppi(sesskey, "LoginShell", 1, &cfg->login_shell); gppi(sesskey, "ScrollbarOnLeft", 0, &cfg->scrollbar_on_left); + gppi(sesskey, "ShadowBold", 0, &cfg->shadowbold); gppfont(sesskey, "BoldFont", &cfg->boldfont); gppfont(sesskey, "WideFont", &cfg->widefont); gppfont(sesskey, "WideBoldFont", &cfg->wideboldfont); diff --git a/unix/pterm.c b/unix/pterm.c index 18239809..483122ad 100644 --- a/unix/pterm.c +++ b/unix/pterm.c @@ -2622,23 +2622,27 @@ void setup_fonts_ucs(struct gui_data *inst) } font_charset = set_font_info(inst, 0); - if (inst->cfg.boldfont.name[0]) { - name = inst->cfg.boldfont.name; - guessed = FALSE; + if (inst->cfg.shadowbold) { + inst->fonts[1] = NULL; } else { - name = guess_derived_font_name(inst->fonts[0], TRUE, FALSE); - guessed = TRUE; - } - inst->fonts[1] = name ? gdk_font_load(name) : NULL; - if (inst->fonts[1]) { - set_font_info(inst, 1); - } else if (!guessed) { - fprintf(stderr, "%s: unable to load bold font \"%s\"\n", appname, - inst->cfg.boldfont.name); - exit(1); + if (inst->cfg.boldfont.name[0]) { + name = inst->cfg.boldfont.name; + guessed = FALSE; + } else { + name = guess_derived_font_name(inst->fonts[0], TRUE, FALSE); + guessed = TRUE; + } + inst->fonts[1] = name ? gdk_font_load(name) : NULL; + if (inst->fonts[1]) { + set_font_info(inst, 1); + } else if (!guessed) { + fprintf(stderr, "%s: unable to load bold font \"%s\"\n", appname, + inst->cfg.boldfont.name); + exit(1); + } + if (guessed) + sfree(name); } - if (guessed) - sfree(name); if (inst->cfg.widefont.name[0]) { name = inst->cfg.widefont.name; @@ -2658,33 +2662,37 @@ void setup_fonts_ucs(struct gui_data *inst) if (guessed) sfree(name); - if (inst->cfg.wideboldfont.name[0]) { - name = inst->cfg.wideboldfont.name; - guessed = FALSE; + if (inst->cfg.shadowbold) { + inst->fonts[3] = NULL; } else { - /* - * Here we have some choices. We can widen the bold font, - * bolden the wide font, or widen and bolden the standard - * font. Try them all, in that order! - */ - if (inst->cfg.widefont.name[0]) - name = guess_derived_font_name(inst->fonts[2], TRUE, FALSE); - else if (inst->cfg.boldfont.name[0]) - name = guess_derived_font_name(inst->fonts[1], FALSE, TRUE); - else - name = guess_derived_font_name(inst->fonts[0], TRUE, TRUE); - guessed = TRUE; - } - inst->fonts[3] = name ? gdk_font_load(name) : NULL; - if (inst->fonts[3]) { - set_font_info(inst, 3); - } else if (!guessed) { - fprintf(stderr, "%s: unable to load wide/bold font \"%s\"\n", appname, - inst->cfg.wideboldfont.name); - exit(1); + if (inst->cfg.wideboldfont.name[0]) { + name = inst->cfg.wideboldfont.name; + guessed = FALSE; + } else { + /* + * Here we have some choices. We can widen the bold font, + * bolden the wide font, or widen and bolden the standard + * font. Try them all, in that order! + */ + if (inst->cfg.widefont.name[0]) + name = guess_derived_font_name(inst->fonts[2], TRUE, FALSE); + else if (inst->cfg.boldfont.name[0]) + name = guess_derived_font_name(inst->fonts[1], FALSE, TRUE); + else + name = guess_derived_font_name(inst->fonts[0], TRUE, TRUE); + guessed = TRUE; + } + inst->fonts[3] = name ? gdk_font_load(name) : NULL; + if (inst->fonts[3]) { + set_font_info(inst, 3); + } else if (!guessed) { + fprintf(stderr, "%s: unable to load wide/bold font \"%s\"\n", appname, + inst->cfg.wideboldfont.name); + exit(1); + } + if (guessed) + sfree(name); } - if (guessed) - sfree(name); inst->font_width = gdk_char_width(inst->fonts[0], ' '); inst->font_height = inst->fonts[0]->ascent + inst->fonts[0]->descent; @@ -2841,7 +2849,8 @@ void change_settings_menuitem(GtkMenuItem *item, gpointer data) strcmp(oldcfg.widefont.name, cfg2.widefont.name) || strcmp(oldcfg.wideboldfont.name, cfg2.wideboldfont.name) || strcmp(oldcfg.line_codepage, cfg2.line_codepage) || - oldcfg.vtmode != cfg2.vtmode) { + oldcfg.vtmode != cfg2.vtmode || + oldcfg.shadowbold != cfg2.shadowbold) { setup_fonts_ucs(inst); need_size = 1; } else diff --git a/unix/uxcfg.c b/unix/uxcfg.c index 582b45d9..813009ef 100644 --- a/unix/uxcfg.c +++ b/unix/uxcfg.c @@ -117,10 +117,13 @@ void unix_setup_config_box(struct controlbox *b, int midsession, void *win) ctrl_fontsel(s, "Font used for bold wide text", 'i', HELPCTX(no_help), dlg_stdfontsel_handler, I(offsetof(Config,wideboldfont))); - ctrl_text(s, "If you leave the bold font selectors blank, bold text" - " will be displayed by overprinting (\"shadow bold\"). Note" - " that this only applies if you have not requested bolding" - " to be done by changing the text colour.", + ctrl_checkbox(s, "Use shadow bold instead of bold fonts", 'u', + HELPCTX(no_help), + dlg_stdcheckbox_handler, + I(offsetof(Config,shadowbold))); + ctrl_text(s, "(Note that bold fonts or shadow bolding are only" + " used if you have not requested bolding to be done by" + " changing the text colour.)", HELPCTX(no_help)); ctrl_editbox(s, "Horizontal offset for shadow bold:", 'z', 20, HELPCTX(no_help), dlg_stdeditbox_handler, -- 2.11.0