vcl/inc/CommonSalLayout.hxx        |    1 +
 vcl/source/gdi/CommonSalLayout.cxx |    9 ++++++++-
 vcl/win/gdi/winlayout.cxx          |   31 ++++++++-----------------------
 3 files changed, 17 insertions(+), 24 deletions(-)

New commits:
commit 4375eefb644d03ab4bafbc091436166a8494dc91
Author: Khaled Hosny <khaledho...@eglug.org>
Date:   Fri Mar 3 05:15:14 2017 +0200

    tdf#103831, tdf#100986: Force using GDI when needed
    
    Our DirectWrite renderer is incomplete and can’t handle rotated text or 
text
    with horizontal scaling, so route these two through GDI for now.
    
    Reviewed-on: https://gerrit.libreoffice.org/34848
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Khaled Hosny <khaledho...@eglug.org>
    (cherry picked from commit a51b7a1c3a7e7cf7b0c733e1dec40288278c1884)
    
    Change-Id: I87b85796a29e3acce782e01b4c629fec6f1a9e25
    Reviewed-on: https://gerrit.libreoffice.org/34862
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk>

diff --git a/vcl/inc/CommonSalLayout.hxx b/vcl/inc/CommonSalLayout.hxx
index e2f3a11..58cba16 100644
--- a/vcl/inc/CommonSalLayout.hxx
+++ b/vcl/inc/CommonSalLayout.hxx
@@ -68,6 +68,7 @@ public:
     const FontSelectPattern& getFontSelData() const { return mrFontSelData; };
     HFONT                   getHFONT() const { return mhFont; }
     WinFontInstance&        getWinFontInstance() const { return 
mrWinFontInstance; }
+    bool                    hasHScale() const;
 #elif defined(MACOSX) || defined(IOS)
     explicit                CommonSalLayout(const CoreTextStyle&);
     const CoreTextStyle&    getFontData() const { return mrCoreTextStyle; };
diff --git a/vcl/source/gdi/CommonSalLayout.cxx 
b/vcl/source/gdi/CommonSalLayout.cxx
index bd59a6b..21be0c9 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -209,7 +209,7 @@ CommonSalLayout::CommonSalLayout(HDC hDC, WinFontInstance& 
rWinFontInstance, con
     }
 
     // Calculate the mnAveWidthFactor, see the comment where it is used.
-    if (mrFontSelData.mnWidth && ! OpenGLHelper::isVCLOpenGLEnabled())
+    if (mrFontSelData.mnWidth)
     {
         double nUPEM = hb_face_get_upem(hb_font_get_face(mpHbFont));
 
@@ -233,6 +233,13 @@ CommonSalLayout::CommonSalLayout(HDC hDC, WinFontInstance& 
rWinFontInstance, con
     }
 }
 
+bool CommonSalLayout::hasHScale() const
+{
+    int nHeight(mrFontSelData.mnHeight);
+    int nWidth(mrFontSelData.mnWidth ? mrFontSelData.mnWidth * 
mnAveWidthFactor : nHeight);
+    return nWidth != nHeight;
+}
+
 #elif defined(MACOSX) || defined(IOS)
 CommonSalLayout::CommonSalLayout(const CoreTextStyle& rCoreTextStyle)
 :   mrFontSelData(rCoreTextStyle.maFontSelData)
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index 5cfa9b7..482cbd7 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -103,26 +103,6 @@ bool WinFontInstance::CacheGlyphToAtlas(bool 
bRealGlyphIndices, HDC hDC, HFONT h
         return false;
     }
 
-    // Bail for non-horizontal text.
-    {
-        wchar_t sFaceName[200];
-        int nFaceNameLen = GetTextFaceW(hNewDC, SAL_N_ELEMENTS(sFaceName), 
sFaceName);
-
-        if (!nFaceNameLen)
-            SAL_WARN("vcl.gdi", "GetTextFace failed: " << 
WindowsErrorString(GetLastError()));
-
-        LOGFONTW aLogFont;
-        GetObjectW(hFont, sizeof(LOGFONTW), &aLogFont);
-
-        SelectObject(hNewDC, hOrigFont);
-        DeleteDC(hNewDC);
-
-        if (sFaceName[0] == '@' || aLogFont.lfOrientation != 0 || 
aLogFont.lfEscapement != 0)
-        {
-            pTxt->ReleaseFont();
-            return false;
-        }
-    }
     std::vector<WORD> aGlyphIndices(1);
     // Fetch the ink boxes and calculate the size of the atlas.
     if (!bRealGlyphIndices)
@@ -3872,13 +3852,18 @@ void WinSalGraphics::DrawTextLayout(const 
CommonSalLayout& rLayout, HDC hDC, boo
 void WinSalGraphics::DrawSalLayout(const CommonSalLayout& rLayout)
 {
     HDC hDC = getHDC();
+
+    // Our DirectWrite renderer is incomplete, skip it for non-horizontal or
+    // stretched text.
+    bool bForceGDI = rLayout.GetOrientation() || rLayout.hasHScale();
+
     bool bUseOpenGL = OpenGLHelper::isVCLOpenGLEnabled() && !mbPrinter;
     if (!bUseOpenGL)
     {
         // no OpenGL, just classic rendering
-        DrawTextLayout(rLayout, hDC, false);
+        DrawTextLayout(rLayout, hDC, !bForceGDI);
     }
-    else if (CacheGlyphs(rLayout) &&
+    else if (!bForceGDI && CacheGlyphs(rLayout) &&
              DrawCachedGlyphs(rLayout))
     {
         // Nothing
@@ -3945,7 +3930,7 @@ void WinSalGraphics::DrawSalLayout(const CommonSalLayout& 
rLayout)
             SalColor salColor = MAKE_SALCOLOR(GetRValue(color), 
GetGValue(color), GetBValue(color));
 
             // the actual drawing
-            DrawTextLayout(rLayout, aDC.getCompatibleHDC(), true);
+            DrawTextLayout(rLayout, aDC.getCompatibleHDC(), !bForceGDI);
 
             std::unique_ptr<OpenGLTexture> xTexture(aDC.getTexture());
             if (xTexture)
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to