diff options
author | nyamatongwe <devnull@localhost> | 2011-10-31 10:58:36 +1100 |
---|---|---|
committer | nyamatongwe <devnull@localhost> | 2011-10-31 10:58:36 +1100 |
commit | 8abb964feb3be2f84612c270e152203960d32eaa (patch) | |
tree | f16be220db4f3a9e30ed24c8d9872e05a9432678 /win32 | |
parent | 348e7c87b1671992f54a0f70e1d0877617d4d86e (diff) | |
download | scintilla-mirror-rel-3-0-0.tar.gz |
When using GDI, make a copy of the font for use in autocompletionsrel-3-0-0
so it doesn't get deleted and so use the default font.
Diffstat (limited to 'win32')
-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 |