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: خالد حسني <khaled@libreoffice.org>
(cherry picked from commit c1dcffceb14cd35c7168ba2108b2f2e9aa875b56)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153997
Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 56d3db2..b690142 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");