r22098 by jghali -
scribus-commit
scribus-commit at lists.scribus.net
Tue Jul 4 22:25:03 UTC 2017
Author: jghali
Date: Tue Jul 4 22:25:03 2017
New Revision: 22098
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22098
Log:
reduce a bit exported PDFs size by setting current font and font size only when necessary
Modified:
trunk/Scribus/scribus/pdflib_core.cpp
Modified: trunk/Scribus/scribus/pdflib_core.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22098&path=/trunk/Scribus/scribus/pdflib_core.cpp
==============================================================================
--- trunk/Scribus/scribus/pdflib_core.cpp (original)
+++ trunk/Scribus/scribus/pdflib_core.cpp Tue Jul 4 22:25:03 2017
@@ -122,6 +122,9 @@
uint m_PNr;
const ScPage* m_page;
+ QByteArray m_prevFontName;
+ int m_prevFontSize;
+
QByteArray transformToStr(QTransform tr)
{
return FToStr(tr.m11()) + " " + FToStr(-tr.m12()) + " " + FToStr(-tr.m21()) + " " + FToStr(tr.m22()) + " " + FToStr(tr.dx()) + " " + FToStr(-tr.dy());
@@ -134,7 +137,8 @@
// m_item(ite),
m_pdf(pdf),
m_PNr(num),
- m_page(pag)
+ m_page(pag),
+ m_prevFontSize(-1)
{}
~PdfPainter() {}
@@ -196,10 +200,19 @@
break;
}
- if (fontNr == 65535)
- m_glyphBuffer += pdfFont.name + " " + FToStr(fontSize()) + " Tf\n";
- else
- m_glyphBuffer += pdfFont.name + "S" + Pdf::toPdf(fontNr) + " " + FToStr(fontSize()) + " Tf\n";
+ QByteArray pdfFontName = pdfFont.name;
+ if (fontNr != 65535)
+ {
+ pdfFontName += "S";
+ pdfFontName += Pdf::toPdf(fontNr);
+ }
+
+ if ((pdfFontName != m_prevFontName) || fontSize() != m_prevFontSize)
+ {
+ m_glyphBuffer += pdfFontName + " " + FToStr(fontSize()) + " Tf\n";
+ m_prevFontName = pdfFontName;
+ m_prevFontSize = fontSize();
+ }
if (!StrokeColor.isEmpty())
m_glyphBuffer += StrokeColor;
@@ -212,7 +225,6 @@
transform.translate(x() + gl.xoffset + current_x , y() + gl.yoffset);
transform.scale(qMax(gl.scaleH, 0.1), qMax(gl.scaleV, 0.1));
m_glyphBuffer += transformToStr(transform) + " Tm\n";
-
if (pdfFont.method != Use_Type3 || !FillColor.isEmpty())
{
@@ -333,10 +345,19 @@
break;
}
- if (fontNr == 65535)
- m_glyphBuffer += pdfFont.name + " " + FToStr(fontSize()) + " Tf\n";
- else
- m_glyphBuffer += pdfFont.name + "S" + Pdf::toPdf(fontNr) + " " + FToStr(fontSize()) + " Tf\n";
+ QByteArray pdfFontName = pdfFont.name;
+ if (fontNr != 65535)
+ {
+ pdfFontName += "S";
+ pdfFontName += Pdf::toPdf(fontNr);
+ }
+
+ if ((pdfFontName != m_prevFontName) || fontSize() != m_prevFontSize)
+ {
+ m_glyphBuffer += pdfFontName + " " + FToStr(fontSize()) + " Tf\n";
+ m_prevFontName = pdfFontName;
+ m_prevFontSize = fontSize();
+ }
if (!StrokeColor.isEmpty())
m_glyphBuffer += StrokeColor;
@@ -478,6 +499,8 @@
m_glyphBuffer += m_pathBuffer+"\n";
m_pathBuffer = "";
+ m_prevFontName.clear();
+ m_prevFontSize = -1;
m_glyphBuffer += "BT\n";
}
};
More information about the scribus-commit
mailing list