vcl/win/window/salframe.cxx |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

New commits:
commit 64f383d7ef8a46053f318515f200d4b85883e500
Author:     Jonathan Clark <jonat...@libreoffice.org>
AuthorDate: Mon May 26 14:51:53 2025 -0600
Commit:     Adolfo Jayme Barrientos <fit...@ubuntu.com>
CommitDate: Tue May 27 21:33:37 2025 +0200

    tdf#147299 vcl: Set Microsoft ja IME to vertical mode in vertical text
    
    Fixes a Windows IME integration bug causing the Microsoft Japanese IME
    to display inappropriately rotated text or overlap the composition
    string when the text direction is vertical.
    
    Windows IMEs do not expose an explicit option to enable vertical
    writing. Instead, this mode is set by providing a font face with a
    leading '@' sign. This behavior is not documented, but is long-standing
    and is the standard convention on Windows in other contexts.
    
    Change-Id: I9ebe45cf2c48b5f175d369daaa891f86fdc77c27
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185870
    Tested-by: Jenkins
    Reviewed-by: Jonathan Clark <jonat...@libreoffice.org>
    (cherry picked from commit a7f0e7b40fff2238a5cb2bfac750b22d8d5ee15d)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185921
    Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com>

diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx
index 2cc6e2998d1b..a73b764ee84a 100644
--- a/vcl/win/window/salframe.cxx
+++ b/vcl/win/window/salframe.cxx
@@ -2231,6 +2231,22 @@ static void ImplSalFrameSetInputContext( HWND hWnd, 
const SalInputContext* pCont
                 LOGFONTW aLogFont;
                 
ImplGetLogFontFromFontSelect(pContext->mpFont->GetFontSelectPattern(),
                                              nullptr, aLogFont, true);
+
+                // tdf#147299: To enable vertical input mode, Windows IMEs 
check the face
+                // name string for a leading '@'.
+                SalExtTextInputPosEvent aPosEvt;
+                pFrame->CallCallback(SalEvent::ExtTextInputPos, &aPosEvt);
+                if (aPosEvt.mbVertical)
+                {
+                    std::array<WCHAR, LF_FACESIZE> aTmpFaceName;
+                    std::copy(aLogFont.lfFaceName, aLogFont.lfFaceName + 
LF_FACESIZE,
+                              aTmpFaceName.begin());
+                    aLogFont.lfFaceName[0] = L'@';
+                    std::copy(aTmpFaceName.begin(), aTmpFaceName.end() - 1,
+                              aLogFont.lfFaceName + 1);
+                    aLogFont.lfFaceName[LF_FACESIZE - 1] = L'
+                }
+
                 ImmSetCompositionFontW( hIMC, &aLogFont );
                 ImmReleaseContext( pFrame->mhWnd, hIMC );
             }

Reply via email to