diff options
author | Khaled Hosny <khaledhosny@eglug.org> | 2016-10-30 22:09:10 +0200 |
---|---|---|
committer | Khaled Hosny <khaledhosny@eglug.org> | 2016-10-30 22:10:51 +0200 |
commit | 641b9cb1d0934b3f8b4a80279cb3f3f81ecc4707 (patch) | |
tree | 023a1b47187a8061ad9c9e114b537dbad4c546c3 | |
parent | ffed74ee5450e6f6dd63ad3db489ebdbaa13d5fd (diff) |
tdf#103588: Draw with the right font on Windows
Apparently without implementing InitFont(), we might end up drawing with
the wrong font, thanks to the arcane ways GDI API.
Change-Id: I224de138446d4a536e13992efa98b0f04609576a
-rw-r--r-- | vcl/inc/CommonSalLayout.hxx | 8 | ||||
-rw-r--r-- | vcl/source/gdi/CommonSalLayout.cxx | 5 |
2 files changed, 9 insertions, 4 deletions
diff --git a/vcl/inc/CommonSalLayout.hxx b/vcl/inc/CommonSalLayout.hxx index 298c4c5d990d..eb2e3cd98870 100644 --- a/vcl/inc/CommonSalLayout.hxx +++ b/vcl/inc/CommonSalLayout.hxx @@ -42,9 +42,12 @@ class CommonSalLayout : public GenericSalLayout hb_font_t* mpHbFont; const FontSelectPattern& mrFontSelData; css::uno::Reference<css::i18n::XBreakIterator> mxBreak; -#if defined(MACOSX) || defined(IOS) +#ifdef _WIN32 + HDC mhDC; + HFONT mhFont; +#elif defined(MACOSX) || defined(IOS) const CoreTextStyle& mrCoreTextStyle; -#elif !defined(_WIN32) +#else FreetypeFont& mrFreetypeFont; #endif @@ -57,6 +60,7 @@ class CommonSalLayout : public GenericSalLayout public: #if defined(_WIN32) explicit CommonSalLayout(HDC, WinFontInstance&, const WinFontFace&); + void InitFont() const override { SelectObject(mhDC, mhFont); }; const FontSelectPattern& getFontSelData() const { return mrFontSelData; }; #elif defined(MACOSX) || defined(IOS) explicit CommonSalLayout(const CoreTextStyle&); diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx index dc6ca2cc745d..e7f282627ee7 100644 --- a/vcl/source/gdi/CommonSalLayout.cxx +++ b/vcl/source/gdi/CommonSalLayout.cxx @@ -172,12 +172,13 @@ void CommonSalLayout::ParseFeatures(const OUString& name) #if defined(_WIN32) CommonSalLayout::CommonSalLayout(HDC hDC, WinFontInstance& rWinFontInstance, const WinFontFace& rWinFontFace) : mrFontSelData(rWinFontInstance.maFontSelData) +, mhDC(hDC) +, mhFont(static_cast<HFONT>(GetCurrentObject(hDC, OBJ_FONT))) { mpHbFont = rWinFontFace.GetHbFont(); if (!mpHbFont) { - HFONT hFont = static_cast<HFONT>(GetCurrentObject(hDC, OBJ_FONT)); - hb_face_t* pHbFace = hb_face_create_for_tables(getFontTable, hFont, nullptr); + hb_face_t* pHbFace = hb_face_create_for_tables(getFontTable, mhFont, nullptr); mpHbFont = createHbFont(pHbFace); rWinFontFace.SetHbFont(mpHbFont); |