Codechange: [Win32] Pass a native GDI font description around when we have one, instead of repeatedly guessing the font.
This commit is contained in:
@@ -737,6 +737,7 @@ public:
|
||||
virtual GlyphID MapCharToGlyph(WChar key);
|
||||
virtual const char *GetFontName() { return WIDE_TO_MB(this->logfont.lfFaceName); }
|
||||
virtual bool IsBuiltInFont() { return false; }
|
||||
virtual void *GetOSHandle() { return &this->logfont; }
|
||||
};
|
||||
|
||||
|
||||
@@ -960,13 +961,16 @@ static void LoadWin32Font(FontSize fs)
|
||||
|
||||
LOGFONT logfont;
|
||||
MemSetT(&logfont, 0);
|
||||
if (settings->os_handle != nullptr) logfont = *(const LOGFONT *)settings->os_handle;
|
||||
|
||||
logfont.lfWeight = strcasestr(settings->font, " bold") != nullptr ? FW_BOLD : FW_NORMAL; // Poor man's way to allow selecting bold fonts.
|
||||
logfont.lfPitchAndFamily = fs == FS_MONO ? FIXED_PITCH : VARIABLE_PITCH;
|
||||
logfont.lfCharSet = DEFAULT_CHARSET;
|
||||
logfont.lfOutPrecision = OUT_OUTLINE_PRECIS;
|
||||
logfont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
|
||||
convert_to_fs(settings->font, logfont.lfFaceName, lengthof(logfont.lfFaceName), false);
|
||||
if (logfont.lfFaceName[0] == 0) {
|
||||
logfont.lfWeight = strcasestr(settings->font, " bold") != nullptr ? FW_BOLD : FW_NORMAL; // Poor man's way to allow selecting bold fonts.
|
||||
logfont.lfPitchAndFamily = fs == FS_MONO ? FIXED_PITCH : VARIABLE_PITCH;
|
||||
logfont.lfCharSet = DEFAULT_CHARSET;
|
||||
logfont.lfOutPrecision = OUT_OUTLINE_PRECIS;
|
||||
logfont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
|
||||
convert_to_fs(settings->font, logfont.lfFaceName, lengthof(logfont.lfFaceName), false);
|
||||
}
|
||||
|
||||
HFONT font = CreateFontIndirect(&logfont);
|
||||
if (font == nullptr) {
|
||||
|
Reference in New Issue
Block a user