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 <marklh9@gmail.com>
This commit is contained in:
Mark Hung
2023-03-10 12:42:39 +00:00
parent 57b88be1e1
commit 9e6ff03454
+21 -2
View File
@@ -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);