r19360 by jghali - #12462: Encoding error in PDF with Symbol font

scribus-commit scribus-commit at lists.scribus.net
Mon Jul 21 20:05:23 UTC 2014


Author: jghali
Date: Mon Jul 21 20:05:23 2014
New Revision: 19360

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19360
Log:
#12462: Encoding error in PDF with Symbol font

Modified:
    trunk/Scribus/scribus/fonts/ftface.h
    trunk/Scribus/scribus/fonts/scface.cpp
    trunk/Scribus/scribus/fonts/scface.h
    trunk/Scribus/scribus/fonts/scface_ttf.cpp
    trunk/Scribus/scribus/fonts/scface_ttf.h
    trunk/Scribus/scribus/fonts/scfontmetrics.cpp
    trunk/Scribus/scribus/pdflib_core.cpp

Modified: trunk/Scribus/scribus/fonts/ftface.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19360&path=/trunk/Scribus/scribus/fonts/ftface.h
==============================================================================
--- trunk/Scribus/scribus/fonts/ftface.h (original)
+++ trunk/Scribus/scribus/fonts/ftface.h Mon Jul 21 20:05:23 2014
@@ -74,7 +74,7 @@
 	QString pdfDescentAsString()     const { return m_pdfDescender; }
 	QString pdfCapHeightAsString()   const { return m_pdfCapHeight; }
 	QString pdfFontBBoxAsString()    const { return m_pdfFontBBox; }
-	QString ItalicAngleAsString()    const { return m_italicAngle; }
+	QString italicAngleAsString()    const { return m_italicAngle; }
 
 
 //FIXME	QMap<QString,QString> fontDictionary(qreal sz=1.0)      const;

Modified: trunk/Scribus/scribus/fonts/scface.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19360&path=/trunk/Scribus/scribus/fonts/scface.cpp
==============================================================================
--- trunk/Scribus/scribus/fonts/scface.cpp (original)
+++ trunk/Scribus/scribus/fonts/scface.cpp Mon Jul 21 20:05:23 2014
@@ -201,6 +201,14 @@
 	return NONE; 
 }
 
+bool ScFace::isSymbolic() const
+{
+	if (m->status == ScFace::UNKNOWN) {
+		m->load();
+	}
+	return m->isSymbolic();
+}
+
 QString ScFace::pdfAscentAsString() const
 {
 	if (m->status == ScFace::UNKNOWN) {
@@ -237,7 +245,7 @@
 	if (m->status == ScFace::UNKNOWN) {
 		m->load();
 	}
-	return m->ItalicAngleAsString();
+	return m->italicAngleAsString();
 }
 
 qreal ScFace::ascent(qreal sz) const 

Modified: trunk/Scribus/scribus/fonts/scface.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19360&path=/trunk/Scribus/scribus/fonts/scface.h
==============================================================================
--- trunk/Scribus/scribus/fonts/scface.h (original)
+++ trunk/Scribus/scribus/fonts/scface.h Mon Jul 21 20:05:23 2014
@@ -164,7 +164,7 @@
 		virtual QString pdfDescentAsString()     const { return "0"; }
 		virtual QString pdfCapHeightAsString()   const { return "0"; }
 		virtual QString pdfFontBBoxAsString()    const { return "0 0 0 0"; }
-		virtual QString ItalicAngleAsString()    const { return "0"; }
+		virtual QString italicAngleAsString()    const { return "0"; }
 		virtual qreal descent(qreal /*sz*/)      const { return 0.0; }
 		virtual qreal xHeight(qreal sz)          const { return sz; }
 		virtual qreal capHeight(qreal sz)        const { return sz; }
@@ -186,6 +186,7 @@
 		virtual FPointArray glyphOutline(uint gl, qreal sz) const; 
 		virtual FPoint      glyphOrigin (uint gl, qreal sz) const;
 
+		virtual bool isSymbolic() const { return false; }
 	};
 
 
@@ -199,6 +200,9 @@
 
 	/// test for null object
 	bool isNone() const   { return m->status == NULLFACE; }
+
+	/// test if font is a symbolic font
+	bool isSymbolic() const;
 
 	ScFace& operator=(const ScFace& other);
 	/** two ScFaces are equal if they either are both NULLFACEs or they

Modified: trunk/Scribus/scribus/fonts/scface_ttf.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19360&path=/trunk/Scribus/scribus/fonts/scface_ttf.cpp
==============================================================================
--- trunk/Scribus/scribus/fonts/scface_ttf.cpp (original)
+++ trunk/Scribus/scribus/fonts/scface_ttf.cpp Mon Jul 21 20:05:23 2014
@@ -500,6 +500,13 @@
 		delete kernFeature;
 }
 
+bool ScFace_ttf::isSymbolic() const
+{
+	FT_Face face = ftFace();
+	if (!face || !face->charmap)
+		return false;
+	return (m_face->charmap->encoding == FT_ENCODING_MS_SYMBOL);
+}
 
 void ScFace_ttf::load() const
 {

Modified: trunk/Scribus/scribus/fonts/scface_ttf.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19360&path=/trunk/Scribus/scribus/fonts/scface_ttf.h
==============================================================================
--- trunk/Scribus/scribus/fonts/scface_ttf.h (original)
+++ trunk/Scribus/scribus/fonts/scface_ttf.h Mon Jul 21 20:05:23 2014
@@ -98,6 +98,8 @@
 
 	qreal glyphKerning ( uint gl1, uint gl2, qreal sz ) const;
 
+	virtual bool isSymbolic() const;
+
 private:
 	mutable KernFeature * kernFeature;
 };

Modified: trunk/Scribus/scribus/fonts/scfontmetrics.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19360&path=/trunk/Scribus/scribus/fonts/scfontmetrics.cpp
==============================================================================
--- trunk/Scribus/scribus/fonts/scfontmetrics.cpp (original)
+++ trunk/Scribus/scribus/fonts/scfontmetrics.cpp Mon Jul 21 20:05:23 2014
@@ -113,8 +113,7 @@
 		//FT_Set_Charmap(face, face->charmaps[chmapUniCode]);
 		retVal = 0;
 	}
-	else
-	if (foundEncoding)
+	else if (foundEncoding)
 	{
 //		qDebug() << "using special enc for" << face->family_name << face->style_name;
 		mapToSet=chmapCustom;
@@ -139,7 +138,7 @@
 		gindex = 0;
 		int countCurrMap=0;
 		charcode = FT_Get_First_Char( face, &gindex );
-		while ( gindex != 0 )
+		while (gindex != 0)
 		{
 			countCurrMap++;
 			charcode = FT_Get_Next_Char( face, charcode, &gindex );
@@ -147,16 +146,14 @@
 		//If the last Unicode map we found before has more characters,
 		//then set it to be the current map.
 		
-		if (countUniCode>countCurrMap)
+		if (countUniCode > countCurrMap)
 		{
 //			qDebug() << "override with Unicode enc for" << face->family_name << face->style_name << "map" << mapToSet << "has only" << countCurrMap << "glyphs";
-			mapToSet=chmapUniCode;
-			//FT_Set_Charmap(face, face->charmaps[chmapUniCode]);
+			mapToSet = chmapUniCode;
 			retVal = 0;
 		}
 	}
-//	if (face->charmap == NULL || mapToSet!=FT_Get_Charmap_Index(face->charmap))
-		FT_Set_Charmap(face, face->charmaps[mapToSet]);
+	FT_Set_Charmap(face, face->charmaps[mapToSet]);
 //	qDebug() << "set map" << mapToSet << "for" << face->family_name << face->style_name;
 //	qDebug() << "glyphsForNumbers 0-9:" << FT_Get_Char_Index(face, QChar('0').unicode()) 
 //		<< FT_Get_Char_Index(face, QChar('1').unicode()) << FT_Get_Char_Index(face, QChar('2').unicode()) << FT_Get_Char_Index(face, QChar('3').unicode()) 

Modified: trunk/Scribus/scribus/pdflib_core.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19360&path=/trunk/Scribus/scribus/pdflib_core.cpp
==============================================================================
--- trunk/Scribus/scribus/pdflib_core.cpp (original)
+++ trunk/Scribus/scribus/pdflib_core.cpp Mon Jul 21 20:05:23 2014
@@ -1583,7 +1583,8 @@
 			++nglyphs;
 //			qDebug() << QString("pdflib: nglyphs %1 max %2").arg(nglyphs).arg(face.maxGlyph());
 			uint FontDes = fontDescriptor;
-			if (Options.Version == PDFOptions::PDFVersion_X4 && (fformat == ScFace::SFNT || fformat == ScFace::TTCF))
+			if ((face.isSymbolic() || Options.Version == PDFOptions::PDFVersion_X4) && 
+				(fformat == ScFace::SFNT || fformat == ScFace::TTCF))
 			{
 				uint fontWidths2 = newObject();
 				StartObj(fontWidths2);
@@ -5614,7 +5615,7 @@
 				else
 					idx1 = idx / 224;
 				ScFace currentFace = style.font();
-				if (Options.Version == PDFOptions::PDFVersion_X4
+				if ((Options.Version == PDFOptions::PDFVersion_X4 || currentFace.isSymbolic())
 					&& (currentFace.format() == ScFace::SFNT || currentFace.format() == ScFace::TTCF)
 					&& ( !Options.SubsetList.contains(style.font().replacementName()) ) )
 					tmp+= UsedFontsP[currentFace.replacementName()]+" "+FToStr(tsz / 10.0)+" Tf\n";
@@ -5724,7 +5725,8 @@
 						tmp += "<"+QString(toHex(idx2))+"> Tj\n";
 					}
 				}
-				else if (Options.Version == PDFOptions::PDFVersion_X4 && (currentFace.format() == ScFace::SFNT || currentFace.format() == ScFace::TTCF))
+				else if ((Options.Version == PDFOptions::PDFVersion_X4 || currentFace.isSymbolic()) && 
+				         (currentFace.format() == ScFace::SFNT || currentFace.format() == ScFace::TTCF))
 				{
 					QString val;
 					val.setNum(idx,16);




More information about the scribus-commit mailing list