[Libreoffice-commits] core.git: vcl/win

Mark Hung marklh9 at gmail.com
Tue Feb 7 12:40:26 UTC 2017


 vcl/win/gdi/winlayout.cxx |   28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

New commits:
commit aa9251103a131880afa621501936603d8c75af9d
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.
    
    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>

diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index 6436c61..54c00af 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -291,14 +291,38 @@ bool ExTextOutRenderer::operator ()(SalLayout const &rLayout, HDC hDC,
 {
     bool bGlyphs = false;
     const GlyphItem* pGlyph;
+    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);
+        }
+    }
     while (rLayout.GetNextGlyphs(1, &pGlyph, *pPos, *pGetNextGlypInfo))
     {
         bGlyphs = true;
         WORD glyphWStr[] = { pGlyph->maGlyphId };
-        if (pGlyph->IsVertical())
-            glyphWStr[0] |= 0x02000000; // A (undocumented?) GDI flag for vertical glyphs
+        if (hAltFont && pGlyph->IsVertical() == bUseAltFont)
+        {
+            bUseAltFont = !bUseAltFont;
+            SelectFont(hDC, bUseAltFont ? hAltFont : hFont);
+        }
         ExtTextOutW(hDC, pPos->X(), pPos->Y(), ETO_GLYPH_INDEX, nullptr, LPCWSTR(&glyphWStr), 1, nullptr);
     }
+    if (hAltFont)
+    {
+        if (bUseAltFont)
+            SelectFont(hDC, hFont);
+        DeleteObject(hAltFont);
+    }
 
     return (pRectToErase && bGlyphs);
 }


More information about the Libreoffice-commits mailing list