r20019 by avox - #0012973: fix ttf embedding in Postscript and revert CMAke version requirement to 2.8.9

scribus-commit scribus-commit at lists.scribus.net
Wed Apr 22 19:42:11 UTC 2015


Author: avox
Date: Wed Apr 22 19:42:11 2015
New Revision: 20019

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=20019
Log:
#0012973: fix ttf embedding in Postscript and revert CMAke version requirement to 2.8.9

Added:
    trunk/Scribus/scribus/fonts/sfnt.cpp
    trunk/Scribus/scribus/fonts/sfnt.h
Modified:
    trunk/Scribus/CMakeLists.txt
    trunk/Scribus/scribus/CMakeLists.txt
    trunk/Scribus/scribus/fonts/CMakeLists.txt
    trunk/Scribus/scribus/fonts/ftface.cpp
    trunk/Scribus/scribus/fonts/scface_ttf.cpp
    trunk/Scribus/scribus/pdflib_core.cpp
    trunk/Scribus/scribus/pdfoptions.h

Modified: trunk/Scribus/CMakeLists.txt
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20019&path=/trunk/Scribus/CMakeLists.txt
==============================================================================
--- trunk/Scribus/CMakeLists.txt (original)
+++ trunk/Scribus/CMakeLists.txt Wed Apr 22 19:42:11 2015
@@ -4,7 +4,7 @@
 #Set our CMake minimum version
 #Require 2.8.9 for Qt5
 #Require 3.2.0 for add_custom_target with byproducts
-CMAKE_MINIMUM_REQUIRED(VERSION 3.2.0 FATAL_ERROR)
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8.9 FATAL_ERROR)
 
 #Pretty colors
 SET(CMAKE_COLOR_MAKEFILE ON)

Modified: trunk/Scribus/scribus/CMakeLists.txt
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20019&path=/trunk/Scribus/scribus/CMakeLists.txt
==============================================================================
--- trunk/Scribus/scribus/CMakeLists.txt (original)
+++ trunk/Scribus/scribus/CMakeLists.txt Wed Apr 22 19:42:11 2015
@@ -4,17 +4,20 @@
 	MESSAGE(STATUS "SVN Version requested in About dialog")
 	# a custom target that is always built
 
-add_custom_target(svnheader ALL COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -P ${CMAKE_MODULE_PATH}/getsvn.cmake BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/svnversion.h)
-
-#	add_custom_target(svnheader ALL DEPENDS svn_header ) # svn_header is nothing more than a unique string
+	IF (NOT CMAKE_VERSION VERSION_LESS "3.2.0")
+	add_custom_target(svnheader ALL COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -P ${CMAKE_MODULE_PATH}/getsvn.cmake BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/svnversion.h)
+
+	ELSE (NOT CMAKE_VERSION VERSION_LESS "3.2.0")
+	add_custom_target(svnheader ALL DEPENDS svn_header ) # svn_header is nothing more than a unique string
 
 	# creates svnheader.h using cmake script
-#	add_custom_command(OUTPUT svn_header ${CMAKE_CURRENT_BINARY_DIR}/svnversion.h
-#		COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -P ${CMAKE_MODULE_PATH}/getsvn.cmake)
-
-#	set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/svnversion.h
-#		PROPERTIES GENERATED TRUE
-#		HEADER_FILE_ONLY TRUE)
+	add_custom_command(OUTPUT svn_header ${CMAKE_CURRENT_BINARY_DIR}/svnversion.h
+		COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -P ${CMAKE_MODULE_PATH}/getsvn.cmake)
+
+	set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/svnversion.h
+		PROPERTIES GENERATED TRUE
+		HEADER_FILE_ONLY TRUE)
+	ENDIF (NOT CMAKE_VERSION VERSION_LESS "3.2.0")
 ENDIF (WANT_SVNVERSION)
 
 IF(WIN32)

Modified: trunk/Scribus/scribus/fonts/CMakeLists.txt
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20019&path=/trunk/Scribus/scribus/fonts/CMakeLists.txt
==============================================================================
--- trunk/Scribus/scribus/fonts/CMakeLists.txt (original)
+++ trunk/Scribus/scribus/fonts/CMakeLists.txt Wed Apr 22 19:42:11 2015
@@ -11,6 +11,7 @@
   scface_ps.cpp
   scface_ttf.cpp
   scfontmetrics.cpp
+  sfnt.cpp
 )
 SET(SCRIBUS_FONTS_LIB "scribus_fonts_lib")
 ADD_LIBRARY(${SCRIBUS_FONTS_LIB} STATIC ${SCRIBUS_FONTS_LIB_SOURCES})

Modified: trunk/Scribus/scribus/fonts/ftface.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20019&path=/trunk/Scribus/scribus/fonts/ftface.cpp
==============================================================================
--- trunk/Scribus/scribus/fonts/ftface.cpp (original)
+++ trunk/Scribus/scribus/fonts/ftface.cpp Wed Apr 22 19:42:11 2015
@@ -90,8 +90,9 @@
 	}
 
 	const_cast<FtFace*>(this)->isStroked = false;
+	const_cast<FtFace*>(this)->hasGlyphNames = FT_HAS_GLYPH_NAMES(m_face);
+
 	m_encoding = 0;
-
 	m_uniEM = static_cast<qreal>(m_face->units_per_EM);
 
 	m_descent = m_face->descender / m_uniEM;

Modified: trunk/Scribus/scribus/fonts/scface_ttf.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20019&path=/trunk/Scribus/scribus/fonts/scface_ttf.cpp
==============================================================================
--- trunk/Scribus/scribus/fonts/scface_ttf.cpp (original)
+++ trunk/Scribus/scribus/fonts/scface_ttf.cpp Wed Apr 22 19:42:11 2015
@@ -16,6 +16,8 @@
 #include "fonts/scfontmetrics.h"
 #include "util_debug.h"
 #include "scconfig.h"
+#include "sfnt.h"
+
 
 KernFeature::KernFeature ( FT_Face face )
 		:m_valid ( true )
@@ -521,6 +523,14 @@
 	if ( !kernFeature )
 		kernFeature = new KernFeature ( ftFace() );
 	FtFace::load();
+	sfnt::PostTable checkPost;
+	FT_Face face = ftFace();
+	checkPost.readFrom(face);
+	if (!checkPost.usable)
+		qDebug() << "unusable post table for " << face->family_name << face->style_name << ":" << checkPost.errorMsg;
+	else
+		qDebug() << "posttable has names for" << checkPost.numberOfGlyphs() << "glyphs from" << maxGlyph;
+	const_cast<bool&>(hasGlyphNames) = checkPost.usable && checkPost.numberOfGlyphs() >= maxGlyph;
 }
 
 void ScFace_ttf::unload() const
@@ -606,7 +616,7 @@
 		if (! bb.data())
 			return;
 		// write header
-		sDebug(QObject::tr("memcpy header: %1 %2 %3").arg(0).arg(faceOffset).arg(headerLength));
+//		sDebug(QObject::tr("memcpy header: %1 %2 %3").arg(0).arg(faceOffset).arg(headerLength));
 		if (!copy(bb, 0, coll, faceOffset, headerLength))
 			return;
 
@@ -615,11 +625,11 @@
 		{
 			uint tableSize  = word(coll, faceOffset + OFFSET_TABLE_LEN + TDIR_ENTRY_LEN * i + 12);
 			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));
+//			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;
 			// 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));
+//			sDebug(QObject::tr("memcpy offset: %1 %2 %3").arg(OFFSET_TABLE_LEN + TDIR_ENTRY_LEN*i + 8).arg(pos).arg(4));
 			// buggy: not endian aware: 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;

Modified: trunk/Scribus/scribus/pdflib_core.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20019&path=/trunk/Scribus/scribus/pdflib_core.cpp
==============================================================================
--- trunk/Scribus/scribus/pdflib_core.cpp (original)
+++ trunk/Scribus/scribus/pdflib_core.cpp Wed Apr 22 19:42:11 2015
@@ -1242,198 +1242,197 @@
 	{
 		ScFace& face(AllFonts[it.key()]);
 		ScFace::FontFormat fformat = face.format();
-		if ((!face.hasNames()) || (Options.SubsetList.contains(it.key())))
-		{
-			if (face.hasNames())
-			{
-				UsedFontsP.insert(it.key(), "/Fo"+QString::number(a));
-				uint SubFonts = 0;
-				int glyphCount = 0;
-				double minx =  std::numeric_limits<double>::max();
-				double miny =  std::numeric_limits<double>::max();
-				double maxx = -std::numeric_limits<double>::max();
-				double maxy = -std::numeric_limits<double>::max();
-				QList<uint> glyphWidths;
-				QStringList charProcs;
-				QString encoding = "<< /Type /Encoding\n/Differences [ 0\n";
-				QString fon("");
-				QMap<uint, uint> glyphMapping;
-				QMap<uint,std::pair<QChar,QString> > gl;
-				face.glyphNames(gl);
-				QMap<uint,FPointArray>& RealGlyphs(it.value());
-				QMap<uint,FPointArray>::Iterator ig;
-				for (ig = RealGlyphs.begin(); ig != RealGlyphs.end(); ++ig)
-				{
-					FPoint np, np1, np2;
-					bool nPath = true;
-					fon = "";
-					if (ig.value().size() > 3)
+		if (Options.OutlineList.contains(it.key()))
+		{
+			// Paint glyphs with XForm objects
+			QString fon("");
+			QMap<uint,FPointArray>& RealGlyphs(it.value());
+			QMap<uint,FPointArray>::Iterator ig;
+			for (ig = RealGlyphs.begin(); ig != RealGlyphs.end(); ++ig)
+			{
+				FPoint np, np1, np2;
+				bool nPath = true;
+				fon = "";
+				if (ig.value().size() > 3)
+				{
+					FPointArray gly = ig.value();
+					QTransform mat;
+					mat.scale(0.1, 0.1);
+					gly.map(mat);
+					for (int poi = 0; poi < gly.size()-3; poi += 4)
 					{
-						FPointArray gly = ig.value();
-						QTransform mat;
-						mat.scale(100.0, -100.0);
-						gly.map(mat);
-						gly.translate(0, 1000);
-						for (int poi = 0; poi < gly.size()-3; poi += 4)
+						if (gly.isMarker(poi))
 						{
-							if (gly.isMarker(poi))
-							{
-								fon += "h\n";
-								nPath = true;
-								continue;
-							}
-							if (nPath)
-							{
-								np = gly.point(poi);
-								fon += FToStr(np.x())+" "+FToStr(np.y())+" m\n";
-								nPath = false;
-							}
-							np = gly.point(poi+1);
-							np1 = gly.point(poi+3);
-							np2 = gly.point(poi+2);
-							fon += FToStr(np.x()) + " " + FToStr(np.y()) + " " + FToStr(np1.x()) + " " + FToStr(np1.y()) + " " + FToStr(np2.x()) + " " + FToStr(np2.y()) + " c\n";
+							fon += "h\n";
+							nPath = true;
+							continue;
 						}
-						fon += "h f*\n";
-						np = getMinClipF(&gly);
-						np1 = getMaxClipF(&gly);
+						if (nPath)
+						{
+							np = gly.point(poi);
+							fon += FToStr(np.x())+" "+FToStr(-np.y())+" m\n";
+							nPath = false;
+						}
+						np = gly.point(poi+1);
+						np1 = gly.point(poi+3);
+						np2 = gly.point(poi+2);
+						fon += FToStr(np.x()) + " " + FToStr(-np.y()) + " " +
+							FToStr(np1.x()) + " " + FToStr(-np1.y()) + " " +
+							FToStr(np2.x()) + " " + FToStr(-np2.y()) + " c\n";
 					}
-					else
+					fon += "h f*\n";
+					np = getMinClipF(&gly);
+					np1 = getMaxClipF(&gly);
+				}
+				else
+				{
+					fon = "h";
+					np = FPoint(0, 0);
+					np1 = FPoint(0, 0);
+				}
+				uint fontGlyphXForm = newObject();
+				StartObj(fontGlyphXForm);
+				PutDoc("<<\n/Type /XObject\n/Subtype /Form\n/FormType 1\n");
+				PutDoc("/BBox [ "+FToStr(np.x())+" "+FToStr(-np.y())+" "+FToStr(np1.x())+ " "+FToStr(-np1.y())+" ]\n");
+				PutDoc("/Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]\n");
+				PutDoc(">>\n");
+				if (Options.Compress)
+					fon = CompressStr(&fon);
+				PutDoc("/Length "+QString::number(fon.length()+1));
+				if (Options.Compress)
+					PutDoc("\n/Filter /FlateDecode");
+				PutDoc(" >>\nstream\n"+EncStream(fon, fontGlyphXForm)+"\nendstream\nendobj\n");
+				Seite.XObjects[face.psName().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" )+QString::number(ig.key())] = fontGlyphXForm;
+			}
+		}
+		else if (Options.SubsetList.contains(it.key()))
+		{
+			// use PDF Type3 font
+			UsedFontsP.insert(it.key(), "/Fo"+QString::number(a));
+			uint SubFonts = 0;
+			int glyphCount = 0;
+			double minx =  std::numeric_limits<double>::max();
+			double miny =  std::numeric_limits<double>::max();
+			double maxx = -std::numeric_limits<double>::max();
+			double maxy = -std::numeric_limits<double>::max();
+			QList<uint> glyphWidths;
+			QStringList charProcs;
+			QString encoding = "<< /Type /Encoding\n/Differences [ 0\n";
+			QString fon("");
+			QMap<uint, uint> glyphMapping;
+			QMap<uint,std::pair<QChar,QString> > gl;
+			face.glyphNames(gl);
+			QMap<uint,FPointArray>& RealGlyphs(it.value());
+			QMap<uint,FPointArray>::Iterator ig;
+			for (ig = RealGlyphs.begin(); ig != RealGlyphs.end(); ++ig)
+			{
+				FPoint np, np1, np2;
+				bool nPath = true;
+				fon = "";
+				if (ig.value().size() > 3)
+				{
+					FPointArray gly = ig.value();
+					QTransform mat;
+					mat.scale(100.0, -100.0);
+					gly.map(mat);
+					gly.translate(0, 1000);
+					for (int poi = 0; poi < gly.size()-3; poi += 4)
 					{
-						fon = "h";
-						np = FPoint(0, 0);
-						np1 = FPoint(0, 0);
+						if (gly.isMarker(poi))
+						{
+							fon += "h\n";
+							nPath = true;
+							continue;
+						}
+						if (nPath)
+						{
+							np = gly.point(poi);
+							fon += FToStr(np.x())+" "+FToStr(np.y())+" m\n";
+							nPath = false;
+						}
+						np = gly.point(poi+1);
+						np1 = gly.point(poi+3);
+						np2 = gly.point(poi+2);
+						fon += FToStr(np.x()) + " " + FToStr(np.y()) + " " + FToStr(np1.x()) + " " + FToStr(np1.y()) + " " + FToStr(np2.x()) + " " + FToStr(np2.y()) + " c\n";
 					}
-					fon.prepend(QString::number(qRound(np1.x())) + " 0 "+QString::number(qRound(np.x()))+" "+QString::number(qRound(np.y()))+" "+QString::number(qRound(np1.x()))+ " "+QString::number(qRound(np1.y()))+" d1\n");
-					minx = qMin(minx, np.x());
-					miny = qMin(miny, np.y());
-					maxx = qMax(maxx, np1.x());
-					maxy = qMax(maxy, np1.y());
-					glyphWidths.append(qRound(np1.x()));
-					uint charProcObject = newObject();
-					charProcs.append("/"+gl[ig.key()].second+" "+QString::number(charProcObject)+" 0 R\n");
-					encoding += "/"+gl[ig.key()].second+" ";
-					glyphMapping.insert(ig.key(), glyphCount + SubFonts * 256);
-					StartObj(charProcObject);
-					if (Options.Compress)
-						fon = CompressStr(&fon);
-					PutDoc("<< /Length "+QString::number(fon.length()+1));
-					if (Options.Compress)
-						PutDoc("\n/Filter /FlateDecode");
-					PutDoc("\n>>\nstream\n"+EncStream(fon, charProcObject)+"\nendstream\nendobj\n");
-					glyphCount++;
-					int glyphsLeft = RealGlyphs.count() - SubFonts * 256;
-					if ((glyphCount > 255) || (glyphCount == glyphsLeft))
+					fon += "h f*\n";
+					np = getMinClipF(&gly);
+					np1 = getMaxClipF(&gly);
+				}
+				else
+				{
+					fon = "h";
+					np = FPoint(0, 0);
+					np1 = FPoint(0, 0);
+				}
+				fon.prepend(QString::number(qRound(np1.x())) + " 0 "+QString::number(qRound(np.x()))+" "+QString::number(qRound(np.y()))+" "+QString::number(qRound(np1.x()))+ " "+QString::number(qRound(np1.y()))+" d1\n");
+				minx = qMin(minx, np.x());
+				miny = qMin(miny, np.y());
+				maxx = qMax(maxx, np1.x());
+				maxy = qMax(maxy, np1.y());
+				glyphWidths.append(qRound(np1.x()));
+				uint charProcObject = newObject();
+				charProcs.append("/"+gl[ig.key()].second+" "+QString::number(charProcObject)+" 0 R\n");
+				encoding += "/"+gl[ig.key()].second+" ";
+				glyphMapping.insert(ig.key(), glyphCount + SubFonts * 256);
+				StartObj(charProcObject);
+				if (Options.Compress)
+					fon = CompressStr(&fon);
+				PutDoc("<< /Length "+QString::number(fon.length()+1));
+				if (Options.Compress)
+					PutDoc("\n/Filter /FlateDecode");
+				PutDoc("\n>>\nstream\n"+EncStream(fon, charProcObject)+"\nendstream\nendobj\n");
+				glyphCount++;
+				int glyphsLeft = RealGlyphs.count() - SubFonts * 256;
+				if ((glyphCount > 255) || (glyphCount == glyphsLeft))
+				{
+					uint fontWidths = newObject();
+					StartObj(fontWidths);
+					PutDoc("[ ");
+					for (int ww = 0; ww < glyphWidths.count(); ++ww)
 					{
-						uint fontWidths = newObject();
-						StartObj(fontWidths);
-						PutDoc("[ ");
-						for (int ww = 0; ww < glyphWidths.count(); ++ww)
-						{
-							PutDoc(QString::number(glyphWidths[ww])+" ");
-						}
-						PutDoc("]\nendobj\n");
-						uint fontCharProcs = newObject();
-						StartObj(fontCharProcs);
-						PutDoc("<<\n");
-						for (int ww = 0; ww < charProcs.count(); ++ww)
-						{
-							PutDoc(charProcs[ww]);
-						}
-						PutDoc(">>\nendobj\n");
-						uint fontEncoding = newObject();
-						StartObj(fontEncoding);
-						PutDoc(encoding);
-						PutDoc("]\n");
-						PutDoc(">>\nendobj\n");
-						uint font3Object = newObject();
-						StartObj(font3Object);
-						PutDoc("<<\n/Type /Font\n/Subtype /Type3\n");
-						PutDoc("/Name /Fo"+QString::number(a)+"S"+QString::number(SubFonts)+"\n");
-						PutDoc("/FirstChar 0\n");
-						PutDoc("/LastChar "+QString::number(glyphCount-1)+"\n");
-						PutDoc("/Widths "+QString::number(fontWidths)+" 0 R\n");
-						PutDoc("/CharProcs "+QString::number(fontCharProcs)+" 0 R\n");
-						PutDoc("/FontBBox ["+QString::number(qRound(minx))+" "+QString::number(qRound(miny))+" "+QString::number(qRound(maxx))+ " "+QString::number(qRound(maxy))+"]\n");
-						PutDoc("/FontMatrix [0.001 0 0 0.001 0 0]\n");
-						PutDoc("/Encoding "+QString::number(fontEncoding)+" 0 R\n");
-						PutDoc(">>\nendobj\n");
-						Seite.FObjects["Fo"+QString::number(a)+"S"+QString::number(SubFonts)] = font3Object;
-						charProcs.clear();
-						glyphWidths.clear();
-//						glyphMapping.clear();
-						glyphCount = 0;
-						++SubFonts;
-						minx =  std::numeric_limits<double>::max();
-						miny =  std::numeric_limits<double>::max();
-						maxx = -std::numeric_limits<double>::max();
-						maxy = -std::numeric_limits<double>::max();
-						encoding = "<< /Type /Encoding\n/Differences [ 0\n";
+						PutDoc(QString::number(glyphWidths[ww])+" ");
 					}
-				}
-				Type3Fonts.insert("/Fo"+QString::number(a), glyphMapping);
-			}
-			else
-			{
-				QString fon("");
-				QMap<uint,FPointArray>& RealGlyphs(it.value());
-				QMap<uint,FPointArray>::Iterator ig;
-				for (ig = RealGlyphs.begin(); ig != RealGlyphs.end(); ++ig)
-				{
-					FPoint np, np1, np2;
-					bool nPath = true;
-					fon = "";
-					if (ig.value().size() > 3)
+					PutDoc("]\nendobj\n");
+					uint fontCharProcs = newObject();
+					StartObj(fontCharProcs);
+					PutDoc("<<\n");
+					for (int ww = 0; ww < charProcs.count(); ++ww)
 					{
-						FPointArray gly = ig.value();
-						QTransform mat;
-						mat.scale(0.1, 0.1);
-						gly.map(mat);
-						for (int poi = 0; poi < gly.size()-3; poi += 4)
-						{
-							if (gly.isMarker(poi))
-							{
-								fon += "h\n";
-								nPath = true;
-								continue;
-							}
-							if (nPath)
-							{
-								np = gly.point(poi);
-								fon += FToStr(np.x())+" "+FToStr(-np.y())+" m\n";
-								nPath = false;
-							}
-							np = gly.point(poi+1);
-							np1 = gly.point(poi+3);
-							np2 = gly.point(poi+2);
-							fon += FToStr(np.x()) + " " + FToStr(-np.y()) + " " +
-								FToStr(np1.x()) + " " + FToStr(-np1.y()) + " " +
-								FToStr(np2.x()) + " " + FToStr(-np2.y()) + " c\n";
-						}
-						fon += "h f*\n";
-						np = getMinClipF(&gly);
-						np1 = getMaxClipF(&gly);
+						PutDoc(charProcs[ww]);
 					}
-					else
-					{
-						fon = "h";
-						np = FPoint(0, 0);
-						np1 = FPoint(0, 0);
-					}
-					uint fontGlyphXForm = newObject();
-					StartObj(fontGlyphXForm);
-					PutDoc("<<\n/Type /XObject\n/Subtype /Form\n/FormType 1\n");
-					PutDoc("/BBox [ "+FToStr(np.x())+" "+FToStr(-np.y())+" "+FToStr(np1.x())+ " "+FToStr(-np1.y())+" ]\n");
-					PutDoc("/Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]\n");
-					PutDoc(">>\n");
-					if (Options.Compress)
-						fon = CompressStr(&fon);
-					PutDoc("/Length "+QString::number(fon.length()+1));
-					if (Options.Compress)
-						PutDoc("\n/Filter /FlateDecode");
-					PutDoc(" >>\nstream\n"+EncStream(fon, fontGlyphXForm)+"\nendstream\nendobj\n");
-					Seite.XObjects[face.psName().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" )+QString::number(ig.key())] = fontGlyphXForm;
-				}
-			}
+					PutDoc(">>\nendobj\n");
+					uint fontEncoding = newObject();
+					StartObj(fontEncoding);
+					PutDoc(encoding);
+					PutDoc("]\n");
+					PutDoc(">>\nendobj\n");
+					uint font3Object = newObject();
+					StartObj(font3Object);
+					PutDoc("<<\n/Type /Font\n/Subtype /Type3\n");
+					PutDoc("/Name /Fo"+QString::number(a)+"S"+QString::number(SubFonts)+"\n");
+					PutDoc("/FirstChar 0\n");
+					PutDoc("/LastChar "+QString::number(glyphCount-1)+"\n");
+					PutDoc("/Widths "+QString::number(fontWidths)+" 0 R\n");
+					PutDoc("/CharProcs "+QString::number(fontCharProcs)+" 0 R\n");
+					PutDoc("/FontBBox ["+QString::number(qRound(minx))+" "+QString::number(qRound(miny))+" "+QString::number(qRound(maxx))+ " "+QString::number(qRound(maxy))+"]\n");
+					PutDoc("/FontMatrix [0.001 0 0 0.001 0 0]\n");
+					PutDoc("/Encoding "+QString::number(fontEncoding)+" 0 R\n");
+					PutDoc(">>\nendobj\n");
+					Seite.FObjects["Fo"+QString::number(a)+"S"+QString::number(SubFonts)] = font3Object;
+					charProcs.clear();
+					glyphWidths.clear();
+//					glyphMapping.clear();
+					glyphCount = 0;
+					++SubFonts;
+					minx =  std::numeric_limits<double>::max();
+					miny =  std::numeric_limits<double>::max();
+					maxx = -std::numeric_limits<double>::max();
+					maxy = -std::numeric_limits<double>::max();
+					encoding = "<< /Type /Encoding\n/Differences [ 0\n";
+				}
+			}
+			Type3Fonts.insert("/Fo"+QString::number(a), glyphMapping);
 		}
 		else
 		{
@@ -1585,7 +1584,7 @@
 			++nglyphs;
 //			qDebug() << QString("pdflib: nglyphs %1 max %2").arg(nglyphs).arg(face.maxGlyph());
 			uint FontDes = fontDescriptor;
-			if ((face.isSymbolic() || Options.Version == PDFOptions::PDFVersion_X4) && 
+			if ((face.isSymbolic() || !face.hasNames() || Options.Version == PDFOptions::PDFVersion_X4) && 
 				(fformat == ScFace::SFNT || fformat == ScFace::TTCF))
 			{
 				uint fontWidths2 = newObject();
@@ -5508,7 +5507,7 @@
 			}
 			tmp2 += "S\n";
 		}
-		if (!style.font().hasNames())
+		if (Options.OutlineList.contains(style.font().replacementName()))
 		{
 			if (glyph != style.font().char2CMap(QChar(' ')))
 			{
@@ -5617,7 +5616,7 @@
 				else
 					idx1 = idx / 224;
 				ScFace currentFace = style.font();
-				if ((Options.Version == PDFOptions::PDFVersion_X4 || currentFace.isSymbolic())
+				if ((Options.Version == PDFOptions::PDFVersion_X4 || currentFace.isSymbolic() || !currentFace.hasNames())
 					&& (currentFace.format() == ScFace::SFNT || currentFace.format() == ScFace::TTCF)
 					&& ( !Options.SubsetList.contains(style.font().replacementName()) ) )
 					tmp+= UsedFontsP[currentFace.replacementName()]+" "+FToStr(tsz / 10.0)+" Tf\n";
@@ -5727,7 +5726,7 @@
 						tmp += "<"+QString(toHex(idx2))+"> Tj\n";
 					}
 				}
-				else if ((Options.Version == PDFOptions::PDFVersion_X4 || currentFace.isSymbolic()) && 
+				else if ((Options.Version == PDFOptions::PDFVersion_X4 || currentFace.isSymbolic() || !currentFace.hasNames()) && 
 				         (currentFace.format() == ScFace::SFNT || currentFace.format() == ScFace::TTCF))
 				{
 					QString val;

Modified: trunk/Scribus/scribus/pdfoptions.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20019&path=/trunk/Scribus/scribus/pdfoptions.h
==============================================================================
--- trunk/Scribus/scribus/pdfoptions.h (original)
+++ trunk/Scribus/scribus/pdfoptions.h Wed Apr 22 19:42:11 2015
@@ -113,6 +113,7 @@
 	int  Binding;
 	QList<QString> EmbedList;
 	QList<QString> SubsetList;
+	QList<QString> OutlineList;
 	bool MirrorH;
 	bool MirrorV;
 	bool doClip;




More information about the scribus-commit mailing list