r19325 by jghali - some refactoring in scface_ttf to remove unnecessary level of indentation and fix some code style issues

scribus-commit scribus-commit at lists.scribus.net
Sun Jul 6 21:05:15 UTC 2014


Author: jghali
Date: Sun Jul  6 21:05:15 2014
New Revision: 19325

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19325
Log:
some refactoring in scface_ttf to remove unnecessary level of indentation and fix some code style issues

Modified:
    trunk/Scribus/scribus/fonts/scface_ttf.cpp

Modified: trunk/Scribus/scribus/fonts/scface_ttf.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19325&path=/trunk/Scribus/scribus/fonts/scface_ttf.cpp
==============================================================================
--- trunk/Scribus/scribus/fonts/scface_ttf.cpp (original)
+++ trunk/Scribus/scribus/fonts/scface_ttf.cpp Sun Jul  6 21:05:15 2014
@@ -65,50 +65,46 @@
 
 double KernFeature::getPairValue ( unsigned int glyph1, unsigned int glyph2 ) const
 {
-	if ( m_valid )
-	{
-
-		if ( pairs.contains( glyph1 )
-				&& pairs[glyph1].contains(glyph2))
-		{
-			return pairs[glyph1][glyph2];
-		}
-		else
-		{
-			//qDebug()<<"Search in classes";
-			foreach (const quint16& coverageId, coverages.keys())
-			{
-				// for each pairpos table, coverage lists covered _first_ (left) glyph
-				if(coverages[coverageId].contains(glyph1))
-				{
-					foreach(const quint16& classDefOffset, classGlyphFirst[coverageId].keys())
+	if (!m_valid)
+		return 0.0;
+
+	if (pairs.contains(glyph1) && 
+		pairs[glyph1].contains(glyph2))
+	{
+		return pairs[glyph1][glyph2];
+	}
+
+	//qDebug()<<"Search in classes";
+	foreach (const quint16& coverageId, coverages.keys())
+	{
+		// for each pairpos table, coverage lists covered _first_ (left) glyph
+		if (!coverages[coverageId].contains(glyph1))
+			continue;
+
+		foreach(const quint16& classDefOffset, classGlyphFirst[coverageId].keys())
+		{
+			const ClassDefTable& cdt(classGlyphFirst[coverageId][classDefOffset]);
+			foreach(const quint16& classIndex, cdt.keys())
+			{
+				const QList<quint16>& gl(cdt[classIndex]);
+				if (!gl.contains(glyph1))
+					continue;
+				//qDebug()<<"Found G1"<<glyph1<<"in Class"<<classIndex<<"at pos"<<gl.indexOf(glyph1);
+				// Now we got the index of the first glyph class, see if glyph2 is in one of the left glyphs classes attached to this subtable.
+				foreach(const quint16& classDefOffset2, classGlyphSecond[coverageId].keys())
+				{
+					const ClassDefTable& cdt2(classGlyphSecond[coverageId][classDefOffset2]);
+					foreach(const quint16& classIndex2, cdt2.keys())
 					{
-						const ClassDefTable& cdt(classGlyphFirst[coverageId][classDefOffset]);
-						foreach(const quint16& classIndex, cdt.keys())
+						const QList<quint16>& gl2(cdt2[classIndex2]);
+						if (gl2.contains(glyph2))
 						{
-							const QList<quint16>& gl(cdt[classIndex]);
-							if(gl.contains(glyph1))
-							{
-								//qDebug()<<"Found G1"<<glyph1<<"in Class"<<classIndex<<"at pos"<<gl.indexOf(glyph1);
-								// Now we got the index of the first glyph class, see if glyph2 is in one of the left glyphs classes attached to this subtable.
-								foreach(const quint16& classDefOffset2, classGlyphSecond[coverageId].keys())
-								{
-									const ClassDefTable& cdt2(classGlyphSecond[coverageId][classDefOffset2]);
-									foreach(const quint16& classIndex2, cdt2.keys())
-									{
-										const QList<quint16>& gl2(cdt2[classIndex2]);
-										if(gl2.contains(glyph2))
-										{
-											//qDebug()<<"Found G2"<<glyph2<<"in Class"<<classIndex2<<"at pos"<<gl2.indexOf(glyph2);
-
-											double v(classValue[coverageId][classIndex][classIndex2]);
-											// Cache this pair into "pairs" map.
-											pairs[glyph1][glyph2] = v;
-											return v;
-										}
-									}
-								}
-							}
+							//qDebug()<<"Found G2"<<glyph2<<"in Class"<<classIndex2<<"at pos"<<gl2.indexOf(glyph2);
+
+							double v(classValue[coverageId][classIndex][classIndex2]);
+							// Cache this pair into "pairs" map.
+							pairs[glyph1][glyph2] = v;
+							return v;
 						}
 					}
 				}
@@ -249,14 +245,13 @@
 				quint16 PairSetOffset ( toUint16 ( subtableOffset +10 + ( 2 * psIdx ) ) +  subtableOffset );
 				quint16 PairValueCount ( toUint16 ( PairSetOffset ) );
 				quint16 PairValueRecord ( PairSetOffset + 2 );
-				for ( int pvIdx ( 0 );pvIdx < PairValueCount; ++pvIdx )
+				for ( int pvIdx ( 0 ); pvIdx < PairValueCount; ++pvIdx )
 				{
 					quint16 recordBase ( PairValueRecord + ( ( 2 + 2 + 2 ) * pvIdx ) );
 					quint16 SecondGlyph ( toUint16 ( recordBase ) );
 					qint16 Value1 ( toInt16 ( recordBase + 2 ) );
 					pairs[FirstGlyph][SecondGlyph] = double ( Value1 );
 				}
-
 			}
 		}
 		else if ( ValueFormat1 && ( !ValueFormat2 ) )
@@ -267,7 +262,7 @@
 				quint16 PairSetOffset ( toUint16 ( subtableOffset +10 + ( 2 * psIdx ) ) +  subtableOffset );
 				quint16 PairValueCount ( toUint16 ( PairSetOffset ) );
 				quint16 PairValueRecord ( PairSetOffset + 2 );
-				for ( int pvIdx ( 0 );pvIdx < PairValueCount; ++pvIdx )
+				for ( int pvIdx ( 0 ); pvIdx < PairValueCount; ++pvIdx )
 				{
 					quint16 recordBase ( PairValueRecord + ( ( 2 + 2 ) * pvIdx ) );
 					quint16 SecondGlyph ( toUint16 ( recordBase ) );
@@ -303,7 +298,7 @@
 				for ( quint16 C2 ( 0 );C2 < Class2Count; ++C2 )
 				{
 					qint16 Value1 ( toInt16 ( Class2Record + ( C2 * ( 2 * 2 ) ) ) );
-					if(Value1 != 0)
+					if (Value1 != 0)
 					{
 						classValue[subtableOffset][C1][C2] = double ( Value1 );
 					}
@@ -318,7 +313,7 @@
 				for ( quint16 C2 ( 1 );C2 < Class2Count; ++C2 )
 				{
 					qint16 Value1 ( toInt16 ( Class2Record + ( C2 * 2 ) ) );
-					if(Value1 != 0)
+					if (Value1 != 0)
 					{
 						classValue[subtableOffset][C1][C2] = double ( Value1 );
 					}
@@ -337,14 +332,14 @@
 
 KernFeature::ClassDefTable KernFeature::getClass ( bool leftGlyph, quint16 classDefOffset, quint16 coverageId )
 {
-	if(leftGlyph)
-	{
-		if(classGlyphFirst.contains(coverageId) && classGlyphFirst[coverageId].contains(classDefOffset))
+	if (leftGlyph)
+	{
+		if (classGlyphFirst.contains(coverageId) && classGlyphFirst[coverageId].contains(classDefOffset))
 			return classGlyphFirst[coverageId][classDefOffset];
 	}
 	else
 	{
-		if(classGlyphSecond.contains(coverageId) && classGlyphSecond[coverageId].contains(classDefOffset))
+		if (classGlyphSecond.contains(coverageId) && classGlyphSecond[coverageId].contains(classDefOffset))
 			return classGlyphSecond[coverageId][classDefOffset];
 	}
 
@@ -396,15 +391,15 @@
 		qDebug() <<"Unknown Class Table type";
 
 	// if possible (all glyphs are "classed"), avoid to pass through this slow piece of code.
-	if(excludeList.count() != coverages[coverageId].count())
+	if (excludeList.count() != coverages[coverageId].count())
 	{
 		foreach(const quint16& gidx, coverages[coverageId])
 		{
-			if(!excludeList.contains(gidx))
+			if (!excludeList.contains(gidx))
 				ret[0] << gidx;
 		}
 	}
-	if(leftGlyph)
+	if (leftGlyph)
 		classGlyphFirst[coverageId][classDefOffset] = ret;
 	else
 		classGlyphSecond[coverageId][classDefOffset] = ret;
@@ -626,10 +621,10 @@
 			{
 				unsigned char u=tmp[posi];
 				linebuf[poso]=((u >> 4) & 15) + '0';
-				if(u>0x9f) linebuf[poso]+='a'-':';
+				if (u>0x9f) linebuf[poso]+='a'-':';
 				++poso;
 				u&=15; linebuf[poso]=u + '0';
-				if(u>0x9) linebuf[poso]+='a'-':';
+				if (u>0x9) linebuf[poso]+='a'-':';
 				++posi;
 				++poso;
 				if (poso > 70)




More information about the scribus-commit mailing list