r22312 by jghali -

scribus-commit scribus-commit at lists.scribus.net
Sat Dec 30 20:45:43 UTC 2017


Author: jghali
Date: Sat Dec 30 20:45:43 2017
New Revision: 22312

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22312
Log:
refactoring of ODTIm::constructFontName()

Modified:
    trunk/Scribus/scribus/plugins/gettext/odt2im/importodt.cpp

Modified: trunk/Scribus/scribus/plugins/gettext/odt2im/importodt.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22312&path=/trunk/Scribus/scribus/plugins/gettext/odt2im/importodt.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/gettext/odt2im/importodt.cpp	(original)
+++ trunk/Scribus/scribus/plugins/gettext/odt2im/importodt.cpp	Sat Dec 30 20:45:43 2017
@@ -1327,64 +1327,59 @@
 
 QString ODTIm::constructFontName(QString fontBaseName, QString fontStyle)
 {
-	QString fontName = "";
-	bool found = false;
+	QString fontName;
 	SCFontsIterator it(PrefsManager::instance()->appPrefs.fontPrefs.AvailFonts);
 	for ( ; it.hasNext(); it.next())
 	{
-		if (fontBaseName.toLower() == it.current().family().toLower())
-		{
-			// found the font family, now go for the style
-			QStringList slist = PrefsManager::instance()->appPrefs.fontPrefs.AvailFonts.fontMap[it.current().family()];
-			slist.sort();
-			if (slist.count() > 0)
-			{
-				for (int a = 0; a < slist.count(); a++)
-				{
-					if (fontStyle.toLower() == slist[a].toLower())
-					{
-						found = true;
-						fontName = it.current().family() + " " + slist[a];
-						break;
-					}
-				}
-				if (!found)
-				{
-					int reInd = slist.indexOf("Regular");
-					if (reInd < 0)
-						fontName = it.current().family() + " " + slist[0];
-					else
-						fontName = it.current().family() + " " + slist[reInd];
-					found = true;
-				}
-			}
+		if (fontBaseName.toLower() != it.current().family().toLower())
+			continue;
+
+		// found the font family, now go for the style
+		QStringList slist = PrefsManager::instance()->appPrefs.fontPrefs.AvailFonts.fontMap[it.current().family()];
+		slist.sort();
+		if (slist.count() > 0)
+		{
+			for (int a = 0; a < slist.count(); a++)
+			{
+				if (fontStyle.toLower() == slist[a].toLower())
+				{
+					fontName = it.current().family() + " " + slist[a];
+					return fontName;
+				}
+			}
+			int reInd = slist.indexOf("Regular");
+			if (reInd < 0)
+				fontName = it.current().family() + " " + slist[0];
 			else
-			{
-				fontName = it.current().family();
-				found = true;
-			}
-			break;
-		}
-	}
-	if (!found)
-	{
-		QString family = fontBaseName;
-		if (!fontStyle.isEmpty())
-			family += " " + fontStyle;
-		if (!PrefsManager::instance()->appPrefs.fontPrefs.GFontSub.contains(family))
-		{
-			qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
-			QScopedPointer<MissingFont> dia(new MissingFont(0, family, m_Doc));
-			if (dia->exec())
-				fontName = dia->getReplacementFont();
-			else
-				fontName = m_Doc->itemToolPrefs().textFont;
-			qApp->changeOverrideCursor(QCursor(Qt::WaitCursor));
-			PrefsManager::instance()->appPrefs.fontPrefs.GFontSub[family] = fontName;
+				fontName = it.current().family() + " " + slist[reInd];
+			return fontName;
 		}
 		else
-			fontName = PrefsManager::instance()->appPrefs.fontPrefs.GFontSub[family];
-	}
+		{
+			fontName = it.current().family();
+			return fontName;
+		}
+	}
+
+	// Still no font found
+	QString family = fontBaseName;
+	if (!fontStyle.isEmpty())
+		family += " " + fontStyle;
+	if (PrefsManager::instance()->appPrefs.fontPrefs.GFontSub.contains(family))
+	{
+		fontName = PrefsManager::instance()->appPrefs.fontPrefs.GFontSub[family];
+		return fontName;
+	}
+
+	qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
+	QScopedPointer<MissingFont> dia(new MissingFont(0, family, m_Doc));
+	if (dia->exec())
+		fontName = dia->getReplacementFont();
+	else
+		fontName = m_Doc->itemToolPrefs().textFont;
+	PrefsManager::instance()->appPrefs.fontPrefs.GFontSub[family] = fontName;
+	qApp->changeOverrideCursor(QCursor(Qt::WaitCursor));
+
 	return fontName;
 }
 




More information about the scribus-commit mailing list