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>
(cherry picked from commit 06cc40d87663cce8006d8b5fb0eb27777d51c749)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153341
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 86461d7..968a224 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -7077,11 +7077,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;
@@ -7092,13 +7101,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);