r24468 by jghali - PDF: subset CID-keyed OpenType fonts as CFF for PDF < 1.6 (requires Harfbuzz >= 2.0)

scribus-commit scribus-commit at lists.scribus.net
Wed Feb 10 22:59:41 UTC 2021


Author: jghali
Date: Wed Feb 10 22:59:41 2021
New Revision: 24468

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24468
Log:
PDF: subset CID-keyed OpenType fonts as CFF for PDF < 1.6 (requires Harfbuzz >= 2.0)

Modified:
    trunk/Scribus/scribus/pdflib_core.cpp

Modified: trunk/Scribus/scribus/pdflib_core.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24468&path=/trunk/Scribus/scribus/pdflib_core.cpp
==============================================================================
--- trunk/Scribus/scribus/pdflib_core.cpp	(original)
+++ trunk/Scribus/scribus/pdflib_core.cpp	Wed Feb 10 22:59:41 2021
@@ -2243,11 +2243,25 @@
 		return result;
 	}
 
+	QByteArray subType = "/OpenType";
+	if (!Options.supportsEmbeddedOpenTypeFonts())
+	{
+		QByteArray cffData = sfnt::getTable(subset, "CFF ");
+		QByteArray cffSubset(cffData.data(), cffData.length());
+		if (cffSubset.isEmpty())
+		{
+			PdfFont result = PDF_WriteType3Font(fontName, face, usedGlyphs);
+			return result;
+		}
+		subset = cffSubset;
+		subType = "/CIDFontType0C";
+	}
+
 	/*dumpFont(face.psName() + "subs.otf", subset);*/
 	QByteArray baseFont   = sanitizeFontName(face.psName());
 	QByteArray subsetTag  = PDF_GenerateSubsetTag(baseFont, glyphs);
 	QByteArray subsetName = subsetTag + '+' + baseFont;
-	PdfId embeddedFontObj = PDF_EmbedFontObject(subset, "/OpenType");
+	PdfId embeddedFontObj = PDF_EmbedFontObject(subset, subType);
 	PdfId fontDes = PDF_WriteFontDescriptor(subsetName, face, face.format(), embeddedFontObj);
 	
 	PdfFont result = PDF_EncodeCidFont(fontName, face, subsetName, fontDes, usedGlyphs, glyphMap);
@@ -2417,7 +2431,7 @@
 					{
 						pdfFont = PDF_WriteTtfSubsetFont(fontName, face, usedGlyphs);
 					}
-					else if (face.type() == ScFace::OTF && face.isCIDKeyed() && Options.supportsEmbeddedOpenTypeFonts() && sfnt::canSubsetOpenTypeFonts())
+					else if (face.type() == ScFace::OTF && face.isCIDKeyed() && sfnt::canSubsetOpenTypeFonts())
 					{
 						pdfFont = PDF_WriteOpenTypeSubsetFont(fontName, face, usedGlyphs);
 					}




More information about the scribus-commit mailing list