r21759 by jghali - fix FontName key in font descriptors

scribus-commit scribus-commit at lists.scribus.net
Fri Feb 10 03:32:13 UTC 2017


Author: jghali
Date: Fri Feb 10 03:32:13 2017
New Revision: 21759

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21759
Log:
fix FontName key in font descriptors
per PDF specs it should be the same as the value of BaseFont in the font or CIDFont dictionary that refers to this font descriptor

Modified:
    trunk/Scribus/scribus/pdflib_core.cpp

Modified: trunk/Scribus/scribus/pdflib_core.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21759&path=/trunk/Scribus/scribus/pdflib_core.cpp
==============================================================================
--- trunk/Scribus/scribus/pdflib_core.cpp	(original)
+++ trunk/Scribus/scribus/pdflib_core.cpp	Fri Feb 10 03:32:13 2017
@@ -1789,7 +1789,7 @@
 	writer.startObj(fontObject2);
 	PutDoc("<<\n/Type /Font\n/Subtype /Type0\n");
 	PutDoc("/Name " + Pdf::toName(fontName) + "\n");
-	PutDoc("/BaseFont "+ baseFont +"\n");
+	PutDoc("/BaseFont "+ Pdf::toName(baseFont) +"\n");
 	PutDoc("/Encoding /Identity-H\n");
 	PutDoc("/ToUnicode "+Pdf::toPdf(fontToUnicode2)+" 0 R\n");
 	PutDoc("/DescendantFonts [");
@@ -1798,7 +1798,7 @@
 		PutDoc("/Subtype /CIDFontType0");
 	else
 		PutDoc("/Subtype /CIDFontType2");
-	PutDoc("/BaseFont " + baseFont);
+	PutDoc("/BaseFont " + Pdf::toName(baseFont));
 	PutDoc("/FontDescriptor " + Pdf::toPdf(fontDes)+ " 0 R");
 	PutDoc("/CIDSystemInfo <</Ordering(Identity)/Registry(Adobe)/Supplement 0>>");
 	PutDoc("/DW 1000");
@@ -1940,7 +1940,7 @@
 		PutDoc("<<\n/Type /Font\n/Subtype ");
 		PutDoc(subtype + "\n");
 		PutDoc("/Name "+Pdf::toName(fontName)+"S"+Pdf::toPdf(Fc)+"\n");
-		PutDoc("/BaseFont "+baseFont+"\n");
+		PutDoc("/BaseFont "+ Pdf::toName(baseFont) + "\n");
 		PutDoc("/FirstChar 0\n");
 		PutDoc("/LastChar "+Pdf::toPdf(chCount-1)+"\n");
 		PutDoc("/Widths "+Pdf::toPdf(fontWidths2)+" 0 R\n");
@@ -1980,8 +1980,8 @@
 	writer.startObj(fontObjectForm);
 	PutDoc("<<\n/Type /Font\n/Subtype ");
 	PutDoc(subtype + "\n");
-	PutDoc("/Name " + formFont.name+ "\n");
-	PutDoc("/BaseFont "+Pdf::toName(sanitizeFontName(face.psName()))+"\n");
+	PutDoc("/Name " + formFont.name + "\n");
+	PutDoc("/BaseFont "+ Pdf::toName(baseFont) +"\n");
 	PutDoc("/Encoding << \n");
 	PutDoc("/Differences [ \n");
 	PutDoc("24 /breve /caron /circumflex /dotaccent /hungarumlaut /ogonek /ring /tilde\n");
@@ -2045,7 +2045,7 @@
 	/*dumpFont(face.psName()+"subs.ttf", subset);*/
 	PdfId embeddedFontObj = PDF_EmbedFontObject(subset, QByteArray());
 	PdfId fontDes = PDF_WriteFontDescriptor(fontName, face, face.format(), embeddedFontObj);
-	QByteArray baseFont = Pdf::toName(sanitizeFontName(face.psName()));
+	QByteArray baseFont = sanitizeFontName(face.psName());
 	ScFace::FaceEncoding fullEncoding, subEncoding;
 	QMap<uint,uint> glyphmap;
 	face.glyphNames(fullEncoding);
@@ -2086,7 +2086,7 @@
 	/*dumpFont(face.psName()+"subs.cff", subset);*/
 	PdfId embeddedFontObj = PDF_EmbedFontObject(subset, "/CIDFontType0C");
 	PdfId fontDes = PDF_WriteFontDescriptor(fontName, face, face.format(), embeddedFontObj);
-	QByteArray baseFont = Pdf::toName(sanitizeFontName(face.psName()));
+	QByteArray baseFont = sanitizeFontName(face.psName());
 	ScFace::FaceEncoding fullEncoding, subEncoding;
 	QMap<uint,uint> glyphmap;
 	face.glyphNames(fullEncoding);
@@ -2280,7 +2280,8 @@
 			{
 				PdfId embeddedFontObject = PDF_EmbedFontObject(it.key(), face);
 				
-				PdfId fontDescriptor = PDF_WriteFontDescriptor(fontName, face, fformat, embeddedFontObject);
+				QByteArray baseFont  = sanitizeFontName(face.psName());
+				PdfId fontDescriptor = PDF_WriteFontDescriptor(baseFont, face, fformat, embeddedFontObject);
 				
 				ScFace::FaceEncoding gl;
 				face.glyphNames(gl);
@@ -2303,7 +2304,6 @@
 					}
 				}
 				
-				QByteArray baseFont = Pdf::toName(sanitizeFontName(face.psName()));
 				QByteArray subtype = (fformat == ScFace::SFNT || fformat == ScFace::TTCF) ? "/TrueType" : "/Type1";
 				
 				if ((face.isSymbolic() || !hasNeededGlyphNames || Options.Version == PDFOptions::PDFVersion_X4 || face.type() == ScFace::OTF) &&




More information about the scribus-commit mailing list