diff options
author | nyamatongwe <unknown> | 2011-10-31 10:58:36 +1100 |
---|---|---|
committer | nyamatongwe <unknown> | 2011-10-31 10:58:36 +1100 |
commit | b54d39aecf558ef6ae874abfc3f1f1b17f46fd77 (patch) | |
tree | d341fc4f13dc9281b2b5e06e8757295c2b041b95 | |
parent | 1fa26e53a08ea20ea45244d16602e8e482bdb8f0 (diff) | |
download | scintilla-mirror-b54d39aecf558ef6ae874abfc3f1f1b17f46fd77.tar.gz |
When using GDI, make a copy of the font for use in autocompletions
so it doesn't get deleted and so use the default font.
-rw-r--r-- | win32/PlatWin.cxx | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index 3d9b7e88f..01c36199b 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -192,25 +192,28 @@ struct FormatAndMetrics { }; HFONT FormatAndMetrics::HFont() { + LOGFONTW lf; + memset(&lf, 0, sizeof(lf)); #if defined(USE_D2D) if (technology == SCWIN_TECH_GDI) { - return hfont; + if (0 == ::GetObject(hfont, sizeof(lf), &lf)) { + return 0; + } } else { - LOGFONTW lf; - memset(&lf, 0, sizeof(lf)); - HRESULT hr = pTextFormat->GetFontFamilyName(lf.lfFaceName, LF_FACESIZE); - if (SUCCEEDED(hr)) { - lf.lfWeight = pTextFormat->GetFontWeight(); - lf.lfItalic = pTextFormat->GetFontStyle() == DWRITE_FONT_STYLE_ITALIC; - lf.lfHeight = -static_cast<int>(pTextFormat->GetFontSize()); - return ::CreateFontIndirectW(&lf); + if (!SUCCEEDED(hr)) { + return 0; } + lf.lfWeight = pTextFormat->GetFontWeight(); + lf.lfItalic = pTextFormat->GetFontStyle() == DWRITE_FONT_STYLE_ITALIC; + lf.lfHeight = -static_cast<int>(pTextFormat->GetFontSize()); } - return 0; #else - return hfont; + if (0 == ::GetObject(hfont, sizeof(lf), &lf)) { + return 0; + } #endif + return ::CreateFontIndirectW(&lf); } #ifndef CLEARTYPE_QUALITY |