vcl/source/outdev/font.cxx |   23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

New commits:
commit 6de58389343d40ea9e638423967b9a845c7ef0d9
Author:     Mark Hung <mark...@gmail.com>
AuthorDate: Mon Feb 27 08:58:22 2023 +0800
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Thu Mar 16 09:21:29 2023 +0000

    tdf#114556 fix vertical writing emphasis mark position.
    
    1. Calculate emphasis mark offset from base line using
    ascender + descender, so it won't be too close or even overlap
    with the glyph. It's an approximate for ideographic embox right
    or ideographic chraceter face right.
    
    2. CJK Ideographs have different drawing base positions.
    Besides, it seems that glyph bound rect isn't consistent among
    platforms, so use glyph advance information ( pGlyph->origWidth )
    to calculate proper position and center the emphasis mark along
    glyph advance axis.
    
    Change-Id: I93676656ed2a1b12a2237a9af94d772879eb7ff7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147748
    Tested-by: Jenkins
    Reviewed-by: Mark Hung <mark...@gmail.com>
    (cherry picked from commit 9e6ff03454c2c554fc81b5f5d453a02edd5245d1)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148862
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx
index 5014800fa2c6..6e8db56e06a3 100644
--- a/vcl/source/outdev/font.cxx
+++ b/vcl/source/outdev/font.cxx
@@ -931,11 +931,20 @@ void OutputDevice::ImplDrawEmphasisMarks( SalLayout& 
rSalLayout )
     }
 
     Point aOffset(0,0);
+    Point aOffsetVert(0,0);
 
     if ( nEmphasisMark & FontEmphasisMark::PosBelow )
+    {
         aOffset.AdjustY(mpFontInstance->mxFontMetric->GetDescent() + 
aEmphasisMark.GetYOffset());
+        aOffsetVert = aOffset;
+    }
     else
+    {
         aOffset.AdjustY(-(mpFontInstance->mxFontMetric->GetAscent() + 
aEmphasisMark.GetYOffset()));
+        // Todo: use ideographic em-box or ideographic character face 
information.
+        aOffsetVert.AdjustY(-(mpFontInstance->mxFontMetric->GetAscent() +
+                    mpFontInstance->mxFontMetric->GetDescent() + 
aEmphasisMark.GetYOffset()));
+    }
 
     tools::Long nEmphasisWidth2  = aEmphasisMark.GetWidth() / 2;
     tools::Long nEmphasisHeight2 = nEmphasisHeight / 2;
@@ -953,8 +962,18 @@ void OutputDevice::ImplDrawEmphasisMarks( SalLayout& 
rSalLayout )
 
         if (!pGlyph->IsSpacing())
         {
-            Point aAdjPoint = aOffset;
-            aAdjPoint.AdjustX(aRectangle.Left() + (aRectangle.GetWidth() - 
aEmphasisMark.GetWidth()) / 2 );
+            Point aAdjPoint;
+            if (pGlyph->IsVertical())
+            {
+                aAdjPoint = aOffsetVert;
+                aAdjPoint.AdjustX((-pGlyph->origWidth() + 
aEmphasisMark.GetWidth()) / 2);
+            }
+            else
+            {
+                aAdjPoint = aOffset;
+                aAdjPoint.AdjustX(aRectangle.Left() + (aRectangle.GetWidth() - 
aEmphasisMark.GetWidth()) / 2 );
+            }
+
             if ( mpFontInstance->mnOrientation )
             {
                 Point aOriginPt(0, 0);

Reply via email to