aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--win32/PlatWin.cxx25
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