[Libreoffice-commits] core.git: vcl/inc vcl/source

Khaled Hosny khaledhosny at eglug.org
Sun Oct 30 20:11:29 UTC 2016


 vcl/inc/CommonSalLayout.hxx        |    8 ++++++--
 vcl/source/gdi/CommonSalLayout.cxx |    5 +++--
 2 files changed, 9 insertions(+), 4 deletions(-)

New commits:
commit 641b9cb1d0934b3f8b4a80279cb3f3f81ecc4707
Author: Khaled Hosny <khaledhosny at eglug.org>
Date:   Sun Oct 30 22:09:10 2016 +0200

    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

diff --git a/vcl/inc/CommonSalLayout.hxx b/vcl/inc/CommonSalLayout.hxx
index 298c4c5..eb2e3cd 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 dc6ca2cc..e7f2826 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);


More information about the Libreoffice-commits mailing list