diff options
author | Mark Hung <marklh9@gmail.com> | 2023-02-27 08:58:22 +0800 |
---|---|---|
committer | Mark Hung <marklh9@gmail.com> | 2023-03-10 12:42:39 +0000 |
commit | 9e6ff03454c2c554fc81b5f5d453a02edd5245d1 (patch) | |
tree | 278a330c7144886f65b65b1e97e1d1c7af6ca65f /vcl/source/outdev/font.cxx | |
parent | 57b88be1e10e131aea429e205fd426b7dab2ba2d (diff) |
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>
Diffstat (limited to 'vcl/source/outdev/font.cxx')
-rw-r--r-- | vcl/source/outdev/font.cxx | 23 |
1 files changed, 21 insertions, 2 deletions
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); |