r24845 by jghali - Remove unused embedFont() function from ScFace*

scribus-commit scribus-commit at lists.scribus.net
Sat Jan 29 23:29:45 UTC 2022


Author: jghali
Date: Sat Jan 29 23:29:45 2022
New Revision: 24845

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24845
Log:
Remove unused embedFont() function from ScFace*

Modified:
    trunk/Scribus/scribus/fonts/scface.cpp
    trunk/Scribus/scribus/fonts/scface.h
    trunk/Scribus/scribus/fonts/scface_ps.cpp
    trunk/Scribus/scribus/fonts/scface_ps.h
    trunk/Scribus/scribus/fonts/scface_ttf.cpp
    trunk/Scribus/scribus/fonts/scface_ttf.h

Modified: trunk/Scribus/scribus/fonts/scface.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24845&path=/trunk/Scribus/scribus/fonts/scface.cpp
==============================================================================
--- trunk/Scribus/scribus/fonts/scface.cpp	(original)
+++ trunk/Scribus/scribus/fonts/scface.cpp	Sat Jan 29 23:29:45 2022
@@ -475,13 +475,6 @@
 	return false;
 }
 
-bool ScFace::embedFont(QByteArray &str)
-{
-	if (m_m->status == ScFace::UNKNOWN)
-		m_m->load();
-	return m_m->embedFont(str);
-}
-
 bool ScFace::glyphNames(FaceEncoding& gList)
 {
 	if (m_m->status == ScFace::UNKNOWN)

Modified: trunk/Scribus/scribus/fonts/scface.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24845&path=/trunk/Scribus/scribus/fonts/scface.h
==============================================================================
--- trunk/Scribus/scribus/fonts/scface.h	(original)
+++ trunk/Scribus/scribus/fonts/scface.h	Sat Jan 29 23:29:45 2022
@@ -195,7 +195,6 @@
 		virtual cid_type glyphIndexToCID(ScFace::gid_type index) const { return index; }
 		virtual QMap<QString,QString> fontDictionary(qreal sz=1.0) const;
 		virtual GlyphMetrics glyphBBox(gid_type gl, qreal sz) const;
-		virtual bool embedFont(QByteArray &/*str*/)       const { return false; }
 		virtual void rawData(QByteArray & /*bb*/)      const {}
 		virtual FT_Face ftFace() const { return nullptr; }
 		virtual void* hbFont();
@@ -237,8 +236,6 @@
 	bool operator==(const ScFace& other) const ;
 	bool operator!=(const ScFace& other) const { return ! (*this == other); }
 
-
-	bool embedFont(QByteArray &str);
 	void rawData(QByteArray & bb);
 	bool glyphNames(FaceEncoding& gList);
 

Modified: trunk/Scribus/scribus/fonts/scface_ps.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24845&path=/trunk/Scribus/scribus/fonts/scface_ps.cpp
==============================================================================
--- trunk/Scribus/scribus/fonts/scface_ps.cpp	(original)
+++ trunk/Scribus/scribus/fonts/scface_ps.cpp	Sat Jan 29 23:29:45 2022
@@ -141,89 +141,8 @@
 	formatCode = ScFace::PFB;
 }
 
-bool ScFace_PFB::embedFont(QByteArray& str) const
-{
-	QByteArray bb;
-	rawData(bb);
-	if ((bb.size() > 2) &&  (bb[0] == '\x80') && (static_cast<int>(bb[1]) == 1))
-	{
-		int posi,cxxc=0;
-		for (posi = 6; posi < bb.size(); ++posi)
-		{
-			if ((bb[posi] == '\x80') && (posi + 1 < bb.size()) && (static_cast<int>(bb[posi + 1]) == 2))
-				break;
-			str += bb[posi];
-		}
-		int ulen;
-		if (posi + 6 < bb.size())
-		{
-			ulen = bb[posi + 2] & 0xff;
-			ulen |= (bb[posi + 3] << 8) & 0xff00;
-			ulen |= (bb[posi + 4] << 16) & 0xff0000;
-			ulen |= (bb[posi + 5] << 24) & 0xff000000;
-			posi += 6;
-			if (posi + ulen > bb.size())
-				ulen = bb.size() - posi - 1;
-			char linebuf[80];
-			cxxc = 0;
-			for (int j = 0; j < ulen; ++j)
-			{
-				unsigned char u = bb[posi];
-				linebuf[cxxc] = ((u >> 4) & 15) + '0';
-				if (u>0x9f)
-					linebuf[cxxc] += 'a'-':';
-				++cxxc;
-				u &= 15;
-				linebuf[cxxc] = u + '0';
-				if (u>0x9)
-					linebuf[cxxc] += 'a'-':';
-				++posi;
-				++cxxc;
-				if (cxxc > 72)
-				{
-					linebuf[cxxc++] = '\n';
-					linebuf[cxxc++] = 0;
-					str += linebuf;
-					cxxc = 0;
-				}
-			}
-			linebuf[cxxc] = 0;
-			str += linebuf;
-			str += "\n";
-		}
-		posi += 6;
-		for (int j = posi; j < bb.size(); ++j)
-		{
-			if ((bb[j] == '\x80') && (j + 1 < bb.size()) && (static_cast<int>(bb[j + 1]) == 3))
-				break;
-			if (bb[j] == '\r')
-				str += "\n";
-			else
-				str += bb[j];
-		}
-		str += "\n";
-		return true;
-	}
-	qDebug("%s", QObject::tr("Font %1 cannot be read, no embedding").arg(fontFile).toLatin1().constData());
-	return false;
-}
-
 ScFace_PFA::ScFace_PFA(const QString& fam, const QString& sty, const QString& alt, const QString& scname, const QString& psname, const QString& path, int face, const QStringList& features) :
 	ScFace_PostScript(fam, sty, alt, scname, psname, path, face, features)
 {
 	formatCode = ScFace::PFA;
 }
-
-bool ScFace_PFA::embedFont(QByteArray& str) const
-{
-	QByteArray bb;
-	rawData(bb);
-	if (bb.size() > 2 && bb[0] == '%' && bb[1] == '!')
-	{
-		// this is ok since bb will not contain '\0'
-		str.append(bb);
-		return true;
-	}
-	qDebug("%s", QObject::tr("Font %1 cannot be read, no embedding").arg(fontFile).toLatin1().constData());
-	return false;
-}

Modified: trunk/Scribus/scribus/fonts/scface_ps.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24845&path=/trunk/Scribus/scribus/fonts/scface_ps.h
==============================================================================
--- trunk/Scribus/scribus/fonts/scface_ps.h	(original)
+++ trunk/Scribus/scribus/fonts/scface_ps.h	Sat Jan 29 23:29:45 2022
@@ -43,29 +43,25 @@
 /*
 	Class ScFace_pfb
 	Subclass of ScFace, specifically for Adobe type 1 .pfb fonts.
-	Implements: realName() and embedFont().
+	Implements: realName().
 */
 
 class ScFace_PFB : public ScFace_PostScript
 {
 	public:
 		ScFace_PFB(const QString& fam, const QString& sty, const QString& alt, const QString& scname, const QString& psname, const QString& path, int face, const QStringList& features);
-
-		bool embedFont(QByteArray &str) const override;
 };
 
 /*
 	Class ScFace_pfa
 	Subclass of ScFace, specifically for Adobe type 1 and type 3 .pfa fonts.
-	Implements: realName() and embedFont().
+	Implements: realName().
 */
 
 class ScFace_PFA : public ScFace_PostScript
 {
 	public:
 		ScFace_PFA(const QString& fam, const QString& sty, const QString& alt, const QString& scname, const QString& psname, const QString& path, int face, const QStringList& features);
-
-		bool embedFont(QByteArray &str) const override;
 };
 
 

Modified: trunk/Scribus/scribus/fonts/scface_ttf.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24845&path=/trunk/Scribus/scribus/fonts/scface_ttf.cpp
==============================================================================
--- trunk/Scribus/scribus/fonts/scface_ttf.cpp	(original)
+++ trunk/Scribus/scribus/fonts/scface_ttf.cpp	Sat Jan 29 23:29:45 2022
@@ -173,105 +173,3 @@
 	else
 		FtFace::rawData(bb);
 }
-
-bool ScFace_ttf::embedFont(QByteArray &str) const
-{
-	QByteArray bb;
-	FtFace::rawData(bb);
-	if (formatCode == ScFace::TYPE42)
-	{
-		//easy:
-		str = bb;
-		return true;
-	}
-
-	int counter = 0;
-	char *buf[50];
-	FT_ULong charcode;
-	FT_UInt gindex;
-	FT_Face face = ftFace();
-	if (!face)
-		return false;
-	const FT_Stream fts = face->stream;
-	if (ftIOFunc(fts, 0L, nullptr, 0))
-		return(false);
-
-	str += "%!PS-TrueTypeFont\n";
-	str += "11 dict begin\n";
-	str += "/FontName /" + psName + " def\n";
-	str += "/Encoding /ISOLatin1Encoding where {pop ISOLatin1Encoding} {StandardEncoding} ifelse def\n";
-	str += "/PaintType 0 def\n/FontMatrix [1 0 0 1 0 0] def\n";
-	str += "/FontBBox [" + m_pdfFontBBox + "] def\n";
-	str += "/FontType 42 def\n";
-	str += "/FontInfo 8 dict dup begin\n";
-	str += "/FamilyName (" + psName + ") def\n";
-	str += "end readonly def\n";
-	unsigned char *tmp = new unsigned char[65535];
-	int length;
-	char linebuf[80];
-	str += "/sfnts [";
-	int poso = 0;
-	do
-	{
-		int posi = 0;
-		length = fts->size - fts->pos;
-		if (length > 65534)
-			length = 65534;
-		if (!ftIOFunc(fts, 0L, tmp, length))
-		{
-			str += "\n<\n";
-			for (int j = 0; j < length; j++)
-			{
-				unsigned char u = tmp[posi];
-				linebuf[poso] = ((u >> 4) & 15) + '0';
-				if (u > 0x9f)
-					linebuf[poso] += 'a'-':';
-				++poso;
-				u &= 15;
-				linebuf[poso] = u + '0';
-				if (u > 0x9)
-					linebuf[poso] += 'a'-':';
-				++posi;
-				++poso;
-				if (poso > 70)
-				{
-					linebuf[poso++] = '\n';
-					linebuf[poso++] = 0;
-					str += linebuf;
-					poso = 0;
-				}
-			}
-			linebuf[poso++] = 0;
-			str += linebuf;
-			poso = 0;
-			str += "00\n>";
-		}
-		else
-		{
-			sDebug(QObject::tr("Font %1 is broken (read stream), no embedding").arg(fontFile));
-			str += "\n] def\n";
-			status = qMax(status,ScFace::BROKENGLYPHS);
-			return false;
-		}
-	}
-	while (length == 65534);
-	
-	str += "\n] def\n";
-	delete[] tmp;
-	gindex = 0;
-	charcode = FT_Get_First_Char(face, &gindex );
-	QString tmp2, tmp3, tmp4;
-	while (gindex != 0)
-	{
-		FT_Get_Glyph_Name(face, gindex, buf, 50);
-		tmp2 += "/"+QString(reinterpret_cast<char*>(buf)) + " " + tmp3.setNum(gindex) + " def\n";
-		charcode = FT_Get_Next_Char(face, charcode, &gindex );
-		counter++;
-	}
-	tmp4.setNum(counter);
-	str += "/CharStrings " + tmp4 + " dict dup begin\n" + tmp2;
-	str += "end readonly def\n";
-	str += "FontName currentdict end definefont pop\n";
-	return(true);
-}
-

Modified: trunk/Scribus/scribus/fonts/scface_ttf.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24845&path=/trunk/Scribus/scribus/fonts/scface_ttf.h
==============================================================================
--- trunk/Scribus/scribus/fonts/scface_ttf.h	(original)
+++ trunk/Scribus/scribus/fonts/scface_ttf.h	Sat Jan 29 23:29:45 2022
@@ -15,7 +15,7 @@
 /*
 	Class ScFace_ttf
 	Subclass of ScFace, specifically for TrueType fonts.
-	Implements: realName() and embedFont().
+	Implements: realName().
 */
 
 class SCRIBUS_API ScFace_ttf : public FtFace
@@ -27,7 +27,6 @@
 	void load () const override;
 	void unload () const override;
 
-	bool embedFont(QByteArray &str) const override;
 	void rawData(QByteArray & bb) const override;
 	
 	bool glyphNames(ScFace::FaceEncoding& glyphList) const override;




More information about the scribus-commit mailing list