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

New commits:
commit fe2c0663436879b2d562f0c921da3f844017d85a
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:43 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 4b05805df02eadd920e808c8f82dbfd1038b4be8)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153996
    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 432f25b04ba1..b5653748ac8e 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -2649,6 +2649,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];
@@ -2731,9 +2735,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