r22622 by jghali - #15397, part 1: fix embedding of TrueType collection fonts in PDF
scribus-commit
scribus-commit at lists.scribus.net
Sun Aug 12 00:02:45 UTC 2018
Author: jghali
Date: Sun Aug 12 00:02:45 2018
New Revision: 22622
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22622
Log:
#15397, part 1: fix embedding of TrueType collection fonts in PDF
Modified:
branches/Version14x/Scribus/scribus/fonts/scface_ttf.cpp
branches/Version14x/Scribus/scribus/pdflib_core.cpp
Modified: branches/Version14x/Scribus/scribus/fonts/scface_ttf.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22622&path=/branches/Version14x/Scribus/scribus/fonts/scface_ttf.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/fonts/scface_ttf.cpp (original)
+++ branches/Version14x/Scribus/scribus/fonts/scface_ttf.cpp Sun Aug 12 00:02:45 2018
@@ -457,6 +457,14 @@
const unsigned char * pp = reinterpret_cast<const unsigned char*>(bb.data()) + pos;
return pp[0] << 8 | pp[1];
}
+void putWord(QByteArray & bb, uint pos, quint32 val)
+{
+ unsigned char * pp = reinterpret_cast<unsigned char*>(bb.data()) + pos;
+ *pp++ = (val >> 24) & 0xFF;
+ *pp++ = (val >> 16) & 0xFF;
+ *pp++ = (val >> 8) & 0xFF;
+ *pp++ = (val) & 0xFF;
+}
QString tag(QByteArray const & bb, uint pos)
{
char buf[5] = "1234";
@@ -563,10 +571,11 @@
uint tableStart = word(coll, faceOffset + OFFSET_TABLE_LEN + TDIR_ENTRY_LEN * i + 8);
sDebug(QObject::tr("table '%1'").arg(tag(coll, tableStart)));
sDebug(QObject::tr("memcpy table: %1 %2 %3").arg(pos).arg(tableStart).arg(tableSize));
- if (!copy(bb, pos, coll, tableStart, tableSize)) break;
+ if (!copy(bb, pos, coll, tableStart, tableSize))
+ break;
// write new offset to table entry
sDebug(QObject::tr("memcpy offset: %1 %2 %3").arg(OFFSET_TABLE_LEN + TDIR_ENTRY_LEN*i + 8).arg(pos).arg(4));
- memcpy(bb.data() + OFFSET_TABLE_LEN + TDIR_ENTRY_LEN * i + 8, &pos, 4);
+ putWord(bb, OFFSET_TABLE_LEN + TDIR_ENTRY_LEN * i + 8, pos);
pos += tableSize;
// pad
while ((pos & 3) != 0)
Modified: branches/Version14x/Scribus/scribus/pdflib_core.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22622&path=/branches/Version14x/Scribus/scribus/pdflib_core.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/pdflib_core.cpp (original)
+++ branches/Version14x/Scribus/scribus/pdflib_core.cpp Sun Aug 12 00:02:45 2018
@@ -1433,23 +1433,21 @@
}
if ((fformat == ScFace::SFNT || fformat == ScFace::TTCF) && (Options.EmbedList.contains(it.key())))
{
- QString fon("");
QByteArray bb;
embeddedFontObject = newObject();
StartObj(embeddedFontObject);
face.RawData(bb);
- //AV: += and append() dont't work because they stop at '\0' :-(
- for (int i=0; i < bb.size(); i++)
- fon += QChar(bb[i]);
- int len = fon.length();
+ int len = bb.length();
if (Options.Compress)
- fon = CompressStr(&fon);
+ bb = CompressArray(bb);
//qDebug() << QString("sfnt data: size=%1 before=%2 compressed=%3").arg(bb.size()).arg(len).arg(fon.length());
- PutDoc("<<\n/Length "+QString::number(fon.length()+1)+"\n");
+ PutDoc("<<\n/Length "+QString::number(bb.length()+1)+"\n");
PutDoc("/Length1 "+QString::number(len)+"\n");
if (Options.Compress)
PutDoc("/Filter /FlateDecode\n");
- PutDoc(">>\nstream\n"+EncStream(fon, embeddedFontObject)+"\nendstream\nendobj\n");
+ PutDoc(">>\nstream\n");
+ EncodeArrayToStream(bb, embeddedFontObject);
+ PutDoc("\nendstream\nendobj\n");
}
uint fontDescriptor = newObject();
StartObj(fontDescriptor);
More information about the scribus-commit
mailing list