vcl/source/gdi/pdfwriter_impl.cxx |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

New commits:
commit ef155fcf7bb78a2788f66cad3d6008b9203f5a32
Author:     Khaled Hosny <kha...@libreoffice.org>
AuthorDate: Tue Jul 4 15:49:35 2023 +0000
Commit:     Adolfo Jayme Barrientos <fit...@ubuntu.com>
CommitDate: Wed Jul 5 01:20:58 2023 +0200

    tdf#156151: Take PDF DPI into account when outputting Type 3 glyphs
    
    We were always assuming the default 720 DPI, but this is not always true
    when printing to file as the DPI would depend on printer settings in
    this case.
    
    Change-Id: I747f8e24f0942ecb94eb8acfc1dd9972d83ba0e3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153978
    Tested-by: Jenkins
    Reviewed-by: خالد حسني <kha...@libreoffice.org>
    (cherry picked from commit c1dcffceb14cd35c7168ba2108b2f2e9aa875b56)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153997
    Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com>

diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index 56d3db20716c..b6901420bddf 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -2673,6 +2673,10 @@ bool PDFWriterImpl::emitType3Font(const 
vcl::font::PhysicalFontFace* pFace,
         ResourceDict aResourceDict;
         std::list<StreamRedirect> aOutputStreams;
 
+        // Scale for glyph outlines.
+        double fScaleX = GetDPIX() / 72.;
+        double fScaleY = GetDPIY() / 72.;
+
         for (auto i = 1u; i < nGlyphs; i++)
         {
             auto nStream = pGlyphStreams[i];
@@ -2753,9 +2757,12 @@ bool PDFWriterImpl::emitType3Font(const 
vcl::font::PhysicalFontFace* pFace,
             const auto& rOutline = rGlyph.getOutline();
             if (rOutline.count())
             {
-                // XXX I have no idea why this transformation matrix is needed.
-                aContents.append("q 10 0 0 10 0 ");
-                appendDouble(m_aPages.back().getHeight() * -10, aContents, 3);
+                aContents.append("q ");
+                appendDouble(fScaleX, aContents);
+                aContents.append(" 0 0 ");
+                appendDouble(fScaleY, aContents);
+                aContents.append(" 0 ");
+                appendDouble(m_aPages.back().getHeight() * -fScaleY, 
aContents, 3);
                 aContents.append(" cm\n");
                 m_aPages.back().appendPolyPolygon(rOutline, aContents);
                 aContents.append("f\n");

Reply via email to