1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-10 01:48:00 +00:00

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.

[originally from svn r3410]
This commit is contained in:
Simon Tatham 2003-08-21 18:39:17 +00:00
parent 7798a59987
commit 46f26ee483
4 changed files with 60 additions and 45 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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;
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);
}
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 (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;
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);
}
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);
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

View File

@ -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,