[Libreoffice-commits] core.git: Branch 'libreoffice-5-3' - vcl/win

Mark Hung marklh9 at gmail.com
Thu Feb 9 23:39:16 UTC 2017


 vcl/win/gdi/winlayout.cxx |   30 +++++++++++++++++++++++++++---
 1 file changed, 27 insertions(+), 3 deletions(-)

New commits:
commit 6ea0cb85173ce075a4bc7e2f7c6370628a8ba339
Author: Mark Hung <marklh9 at gmail.com>
Date:   Sat Jan 14 19:00:31 2017 +0800

    tdf#105286 use alternative font when glyph is not vertical.
    
    In vertical layout, a vertical font is selected. For windows,
    that means prepending a '@' to the font name. Switch back to
    the one without '@' in order to display characters that needs
    to be rotated 90 degrees in vertical layout correctly.
    
    cherry-picked from aa9251103a131880afa621501936603d8c75af9d.
    
    Change-Id: I4e0361929f898eddc671b739b36a12dd26d68018
    Reviewed-on: https://gerrit.libreoffice.org/33064
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Khaled Hosny <khaledhosny at eglug.org>
    Reviewed-on: https://gerrit.libreoffice.org/34093

diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index cefe4b1..5cfa9b7 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -3117,6 +3117,22 @@ bool ExTextOutRenderer::operator ()(SalLayout const &rLayout, HDC hDC,
     sal_GlyphId glyphIntStr[MAX_GLYPHS];
     int nGlyphs = 0;
     WORD glyphWStr[MAX_GLYPHS];
+    HFONT hFont = static_cast<HFONT>(GetCurrentObject( hDC, OBJ_FONT ));
+    HFONT hAltFont = nullptr;
+    bool bUseAltFont = false;
+    const CommonSalLayout* pCSL = dynamic_cast<const CommonSalLayout*>(&rLayout);
+    if (pCSL && pCSL->getFontSelData().mbVertical)
+    {
+        LOGFONTW aLogFont;
+        GetObjectW(hFont, sizeof(LOGFONTW), &aLogFont);
+        if (aLogFont.lfFaceName[0] == '@')
+        {
+            memmove(&aLogFont.lfFaceName[0], &aLogFont.lfFaceName[1],
+                sizeof(aLogFont.lfFaceName)-sizeof(aLogFont.lfFaceName[0]));
+            hAltFont = CreateFontIndirectW(&aLogFont);
+        }
+    }
+
     do
     {
         nGlyphs = rLayout.GetNextGlyphs(1, glyphIntStr, *pPos, *pGetNextGlypInfo);
@@ -3125,10 +3141,12 @@ bool ExTextOutRenderer::operator ()(SalLayout const &rLayout, HDC hDC,
 
         if (SalLayout::UseCommonLayout())
         {
-            for (int i = 0; i < nGlyphs; i++)
+            bool bVertical = (glyphIntStr[0] & GF_ROTMASK) == GF_ROTL;
+
+            if (hAltFont && bVertical == bUseAltFont)
             {
-                if ((glyphIntStr[i] & GF_ROTMASK) == GF_ROTL)
-                    glyphIntStr[i] |= GF_VERT;
+                bUseAltFont = !bUseAltFont;
+                SelectFont(hDC, bUseAltFont ? hAltFont : hFont);
             }
         }
 
@@ -3136,6 +3154,12 @@ bool ExTextOutRenderer::operator ()(SalLayout const &rLayout, HDC hDC,
         ExtTextOutW(hDC, pPos->X(), pPos->Y(), ETO_GLYPH_INDEX, nullptr, LPCWSTR(&glyphWStr), nGlyphs, nullptr);
     } while (!pRectToErase);
 
+    if (hAltFont)
+    {
+        if (bUseAltFont)
+            SelectFont(hDC, hFont);
+        DeleteObject(hAltFont);
+    }
     return (pRectToErase && nGlyphs >= 1);
 }
 


More information about the Libreoffice-commits mailing list