r19319 by jghali - refactoring of scfontmetrics GlyNames() to improve readability

scribus-commit scribus-commit at lists.scribus.net
Sun Jul 6 13:56:40 UTC 2014


Author: jghali
Date: Sun Jul  6 13:56:40 2014
New Revision: 19319

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19319
Log:
refactoring of scfontmetrics GlyNames() to improve readability

Modified:
    branches/Version14x/Scribus/scribus/fonts/scfontmetrics.cpp

Modified: branches/Version14x/Scribus/scribus/fonts/scfontmetrics.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19319&path=/branches/Version14x/Scribus/scribus/fonts/scfontmetrics.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/fonts/scfontmetrics.cpp (original)
+++ branches/Version14x/Scribus/scribus/fonts/scfontmetrics.cpp Sun Jul  6 13:56:40 2014
@@ -381,32 +381,33 @@
 			
 		charcode = FT_Get_Next_Char(face, charcode, &gindex );
 	}
+
+	if (!hasPSNames)
+		return true;
+
 	// Let's see if we can find some more...
 	int maxSlot1 = face->num_glyphs;
-	if (hasPSNames)
-		for (int gindex = 1; gindex < maxSlot1; ++gindex)
-		{
-			if (!GList.contains(gindex))
+	for (int gindex = 1; gindex < maxSlot1; ++gindex)
+	{
+		if (GList.contains(gindex))
+			continue;
+		if (FT_Get_Glyph_Name(face, gindex, &buf, 50))
+			continue;
+
+		QString glyphname(reinterpret_cast<char*>(buf));
+		charcode = 0;
+		QMap<uint,std::pair<QChar,QString> >::Iterator gli;
+		for (gli = GList.begin(); gli != GList.end(); ++gli)
+		{
+			if (glyphname == gli.value().second)
 			{
-				bool found = ! FT_Get_Glyph_Name(face, gindex, &buf, 50);
-				if (found)
-				{
-					QString glyphname(reinterpret_cast<char*>(buf));
-					charcode = 0;
-					QMap<uint,std::pair<QChar,QString> >::Iterator gli;
-					for (gli = GList.begin(); gli != GList.end(); ++gli)
-					{
-						if (glyphname == gli.value().second)
-						{
-							charcode = gli.value().first.unicode();
-							break;
-						}
-					}
-//					qDebug() << "\tmore: " << gindex << " '" << charcode << "' --> '" << buf << "'";
-					GList.insert(gindex, std::make_pair(QChar(static_cast<uint>(charcode)), glyphname));
-				}
+				charcode = gli.value().first.unicode();
+				break;
 			}
 		}
+//			qDebug() << "\tmore: " << gindex << " '" << charcode << "' --> '" << buf << "'";
+		GList.insert(gindex, std::make_pair(QChar(static_cast<uint>(charcode)), glyphname));
+	}
 			
 	return true;
 }




More information about the scribus-commit mailing list