r17629 by jghali - pdf export : avoid a few unnecessary lookups in the font map and remove some dead code

scribus-commit scribus-commit at lists.scribus.net
Sun Jun 24 21:07:11 UTC 2012


Author: jghali
Date: Sun Jun 24 21:07:11 2012
New Revision: 17629

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17629
Log:
pdf export : avoid a few unnecessary lookups in the font map and remove some dead code

Modified:
    branches/Version14x/Scribus/scribus/pdflib_core.cpp

Modified: branches/Version14x/Scribus/scribus/pdflib_core.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17629&path=/branches/Version14x/Scribus/scribus/pdflib_core.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/pdflib_core.cpp (original)
+++ branches/Version14x/Scribus/scribus/pdflib_core.cpp Sun Jun 24 21:07:11 2012
@@ -1243,7 +1243,7 @@
 					if (Options.Compress)
 						PutDoc("\n/Filter /FlateDecode");
 					PutDoc(" >>\nstream\n"+EncStream(fon, fontGlyphXForm)+"\nendstream\nendobj\n");
-					Seite.XObjects[AllFonts[it.key()].psName().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" )+QString::number(ig.key())] = fontGlyphXForm;
+					Seite.XObjects[face.psName().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" )+QString::number(ig.key())] = fontGlyphXForm;
 				}
 			}
 		}
@@ -1254,10 +1254,10 @@
 			if ((fformat == ScFace::PFB) && (Options.EmbedList.contains(it.key())))
 			{
 				QString fon("");
+				QByteArray bb;
 				embeddedFontObject = newObject();
 				StartObj(embeddedFontObject);
-				QByteArray bb;
-				AllFonts[it.key()].RawData(bb);
+				face.RawData(bb);
 				int posi;
 				for (posi = 6; posi < bb.size(); ++posi)
 				{
@@ -1307,7 +1307,7 @@
 				bool ok = true;
 				embeddedFontObject = newObject();
 				StartObj(embeddedFontObject);
-				AllFonts[it.key()].EmbedFont(fon);
+				face.EmbedFont(fon);
 				int len1 = fon.indexOf("eexec")+5;
 				fon2 = fon.left(len1)+"\n";
 				int len2 = fon.indexOf("0000000000000000000000000");
@@ -1339,10 +1339,10 @@
 			if ((fformat == ScFace::SFNT || fformat == ScFace::TTCF) && (Options.EmbedList.contains(it.key())))
 			{
 				QString fon("");
+				QByteArray bb;
 				embeddedFontObject = newObject();
 				StartObj(embeddedFontObject);
-				QByteArray bb;
-				AllFonts[it.key()].RawData(bb);
+				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]);
@@ -1360,29 +1360,29 @@
 			StartObj(fontDescriptor);
 			// TODO: think about QByteArray ScFace::getFontDescriptor() -- AV
 			PutDoc("<<\n/Type /FontDescriptor\n");
-			PutDoc("/FontName /"+AllFonts[it.key()].psName().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" )+"\n");
-			PutDoc("/FontBBox [ "+AllFonts[it.key()].fontBBoxAsString()+" ]\n");
+			PutDoc("/FontName /"+face.psName().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" )+"\n");
+			PutDoc("/FontBBox [ "+face.fontBBoxAsString()+" ]\n");
 			PutDoc("/Flags ");
 			//FIXME: isItalic() should be queried from ScFace, not from Qt -- AV
 			//QFontInfo fo = QFontInfo(it.data());
 			int pfl = 0;
-			if (AllFonts[it.key()].isFixedPitch())
+			if (face.isFixedPitch())
 				pfl = pfl ^ 1;
 			//if (fo.italic())
-			if (AllFonts[it.key()].italicAngleAsString() != "0")
+			if (face.italicAngleAsString() != "0")
 				pfl = pfl ^ 64;
 //			pfl = pfl ^ 4;
 			pfl = pfl ^ 32;
 			PutDoc(QString::number(pfl)+"\n");
-			PutDoc("/Ascent "+AllFonts[it.key()].ascentAsString()+"\n");
-			PutDoc("/Descent "+AllFonts[it.key()].descentAsString()+"\n");
-			PutDoc("/CapHeight "+AllFonts[it.key()].capHeightAsString()+"\n");
-			PutDoc("/ItalicAngle "+AllFonts[it.key()].italicAngleAsString()+"\n");
-//			PutDoc("/Ascent "+QString::number(static_cast<int>(AllFonts[it.key()].ascent()))+"\n");
-//			PutDoc("/Descent "+QString::number(static_cast<int>(AllFonts[it.key()].descent()))+"\n");
-//			PutDoc("/CapHeight "+QString::number(static_cast<int>(AllFonts[it.key()].capHeight()))+"\n");
-//			PutDoc("/ItalicAngle "+AllFonts[it.key()].italicAngle()+"\n");
-//			PutDoc("/StemV "+ AllFonts[it.key()].stemV() + "\n");
+			PutDoc("/Ascent "+face.ascentAsString()+"\n");
+			PutDoc("/Descent "+face.descentAsString()+"\n");
+			PutDoc("/CapHeight "+face.capHeightAsString()+"\n");
+			PutDoc("/ItalicAngle "+face.italicAngleAsString()+"\n");
+//			PutDoc("/Ascent "+QString::number(static_cast<int>(face.ascent()))+"\n");
+//			PutDoc("/Descent "+QString::number(static_cast<int>(face.descent()))+"\n");
+//			PutDoc("/CapHeight "+QString::number(static_cast<int>(face.capHeight()))+"\n");
+//			PutDoc("/ItalicAngle "+face.italicAngle()+"\n");
+//			PutDoc("/StemV "+ face.stemV() + "\n");
 			PutDoc("/StemV 1\n");
 			if ((fformat == ScFace::SFNT || fformat == ScFace::TTCF) && (Options.EmbedList.contains(it.key())))
 				PutDoc("/FontFile2 "+QString::number(embeddedFontObject)+" 0 R\n");
@@ -1391,218 +1391,184 @@
 			if ((fformat == ScFace::PFA) && (Options.EmbedList.contains(it.key())))
 				PutDoc("/FontFile "+QString::number(embeddedFontObject)+" 0 R\n");
 			PutDoc(">>\nendobj\n");
-/*			if (!FT_Has_PS_Glyph_Names(AllFonts[it.key()])
-			{
-				StartObj(ObjCounter);
-				int chCount = 31;
-				PutDoc("[ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ");
-				for (int ww = 31; ww < 256; ++ww)
-				{
-					PutDoc(QString::number(static_cast<int>(AllFonts[it.key()]->CharWidth[itg.key()]*
-							1000))+" ");
-					if (itg == gl.end())
+
+			QMap<uint,std::pair<QChar,QString> > gl;
+			face.glyphNames(gl);
+			int nglyphs = 0;
+			QMap<uint,std::pair<QChar,QString> >::Iterator gli;
+			for (gli = gl.begin(); gli != gl.end(); ++gli)
+			{
+				if (gli.key() > static_cast<uint>(nglyphs))
+					nglyphs = gli.key();
+			}
+			++nglyphs;
+//			qDebug() << QString("pdflib: nglyphs %1 max %2").arg(nglyphs).arg(face.maxGlyph());
+			uint FontDes = fontDescriptor;
+			uint Fcc = nglyphs / 224;
+			if ((nglyphs % 224) != 0)
+				Fcc += 1;
+			for (uint Fc = 0; Fc < Fcc; ++Fc)
+			{
+				uint fontWidths2 = newObject();
+				StartObj(fontWidths2);
+				int chCount = 32;
+				PutDoc("[ 0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 ");
+				for (int ww = 32; ww < 256; ++ww)
+				{
+					uint glyph = 224 * Fc + ww - 32;
+					if (gl.contains(glyph))
+						PutDoc(QString::number(static_cast<int>(face.glyphWidth(glyph)* 1000))+" ");
+					else
+						PutDoc("0 ");
+					chCount++;
+					if (signed(glyph) == nglyphs-1)
 						break;
-					++itg;
-					chCount++;
 				}
 				PutDoc("]\nendobj\n");
-				ObjCounter++;
-				// put widths object
-				// encoding dictionary w/ base encoding w/o differences
-				StartObj(ObjCounter);
+				uint fontEncoding2 = newObject();
+				StartObj(fontEncoding2);
+				QStringList toUnicodeMaps;
+				QList<int> toUnicodeMapsCount;
+				QString toUnicodeMap = "";
+				int toUnicodeMapCounter = 0;
+				PutDoc("<< /Type /Encoding\n");
+				PutDoc("/Differences [ \n");
+				int crc = 0;
+				bool startOfSeq = true;
+				for (int ww2 = 32; ww2 < 256; ++ww2)
+				{
+					uint glyph = 224 * Fc + ww2 - 32;
+					QMap<uint,std::pair<QChar,QString> >::Iterator glIt = gl.find(glyph);
+					if (glIt != gl.end() && !glIt.value().second.isEmpty())
+					{
+						if (startOfSeq)
+						{
+							PutDoc(QString::number(ww2)+" ");
+							startOfSeq = false;
+						}
+						PutDoc("/"+glIt.value().second+" ");
+						QString tmp, tmp2;
+						tmp.sprintf("%02X", ww2);
+						tmp2.sprintf("%04X", glIt.value().first.unicode());
+						toUnicodeMap += QString("<%1> <%2>\n").arg(tmp).arg((tmp2));
+						toUnicodeMapCounter++;
+						if (toUnicodeMapCounter == 100)
+						{
+							toUnicodeMaps.append(toUnicodeMap);
+							toUnicodeMapsCount.append(toUnicodeMapCounter);
+							toUnicodeMap = "";
+							toUnicodeMapCounter = 0;
+						}
+						crc++;
+					}
+					else
+					{
+						startOfSeq = true;
+					}
+					if (signed(glyph) == nglyphs-1)
+						break;
+					if (crc > 8)
+					{
+						PutDoc("\n");
+						crc = 0;
+					}
+				}
+				if (toUnicodeMapCounter != 0)
+				{
+					toUnicodeMaps.append(toUnicodeMap);
+					toUnicodeMapsCount.append(toUnicodeMapCounter);
+				}
+				PutDoc("]\n");
+				PutDoc(">>\nendobj\n");
+				QString toUnicodeMapStream = "";
+				toUnicodeMapStream += "/CIDInit /ProcSet findresource begin\n";
+				toUnicodeMapStream += "12 dict begin\n";
+				toUnicodeMapStream += "begincmap\n";
+				toUnicodeMapStream += "/CIDSystemInfo <<\n";
+				toUnicodeMapStream += "/Registry (Adobe)\n";
+				toUnicodeMapStream += "/Ordering (UCS)\n";
+				toUnicodeMapStream += "/Supplement 0\n";
+				toUnicodeMapStream += ">> def\n";
+				toUnicodeMapStream += "/CMapName /Adobe-Identity-UCS def\n";
+				toUnicodeMapStream += "/CMapType 2 def\n";
+				toUnicodeMapStream += "1 begincodespacerange\n";
+				toUnicodeMapStream += "<0000> <FFFF>\n";
+				toUnicodeMapStream += "endcodespacerange\n";
+				for (int uniC = 0; uniC < toUnicodeMaps.count(); uniC++)
+				{
+					toUnicodeMapStream += QString("%1 beginbfchar\n").arg(toUnicodeMapsCount[uniC]);
+					toUnicodeMapStream += toUnicodeMaps[uniC];
+					toUnicodeMapStream += "endbfchar\n";
+				}
+				toUnicodeMapStream += "endcmap\n";
+				toUnicodeMapStream += "CMapName currentdict /CMap defineresource pop\n";
+				toUnicodeMapStream += "end\n";
+				toUnicodeMapStream += "end\n";
+				uint fontToUnicode2 = WritePDFStream(toUnicodeMapStream);
+				uint fontObject2 = newObject();
+				StartObj(fontObject2);
 				PutDoc("<<\n/Type /Font\n/Subtype ");
 				PutDoc((fformat == ScFace::SFNT || fformat == ScFace::TTCF) ? "/TrueType\n" : "/Type1\n");
-				PutDoc("/Name /Fo"+QString::number(a)+"\n");
-				PutDoc("/BaseFont /"+AllFonts[it.key()]->psName().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "" )+"\n");
-				//cf. widths:
+				PutDoc("/Name /Fo"+QString::number(a)+"S"+QString::number(Fc)+"\n");
+				PutDoc("/BaseFont /"+face.psName().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" )+"\n");
 				PutDoc("/FirstChar 0\n");
 				PutDoc("/LastChar "+QString::number(chCount-1)+"\n");
-				PutDoc("/Widths "+QString::number(ObjCounter-1)+" 0 R\n");
-				PutDoc("/FontDescriptor "+QString::number(ObjCounter-2)+" 0 R\n");
-				PutDoc(">>\nendobj\n");
-				Seite.FObjects["Fo"+QString::number(a)] = ObjCounter;
-				ObjCounter++;
-			}
-			else */
-//			{
-				QMap<uint,std::pair<QChar,QString> > gl;
-				AllFonts[it.key()].glyphNames(gl);
-				int nglyphs = 0;
-				QMap<uint,std::pair<QChar,QString> >::Iterator gli;
-				for (gli = gl.begin(); gli != gl.end(); ++gli)
-				{
-					if (gli.key() > static_cast<uint>(nglyphs))
-						nglyphs = gli.key();
-				}
-				++nglyphs;
-//				qDebug() << QString("pdflib: nglyphs %1 max %2").arg(nglyphs).arg(AllFonts[it.key()].maxGlyph());
-				uint FontDes = fontDescriptor;
-				uint Fcc = nglyphs / 224;
-				if ((nglyphs % 224) != 0)
-					Fcc += 1;
-				for (uint Fc = 0; Fc < Fcc; ++Fc)
-				{
-					uint fontWidths2 = newObject();
-					StartObj(fontWidths2);
-					int chCount = 32;
-					PutDoc("[ 0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 ");
-					for (int ww = 32; ww < 256; ++ww)
-					{
-						uint glyph = 224 * Fc + ww - 32;
-						if (gl.contains(glyph))
-							PutDoc(QString::number(static_cast<int>(AllFonts[it.key()].glyphWidth(glyph)* 1000))+" ");
-						else
-							PutDoc("0 ");
-						chCount++;
-						if (signed(glyph) == nglyphs-1)
-							break;
-					}
-					PutDoc("]\nendobj\n");
-					uint fontEncoding2 = newObject();
-					StartObj(fontEncoding2);
-					QStringList toUnicodeMaps;
-					QList<int> toUnicodeMapsCount;
-					QString toUnicodeMap = "";
-					int toUnicodeMapCounter = 0;
-					PutDoc("<< /Type /Encoding\n");
-					PutDoc("/Differences [ \n");
-					int crc = 0;
-					bool startOfSeq = true;
-					for (int ww2 = 32; ww2 < 256; ++ww2)
-					{
-						uint glyph = 224 * Fc + ww2 - 32;
-						QMap<uint,std::pair<QChar,QString> >::Iterator glIt = gl.find(glyph);
-						if (glIt != gl.end() && !glIt.value().second.isEmpty())
-						{
-							if (startOfSeq)
-							{
-								PutDoc(QString::number(ww2)+" ");
-								startOfSeq = false;
-							}
-							PutDoc("/"+glIt.value().second+" ");
-							QString tmp, tmp2;
-							tmp.sprintf("%02X", ww2);
-							tmp2.sprintf("%04X", glIt.value().first.unicode());
-							toUnicodeMap += QString("<%1> <%2>\n").arg(tmp).arg((tmp2));
-							toUnicodeMapCounter++;
-							if (toUnicodeMapCounter == 100)
-							{
-								toUnicodeMaps.append(toUnicodeMap);
-								toUnicodeMapsCount.append(toUnicodeMapCounter);
-								toUnicodeMap = "";
-								toUnicodeMapCounter = 0;
-							}
-							crc++;
-						}
-						else
-						{
-							startOfSeq = true;
-						}
-						if (signed(glyph) == nglyphs-1)
-							break;
-						if (crc > 8)
-						{
-							PutDoc("\n");
-							crc = 0;
-						}
-					}
-					if (toUnicodeMapCounter != 0)
-					{
-						toUnicodeMaps.append(toUnicodeMap);
-						toUnicodeMapsCount.append(toUnicodeMapCounter);
-					}
-					PutDoc("]\n");
-					PutDoc(">>\nendobj\n");
-					QString toUnicodeMapStream = "";
-					toUnicodeMapStream += "/CIDInit /ProcSet findresource begin\n";
-					toUnicodeMapStream += "12 dict begin\n";
-					toUnicodeMapStream += "begincmap\n";
-					toUnicodeMapStream += "/CIDSystemInfo <<\n";
-					toUnicodeMapStream += "/Registry (Adobe)\n";
-					toUnicodeMapStream += "/Ordering (UCS)\n";
-					toUnicodeMapStream += "/Supplement 0\n";
-					toUnicodeMapStream += ">> def\n";
-					toUnicodeMapStream += "/CMapName /Adobe-Identity-UCS def\n";
-					toUnicodeMapStream += "/CMapType 2 def\n";
-					toUnicodeMapStream += "1 begincodespacerange\n";
-					toUnicodeMapStream += "<0000> <FFFF>\n";
-					toUnicodeMapStream += "endcodespacerange\n";
-					for (int uniC = 0; uniC < toUnicodeMaps.count(); uniC++)
-					{
-						toUnicodeMapStream += QString("%1 beginbfchar\n").arg(toUnicodeMapsCount[uniC]);
-						toUnicodeMapStream += toUnicodeMaps[uniC];
-						toUnicodeMapStream += "endbfchar\n";
-					}
-					toUnicodeMapStream += "endcmap\n";
-					toUnicodeMapStream += "CMapName currentdict /CMap defineresource pop\n";
-					toUnicodeMapStream += "end\n";
-					toUnicodeMapStream += "end\n";
-					uint fontToUnicode2 = WritePDFStream(toUnicodeMapStream);
-					uint fontObject2 = newObject();
-					StartObj(fontObject2);
-					PutDoc("<<\n/Type /Font\n/Subtype ");
-					PutDoc((fformat == ScFace::SFNT || fformat == ScFace::TTCF) ? "/TrueType\n" : "/Type1\n");
-					PutDoc("/Name /Fo"+QString::number(a)+"S"+QString::number(Fc)+"\n");
-					PutDoc("/BaseFont /"+AllFonts[it.key()].psName().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" )+"\n");
-					PutDoc("/FirstChar 0\n");
-					PutDoc("/LastChar "+QString::number(chCount-1)+"\n");
-					PutDoc("/Widths "+QString::number(fontWidths2)+" 0 R\n");
-					PutDoc("/Encoding "+QString::number(fontEncoding2)+" 0 R\n");
-					PutDoc("/ToUnicode "+QString::number(fontToUnicode2)+" 0 R\n");
-					PutDoc("/FontDescriptor "+QString::number(FontDes)+" 0 R\n");
-					PutDoc(">>\nendobj\n");
-					Seite.FObjects["Fo"+QString::number(a)+"S"+QString::number(Fc)] = fontObject2;
-				} // for(Fc)
-				uint fontWidthsForm = newObject();
-				StartObj(fontWidthsForm);
-				PutDoc("[ 0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 ");
-				for (int ww = 32; ww < 256; ++ww)
-				{
-					uint glyph = AllFonts[it.key()].char2CMap(QChar(ww));
-					if (gl.contains(glyph))
-						PutDoc(QString::number(static_cast<int>(AllFonts[it.key()].glyphWidth(glyph)* 1000))+" ");
-					else
-						PutDoc("0 ");
-				}
-				PutDoc("]\nendobj\n");
-				uint fontObjectForm = newObject();
-				StartObj(fontObjectForm);
-				PutDoc("<<\n/Type /Font\n/Subtype ");
-				PutDoc((fformat == ScFace::SFNT || fformat == ScFace::TTCF) ? "/TrueType\n" : "/Type1\n");
-//				if (fformat == ScFace::SFNT || fformat == ScFace::TTCF)
-//				{
-//					PutDoc("/TrueType\n");
-					PutDoc("/Name /Fo"+QString::number(a)+"Form"+"\n");
-					Seite.FObjects["Fo"+QString::number(a)+"Form"] = fontObjectForm;
-					UsedFontsF.insert(it.key(), "/Fo"+QString::number(a)+"Form");
-/*				}
-				else
-				{
-					PutDoc("/Type1\n");
-					PutDoc("/Name /"+AllFonts[it.key()].psName().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" )+"\n");
-					Seite.FObjects[AllFonts[it.key()].psName().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" )] = ObjCounter;
-					UsedFontsF.insert(it.key(), "/"+AllFonts[it.key()].psName().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" ));
-				} */
-				PutDoc("/BaseFont /"+AllFonts[it.key()].psName().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" )+"\n");
-				PutDoc("/Encoding << \n");
-				PutDoc("/Differences [ \n");
-				PutDoc("24 /breve /caron /circumflex /dotaccent /hungarumlaut /ogonek /ring /tilde\n");
-				PutDoc("39 /quotesingle 96 /grave 128 /bullet /dagger /daggerdbl /ellipsis /emdash /endash /florin /fraction /guilsinglleft /guilsinglright\n");
-				PutDoc("/minus /perthousand /quotedblbase /quotedblleft /quotedblright /quoteleft /quoteright /quotesinglbase /trademark /fi /fl /Lslash /OE /Scaron\n");
-				PutDoc("/Ydieresis /Zcaron /dotlessi /lslash /oe /scaron /zcaron 164 /currency 166 /brokenbar 168 /dieresis /copyright /ordfeminine 172 /logicalnot\n");
-				PutDoc("/.notdef /registered /macron /degree /plusminus /twosuperior /threesuperior /acute /mu 183 /periodcentered /cedilla /onesuperior /ordmasculine\n");
-				PutDoc("188 /onequarter /onehalf /threequarters 192 /Agrave /Aacute /Acircumflex /Atilde /Adieresis /Aring /AE /Ccedilla /Egrave /Eacute /Ecircumflex\n");
-				PutDoc("/Edieresis /Igrave /Iacute /Icircumflex /Idieresis /Eth /Ntilde /Ograve /Oacute /Ocircumflex /Otilde /Odieresis /multiply /Oslash\n");
-				PutDoc("/Ugrave /Uacute /Ucircumflex /Udieresis /Yacute /Thorn /germandbls /agrave /aacute /acircumflex /atilde /adieresis /aring /ae /ccedilla\n");
-				PutDoc("/egrave /eacute /ecircumflex /edieresis /igrave /iacute /icircumflex /idieresis /eth /ntilde /ograve /oacute /ocircumflex /otilde /odieresis\n");
-				PutDoc("/divide /oslash /ugrave /uacute /ucircumflex /udieresis /yacute /thorn /ydieresis\n");
-				PutDoc("] >>\n");
-				PutDoc("/FirstChar 0\n");
-				PutDoc("/LastChar 255\n");
-				PutDoc("/Widths "+QString::number(fontWidthsForm)+" 0 R\n");
+				PutDoc("/Widths "+QString::number(fontWidths2)+" 0 R\n");
+				PutDoc("/Encoding "+QString::number(fontEncoding2)+" 0 R\n");
+				PutDoc("/ToUnicode "+QString::number(fontToUnicode2)+" 0 R\n");
 				PutDoc("/FontDescriptor "+QString::number(FontDes)+" 0 R\n");
 				PutDoc(">>\nendobj\n");
-//			} // FT_Has_PS_Glyph_Names
+				Seite.FObjects["Fo"+QString::number(a)+"S"+QString::number(Fc)] = fontObject2;
+			} // for(Fc)
+			uint fontWidthsForm = newObject();
+			StartObj(fontWidthsForm);
+			PutDoc("[ 0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 ");
+			for (int ww = 32; ww < 256; ++ww)
+			{
+				uint glyph = face.char2CMap(QChar(ww));
+				if (gl.contains(glyph))
+					PutDoc(QString::number(static_cast<int>(face.glyphWidth(glyph)* 1000))+" ");
+				else
+					PutDoc("0 ");
+			}
+			PutDoc("]\nendobj\n");
+			uint fontObjectForm = newObject();
+			StartObj(fontObjectForm);
+			PutDoc("<<\n/Type /Font\n/Subtype ");
+			PutDoc((fformat == ScFace::SFNT || fformat == ScFace::TTCF) ? "/TrueType\n" : "/Type1\n");
+//			if (fformat == ScFace::SFNT || fformat == ScFace::TTCF)
+//			{
+//				PutDoc("/TrueType\n");
+				PutDoc("/Name /Fo"+QString::number(a)+"Form"+"\n");
+				Seite.FObjects["Fo"+QString::number(a)+"Form"] = fontObjectForm;
+				UsedFontsF.insert(it.key(), "/Fo"+QString::number(a)+"Form");
+/*			}
+			else
+			{
+				PutDoc("/Type1\n");
+				PutDoc("/Name /"+face.psName().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" )+"\n");
+				Seite.FObjects[face.psName().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" )] = ObjCounter;
+				UsedFontsF.insert(it.key(), "/"+face.psName().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" ));
+			} */
+			PutDoc("/BaseFont /"+face.psName().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" )+"\n");
+			PutDoc("/Encoding << \n");
+			PutDoc("/Differences [ \n");
+			PutDoc("24 /breve /caron /circumflex /dotaccent /hungarumlaut /ogonek /ring /tilde\n");
+			PutDoc("39 /quotesingle 96 /grave 128 /bullet /dagger /daggerdbl /ellipsis /emdash /endash /florin /fraction /guilsinglleft /guilsinglright\n");
+			PutDoc("/minus /perthousand /quotedblbase /quotedblleft /quotedblright /quoteleft /quoteright /quotesinglbase /trademark /fi /fl /Lslash /OE /Scaron\n");
+			PutDoc("/Ydieresis /Zcaron /dotlessi /lslash /oe /scaron /zcaron 164 /currency 166 /brokenbar 168 /dieresis /copyright /ordfeminine 172 /logicalnot\n");
+			PutDoc("/.notdef /registered /macron /degree /plusminus /twosuperior /threesuperior /acute /mu 183 /periodcentered /cedilla /onesuperior /ordmasculine\n");
+			PutDoc("188 /onequarter /onehalf /threequarters 192 /Agrave /Aacute /Acircumflex /Atilde /Adieresis /Aring /AE /Ccedilla /Egrave /Eacute /Ecircumflex\n");
+			PutDoc("/Edieresis /Igrave /Iacute /Icircumflex /Idieresis /Eth /Ntilde /Ograve /Oacute /Ocircumflex /Otilde /Odieresis /multiply /Oslash\n");
+			PutDoc("/Ugrave /Uacute /Ucircumflex /Udieresis /Yacute /Thorn /germandbls /agrave /aacute /acircumflex /atilde /adieresis /aring /ae /ccedilla\n");
+			PutDoc("/egrave /eacute /ecircumflex /edieresis /igrave /iacute /icircumflex /idieresis /eth /ntilde /ograve /oacute /ocircumflex /otilde /odieresis\n");
+			PutDoc("/divide /oslash /ugrave /uacute /ucircumflex /udieresis /yacute /thorn /ydieresis\n");
+			PutDoc("] >>\n");
+			PutDoc("/FirstChar 0\n");
+			PutDoc("/LastChar 255\n");
+			PutDoc("/Widths "+QString::number(fontWidthsForm)+" 0 R\n");
+			PutDoc("/FontDescriptor "+QString::number(FontDes)+" 0 R\n");
+			PutDoc(">>\nendobj\n");
 		}
 		a++;
 	}




More information about the scribus-commit mailing list