tdf#115321: Fix PDF position of emphasis mark in vertical text
This aligns the code in PDF writer with
OutputDevice::ImplDrawEmphasisMarks().
Change-Id: I404beda30ff0eb1d6c59d971a7daa59b559ef70f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153326
Tested-by: Jenkins
Reviewed-by: خالد حسني <khaled@libreoffice.org>
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index e9e7e326..4ccbdc2 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -7046,11 +7046,20 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool
writeBuffer( aLine );
Point aOffset(0,0);
Point aOffsetVert(0,0);
if ( nEmphMark & FontEmphasisMark::PosBelow )
{
aOffset.AdjustY(GetFontInstance()->mxFontMetric->GetDescent() + aEmphasisMark.GetYOffset() );
aOffsetVert = aOffset;
}
else
{
aOffset.AdjustY( -(GetFontInstance()->mxFontMetric->GetAscent() + aEmphasisMark.GetYOffset()) );
// Todo: use ideographic em-box or ideographic character face information.
aOffsetVert.AdjustY(-(GetFontInstance()->mxFontMetric->GetAscent() +
GetFontInstance()->mxFontMetric->GetDescent() + aEmphasisMark.GetYOffset()));
}
tools::Long nEmphWidth2 = aEmphasisMark.GetWidth() / 2;
tools::Long nEmphHeight2 = nEmphHeight / 2;
@@ -7061,13 +7070,27 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool
else if ( eAlign == ALIGN_TOP )
aOffset.AdjustY(GetFontInstance()->mxFontMetric->GetAscent() );
tools::Rectangle aRectangle;
nIndex = 0;
while (rLayout.GetNextGlyph(&pGlyph, aPos, nIndex))
while (rLayout.GetNextGlyph(&pGlyph, aPos, nIndex, &pGlyphFont))
{
if (!pGlyph->GetGlyphBoundRect(pGlyphFont, aRectangle))
continue;
if (!pGlyph->IsSpacing())
{
DevicePoint aAdjOffset(aOffset.X(), aOffset.Y());
aAdjOffset.adjustX((pGlyph->newWidth() - aEmphasisMark.GetWidth()) / 2);
DevicePoint aAdjOffset;
if (pGlyph->IsVertical())
{
aAdjOffset = DevicePoint(aOffsetVert.X(), aOffsetVert.Y());
aAdjOffset.adjustX((-pGlyph->origWidth() + aEmphasisMark.GetWidth()) / 2);
}
else
{
aAdjOffset = DevicePoint(aOffset.X(), aOffset.Y());
aAdjOffset.adjustX(aRectangle.Left() + (aRectangle.GetWidth() - aEmphasisMark.GetWidth()) / 2 );
}
aAdjOffset = aRotScale.transform( aAdjOffset );
aAdjOffset -= DevicePoint(nEmphWidth2, nEmphHeight2);