vcl/inc/win/salgdi.h        |    2 -
 vcl/win/gdi/salfont.cxx     |   30 ++--------------------------
 vcl/win/gdi/winlayout.cxx   |   46 ++++----------------------------------------
 vcl/win/window/salframe.cxx |   12 -----------
 4 files changed, 10 insertions(+), 80 deletions(-)

New commits:
commit 5686c1aca40beb9514d40c86b4a3780a8a1334ba
Author:     Mark Hung <mark...@gmail.com>
AuthorDate: Sun May 2 14:45:45 2021 +0800
Commit:     Mark Hung <mark...@gmail.com>
CommitDate: Mon May 10 21:14:09 2021 +0200

    vcl: use DWriteTextRenderer for vertical writing.
    
    It's really not possible to support vertical writing with old
    ExTextOutW API, use DWriteTextRenderer in this case. This also get rid of
    the hacks to prepend '@' in front of the font name when it's for vertical
    writing.
    
    Change-Id: Icf594dd248be35fb101d6c1e296971f1acf56e39
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115017
    Tested-by: Jenkins
    Reviewed-by: Mark Hung <mark...@gmail.com>

diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index 21f1b46ec016..959d8abc0301 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -392,7 +392,7 @@ public:
 // Init/Deinit Graphics
 void    ImplUpdateSysColorEntries();
 int     ImplIsSysColorEntry( Color nColor );
-void    ImplGetLogFontFromFontSelect( HDC, const FontSelectPattern&,
+void    ImplGetLogFontFromFontSelect( const FontSelectPattern&,
             const PhysicalFontFace*, LOGFONTW& );
 
 #define MAX_64KSALPOINTS    ((((sal_uInt16)0xFFFF)-8)/sizeof(POINTS))
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index 39f67e26a057..473f743d3cee 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -195,7 +195,7 @@ bool 
WinGlyphFallbackSubstititution::HasMissingChars(PhysicalFontFace* pFace, OU
         const FontSelectPattern aFSD( *pFace, aSize, 
static_cast<float>(aSize.Height()), 0, false );
         // construct log font
         LOGFONTW aLogFont;
-        ImplGetLogFontFromFontSelect( mhDC, aFSD, pFace, aLogFont );
+        ImplGetLogFontFromFontSelect( aFSD, pFace, aLogFont );
 
         // create HFONT from log font
         HFONT hNewFont = ::CreateFontIndirectW( &aLogFont );
@@ -768,8 +768,7 @@ static int CALLBACK SalEnumQueryFontProcExW( const 
LOGFONTW*,
     return 0;
 }
 
-void ImplGetLogFontFromFontSelect( HDC hDC,
-                                   const FontSelectPattern& rFont,
+void ImplGetLogFontFromFontSelect( const FontSelectPattern& rFont,
                                    const PhysicalFontFace* pFontFace,
                                    LOGFONTW& rLogFont )
 {
@@ -816,29 +815,6 @@ void ImplGetLogFontFromFontSelect( HDC hDC,
     if ( rFont.mbNonAntialiased )
         rLogFont.lfQuality = NONANTIALIASED_QUALITY;
 
-    // select vertical mode if requested and available
-    if ( rFont.mbVertical && nNameLen )
-    {
-        // vertical fonts start with an '@'
-        memmove( &rLogFont.lfFaceName[1], &rLogFont.lfFaceName[0],
-            sizeof(rLogFont.lfFaceName)-sizeof(rLogFont.lfFaceName[0]) );
-        rLogFont.lfFaceName[0] = '@';
-
-        // check availability of vertical mode for this font
-        bool bAvailable = false;
-        EnumFontFamiliesExW( hDC, &rLogFont, SalEnumQueryFontProcExW,
-                         reinterpret_cast<LPARAM>(&bAvailable), 0 );
-
-        if( !bAvailable )
-        {
-            // restore non-vertical name if not vertical mode isn't available
-            memcpy( &rLogFont.lfFaceName[0], aName.getStr(), 
nNameLen*sizeof(wchar_t) );
-            rLogFont.lfFaceName[nNameLen] = '\0';
-            // keep it upright and create the font for sideway glyphs later.
-            rLogFont.lfEscapement = rLogFont.lfEscapement - 2700;
-            rLogFont.lfOrientation = rLogFont.lfEscapement;
-        }
-    }
 }
 
 HFONT WinSalGraphics::ImplDoSetFont(FontSelectPattern const & i_rFont,
@@ -848,7 +824,7 @@ HFONT WinSalGraphics::ImplDoSetFont(FontSelectPattern const 
& i_rFont,
     HFONT hNewFont = nullptr;
 
     LOGFONTW aLogFont;
-    ImplGetLogFontFromFontSelect( getHDC(), i_rFont, i_pFontFace, aLogFont );
+    ImplGetLogFontFromFontSelect( i_rFont, i_pFontFace, aLogFont );
 
     hNewFont = ::CreateFontIndirectW( &aLogFont );
 
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index 0f82d1af5bc6..c0fe1e32b863 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -80,53 +80,13 @@ TextOutRenderer& TextOutRenderer::get(bool bUseDWrite)
 bool ExTextOutRenderer::operator()(GenericSalLayout const& rLayout, 
SalGraphics& /*rGraphics*/,
                                    HDC hDC)
 {
-    HFONT hFont = static_cast<HFONT>(GetCurrentObject(hDC, OBJ_FONT));
-    ScopedHFONT hAltFont;
-    bool bUseAltFont = false;
-    bool bShift = false;
-    if (rLayout.GetFont().GetFontSelectPattern().mbVertical)
-    {
-        LOGFONTW aLogFont;
-        GetObjectW(hFont, sizeof(aLogFont), &aLogFont);
-        if (aLogFont.lfFaceName[0] == '@')
-        {
-            memmove(&aLogFont.lfFaceName[0], &aLogFont.lfFaceName[1],
-                    sizeof(aLogFont.lfFaceName) - 
sizeof(aLogFont.lfFaceName[0]));
-            hAltFont.reset(CreateFontIndirectW(&aLogFont));
-        }
-        else
-        {
-            bShift = true;
-            aLogFont.lfEscapement += 2700;
-            aLogFont.lfOrientation = aLogFont.lfEscapement;
-            hAltFont.reset(CreateFontIndirectW(&aLogFont));
-        }
-    }
-
-    UINT nTextAlign = GetTextAlign(hDC);
     int nStart = 0;
     Point aPos(0, 0);
     const GlyphItem* pGlyph;
     while (rLayout.GetNextGlyph(&pGlyph, aPos, nStart))
     {
         wchar_t glyphWStr = pGlyph->glyphId();
-        if (hAltFont && pGlyph->IsVertical() == bUseAltFont)
-        {
-            bUseAltFont = !bUseAltFont;
-            SelectFont(hDC, bUseAltFont ? hAltFont.get() : hFont);
-        }
-        if (bShift && pGlyph->IsVertical())
-            SetTextAlign(hDC, TA_TOP | TA_LEFT);
-
         ExtTextOutW(hDC, aPos.X(), aPos.Y(), ETO_GLYPH_INDEX, nullptr, 
&glyphWStr, 1, nullptr);
-
-        if (bShift && pGlyph->IsVertical())
-            SetTextAlign(hDC, nTextAlign);
-    }
-    if (hAltFont)
-    {
-        if (bUseAltFont)
-            SelectFont(hDC, hFont);
     }
 
     return true;
@@ -320,7 +280,11 @@ void WinSalGraphics::DrawTextLayout(const 
GenericSalLayout& rLayout)
     const HFONT hLayoutFont = pWinFont->GetHFONT();
 
     const HFONT hOrigFont = ::SelectFont(hDC, hLayoutFont);
-    DrawTextLayout(rLayout, hDC, false);
+
+    // There isnt' a way for Win32 API ExtTextOutW to render vertical-writing 
glyphs correctly,
+    // so let's use DWrite text renderer in this case.
+    DrawTextLayout(rLayout, hDC, 
rLayout.GetFont().GetFontSelectPattern().mbVertical);
+
     ::SelectFont(hDC, hOrigFont);
 }
 
diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx
index eea2ecd340c6..c87e290bdad2 100644
--- a/vcl/win/window/salframe.cxx
+++ b/vcl/win/window/salframe.cxx
@@ -2226,18 +2226,8 @@ static void ImplSalFrameSetInputContext( HWND hWnd, 
const SalInputContext* pCont
             if ( hIMC )
             {
                 LOGFONTW aLogFont;
-                HDC hDC = GetDC( pFrame->mhWnd );
-                // In case of vertical writing, always append a '@' to the
-                // Windows font name, not only if such a Windows font really is
-                // available (bTestVerticalAvail == false in the below call):
-                // The Windows IME's candidates window seems to always use a
-                // font that has all necessary glyphs, not necessarily the one
-                // specified by this font name; but it seems to decide whether
-                // to use that font's horizontal or vertical variant based on a
-                // '@' in front of this font name.
-                ImplGetLogFontFromFontSelect(hDC, 
pContext->mpFont->GetFontSelectPattern(),
+                
ImplGetLogFontFromFontSelect(pContext->mpFont->GetFontSelectPattern(),
                                              nullptr, aLogFont);
-                ReleaseDC( pFrame->mhWnd, hDC );
                 ImmSetCompositionFontW( hIMC, &aLogFont );
                 ImmReleaseContext( pFrame->mhWnd, hIMC );
             }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to