Configurable font quality on Windows. (Together with a little bit of

macro stuff to cope with the inadequacy of VC++ 6 headers.)

[originally from svn r6519]
This commit is contained in:
Owen Dunn 2006-01-11 23:42:02 +00:00
Родитель ad05f78303
Коммит dd924a644e
5 изменённых файлов: 46 добавлений и 2 удалений

Просмотреть файл

@ -324,6 +324,10 @@ enum {
FUNKY_SCO
};
enum {
FQ_DEFAULT, FQ_ANTIALIASED, FQ_NONANTIALIASED, FQ_CLEARTYPE
};
extern const char *const ttymodes[];
enum {
@ -502,6 +506,7 @@ struct config_tag {
int win_name_always;
int width, height;
FontSpec font;
int font_quality;
Filename logfilename;
int logtype;
int logxfovr;

Просмотреть файл

@ -372,6 +372,7 @@ void save_open_settings(void *sesskey, int do_host, Config *cfg)
write_setting_i(sesskey, "TermWidth", cfg->width);
write_setting_i(sesskey, "TermHeight", cfg->height);
write_setting_fontspec(sesskey, "Font", cfg->font);
write_setting_i(sesskey, "FontQuality", cfg->font_quality);
write_setting_i(sesskey, "FontVTMode", cfg->vtmode);
write_setting_i(sesskey, "UseSystemColours", cfg->system_colour);
write_setting_i(sesskey, "TryPalette", cfg->try_palette);
@ -649,6 +650,7 @@ void load_open_settings(void *sesskey, int do_host, Config *cfg)
gppi(sesskey, "TermWidth", 80, &cfg->width);
gppi(sesskey, "TermHeight", 24, &cfg->height);
gppfont(sesskey, "Font", &cfg->font);
gppi(sesskey, "FontQuality", FQ_DEFAULT, &cfg->font_quality);
gppi(sesskey, "FontVTMode", VT_UNICODE, (int *) &cfg->vtmode);
gppi(sesskey, "UseSystemColours", 0, &cfg->system_colour);
gppi(sesskey, "TryPalette", 0, &cfg->try_palette);

Просмотреть файл

@ -172,6 +172,20 @@ void win_setup_config_box(struct controlbox *b, HWND *hwndp, int has_help,
HELPCTX(appearance_border),
dlg_stdcheckbox_handler, I(offsetof(Config,sunken_edge)));
/*
* Configurable font quality settings for Windows.
*/
s = ctrl_getset(b, "Window/Appearance", "font",
"Font settings");
ctrl_radiobuttons(s, "Font quality:", 'q', 2,
HELPCTX(appearance_font),
dlg_stdradiobutton_handler,
I(offsetof(Config, font_quality)),
"Antialiased", I(FQ_ANTIALIASED),
"Non-Antialiased", I(FQ_NONANTIALIASED),
"ClearType", I(FQ_CLEARTYPE),
"Default", I(FQ_DEFAULT), NULL);
/*
* Cyrillic Lock is a horrid misfeature even on Windows, and
* the least we can do is ensure it never makes it to any other

Просмотреть файл

@ -1319,7 +1319,7 @@ static void init_fonts(int pick_width, int pick_height)
#define f(i,c,w,u) \
fonts[i] = CreateFont (font_height, font_width, 0, 0, w, FALSE, u, FALSE, \
c, OUT_DEFAULT_PRECIS, \
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, \
CLIP_DEFAULT_PRECIS, FONT_QUALITY(cfg.font_quality), \
FIXED_PITCH | FF_DONTCARE, cfg.font.name)
f(FONT_NORMAL, cfg.font.charset, fw_dontcare, FALSE);
@ -1488,7 +1488,7 @@ static void another_font(int fontno)
fonts[fontno] =
CreateFont(font_height * (1 + !!(fontno & FONT_HIGH)), x, 0, 0, w,
FALSE, u, FALSE, c, OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
CLIP_DEFAULT_PRECIS, FONT_QUALITY(cfg.font_quality),
FIXED_PITCH | FF_DONTCARE, s);
fontflag[fontno] = 1;
@ -2142,6 +2142,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
cfg.font.isbold != prev_cfg.font.isbold ||
cfg.font.height != prev_cfg.font.height ||
cfg.font.charset != prev_cfg.font.charset ||
cfg.font_quality != prev_cfg.font_quality ||
cfg.vtmode != prev_cfg.vtmode ||
cfg.bold_colour != prev_cfg.bold_colour ||
cfg.resize_action == RESIZE_DISABLED ||

Просмотреть файл

@ -27,8 +27,30 @@ struct FontSpec {
int charset;
};
#ifndef CLEARTYPE_QUALITY
#define CLEARTYPE_QUALITY 5
#endif
#define FONT_QUALITY(fq) ( \
(fq) == FQ_DEFAULT ? DEFAULT_QUALITY : \
(fq) == FQ_ANTIALIASED ? ANTIALIASED_QUALITY : \
(fq) == FQ_NONANTIALIASED ? NONANTIALIASED_QUALITY : \
CLEARTYPE_QUALITY)
/* VC++ 6 doesn't have GetWindowLongPtr and friends. Degrade nicely. */
#ifndef GWLP_USERDATA
#define GetWindowLongPtr GetWindowLong
#define SetWindowLongPtr SetWindowLong
#define GWLP_USERDATA GWL_USERDATA
#define DWLP_MSGRESULT DWL_MSGRESULT
#endif
#define BOXFLAGS DLGWINDOWEXTRA
#ifdef LONG_PTR
#define BOXRESULT (DLGWINDOWEXTRA + sizeof(LONG_PTR))
#else
#define BOXRESULT (DLGWINDOWEXTRA + 4)
#endif
#define DF_END 0x0001
/*