r15999 by pierremarc - Integrated Fribidi. Text engine is now expected to support bidirectional texts.

scribus-commit scribus-commit at lists.scribus.net
Fri Nov 26 14:10:58 CET 2010


Author: pierremarc
Date: Fri Nov 26 13:10:58 2010
New Revision: 15999

URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=15999
Log:
Integrated Fribidi. Text engine is now expected to support bidirectional texts. 

Modified:
    branches/ScribusOIF/scribus/fonts/scface_ttf.cpp
    branches/ScribusOIF/scribus/text/blocklayouter.cpp
    branches/ScribusOIF/scribus/text/boxes.cpp
    branches/ScribusOIF/scribus/text/glyphstore.cpp
    branches/ScribusOIF/scribus/text/shaper.cpp

Modified: branches/ScribusOIF/scribus/fonts/scface_ttf.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15999&path=/branches/ScribusOIF/scribus/fonts/scface_ttf.cpp
==============================================================================
--- branches/ScribusOIF/scribus/fonts/scface_ttf.cpp (original)
+++ branches/ScribusOIF/scribus/fonts/scface_ttf.cpp Fri Nov 26 13:10:58 2010
@@ -833,11 +833,11 @@
 					charList << indices[gIdx];
 					markList << isDiacritic;
 				}
-				qDebug()<<"icu"<<indices[gIdx]
-						<< curGlyph.glyph
-						<< sHeight
-						<< icuY
-						<< icuFwdY ;
+//				qDebug()<<"icu"<<indices[gIdx]
+//						<< curGlyph.glyph
+//						<< sHeight
+//						<< icuY
+//						<< icuFwdY ;
 			}
 		}
 		icuLE->reset();

Modified: branches/ScribusOIF/scribus/text/blocklayouter.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15999&path=/branches/ScribusOIF/scribus/text/blocklayouter.cpp
==============================================================================
--- branches/ScribusOIF/scribus/text/blocklayouter.cpp (original)
+++ branches/ScribusOIF/scribus/text/blocklayouter.cpp Fri Nov 26 13:10:58 2010
@@ -97,7 +97,7 @@
 			lResult = lineR.first();
 
 
-		qDebug()<<"\t"<<curPos<<lResult.endPos;
+		qDebug()<<"RESULT\t"<<curPos<<lResult.endPos;
 		if(gs->findItem(curPos) == gs->findItem(lResult.endPos)) // Case where the's only 1 item for the whole line
 		{
 			GlyphBox * glyphs(new GlyphBox(const_cast<GlyphStore*>(gs),
@@ -118,14 +118,17 @@
 			int item(gs->findItem(curPos));
 			bool itemIsRTL(story->charAttributes(gs->itemTextPosition(item)).testFlag(TextFlag_RightToLeft));
 			int c(curPos);
-			int e(qMin(int( c + gs->itemCharCount(item)),  lResult.endPos));
+			// Think that the cursor is not necessarily at the begining of the item
+			int e(qMin(int( c + gs->itemCharCount(item) - (c - gs->itemTextPosition(item))),  lResult.endPos));
+			qDebug()<<"Cursor"<<c<<"Found Item"<<item<<"End"<<e;
 			QList<int> sameDirectionItems;
 			sameDirectionItems << item;
 			while(e < lResult.endPos)
 			{
-				c = e+1;
+				c = e;
 				item = gs->findItem(c);
 				e = qMin(int(gs->itemCharCount(item) + c), lResult.endPos);
+				qDebug()<<"Cursor"<<c<<"Found Item"<<item<<"End"<<e;
 				if(itemIsRTL != story->charAttributes(gs->itemTextPosition(item)).testFlag(TextFlag_RightToLeft))
 				{
 					runs << sameDirectionItems;
@@ -159,7 +162,19 @@
 				if(first)
 				{
 					first = false;
-					// cPosX is already setup
+					if(paragraphIsRTL == itemIsRTL) // do not forget that atm what's stored in itemIsRTL is the inversed of current direction
+					{
+						foreach(const int& it, iList)
+						{
+							int c(qMax(gs->itemTextPosition(it), curPos));
+							int e(qMin(int(gs->itemCharCount(it) + c - (c - gs->itemTextPosition(it))),  lResult.endPos));
+							double itemWidth(gs->itemWidth(it, c - gs->itemTextPosition(it), e - c + 1));
+							if(paragraphIsRTL)
+								cPosX -= itemWidth;
+							else
+								cPosX += itemWidth;
+						}
+					}
 				}
 				else
 				{
@@ -174,7 +189,7 @@
 							foreach(const int& it, iList)
 							{
 								int c(qMax(gs->itemTextPosition(it), curPos));
-								int e(qMin(int(gs->itemCharCount(item) + c),  lResult.endPos));
+								int e(qMin(int(gs->itemCharCount(it) + c - (c - gs->itemTextPosition(it))),  lResult.endPos));
 								double itemWidth(gs->itemWidth(it, c - gs->itemTextPosition(it), e - c + 1));
 								cPosX -= itemWidth;
 							}
@@ -191,7 +206,7 @@
 							foreach(const int& it, iList)
 							{
 								int c(qMax(gs->itemTextPosition(it), curPos));
-								int e(qMin(int(gs->itemCharCount(item) + c),  lResult.endPos));
+								int e(qMin(int(gs->itemCharCount(it) + c - (c - gs->itemTextPosition(it))),  lResult.endPos));
 								double itemWidth(gs->itemWidth(it, c - gs->itemTextPosition(it), e - c + 1));
 								cPosX -= itemWidth;
 							}
@@ -207,7 +222,7 @@
 				foreach(const int& it, iList)
 				{
 					int c(qMax(gs->itemTextPosition(it), curPos));
-					int e(qMin(int(gs->itemCharCount(it) + c),  lResult.endPos));
+					int e(qMin(int(gs->itemCharCount(it) + c - (c - gs->itemTextPosition(it))),  lResult.endPos));
 					double itemWidth(gs->itemWidth(it, c - gs->itemTextPosition(it), e - c + 1));
 					iListWidth += itemWidth;
 					GlyphBox * glyphs(new GlyphBox(const_cast<GlyphStore*>(gs),  m_textFrame->doc()->PageColors, it, c, e));

Modified: branches/ScribusOIF/scribus/text/boxes.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15999&path=/branches/ScribusOIF/scribus/text/boxes.cpp
==============================================================================
--- branches/ScribusOIF/scribus/text/boxes.cpp (original)
+++ branches/ScribusOIF/scribus/text/boxes.cpp Fri Nov 26 13:10:58 2010
@@ -452,7 +452,7 @@
 		strokeColor.setAlphaF(shade / 100.0);
 		p->setPen(strokeColor, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
 	}
-qDebug() << "Render"<<m_item<<m_charStart<<m_charEnd;
+//qDebug() << "Render"<<m_item<<m_charStart<<m_charEnd;
 	Cluster cluster(m_glyphs->itemStart(m_item));
 	while(cluster.textPosition() <= m_charEnd)
 	{
@@ -477,6 +477,8 @@
 			{
 				p->translate(- (layout->xoffset + layout->xadvance), 0);
 			}
+			else
+				p->translate(layout->xoffset, 0);
 			//		qDebug() << "render pos"<< cluster.textPosition()<<"glyph" << glyph << "width" << layout->xadvance  << "font" << style.font().scName() << "@" << x() << y() ;
 			if ((renderOptions.showControls) &&
 			    (glyph == style.font().char2CMap(QChar(' ')) || glyph >=  ScFace::CONTROL_GLYPHS))
@@ -535,7 +537,7 @@
 		 }
 		 */
 			if(!rtl)
-				p->translate(layout->xadvance + layout->xoffset, 0);
+				p->translate(layout->xadvance, 0);
 		}
 		if(m_glyphs->haveNext(cluster))
 			cluster = m_glyphs->next(cluster);

Modified: branches/ScribusOIF/scribus/text/glyphstore.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15999&path=/branches/ScribusOIF/scribus/text/glyphstore.cpp
==============================================================================
--- branches/ScribusOIF/scribus/text/glyphstore.cpp (original)
+++ branches/ScribusOIF/scribus/text/glyphstore.cpp Fri Nov 26 13:10:58 2010
@@ -256,12 +256,12 @@
 	else
 	{
 		Cluster cluster(itemStart(i));
-		unsigned int limit(item.textPosition + len);
+		unsigned int limit(item.textPosition + start + len);
 		unsigned int ctp(0);
 		while(true)
 		{
 			ctp = cluster.textPosition();
-			if(ctp < start)
+			if(ctp < (item.textPosition + start))
 			{
 				if(haveNext(cluster))
 					cluster = next(cluster);
@@ -352,8 +352,8 @@
 	const ItemData& item(m_items[i]);
 	int glyphIndex = (clusterStart - m_glyphs.data());
 	int delta = (charPos - item.textPosition) - (glyphIndex - item.glyphIndex);
-	if (delta != 0)
-		qDebug() << "markCluster: delta" << charPos-item.textPosition << "~" << glyphIndex-item.glyphIndex;
+//	if (delta != 0)
+//		qDebug() << "markCluster: delta" << charPos-item.textPosition << "~" << glyphIndex-item.glyphIndex;
 //	m_clusterOffsets.insert(glyphIndex, m_clusterRuns.insert(charPos));
 	m_clusterOffsets.insert(charPos, glyphIndex);
 //	uint run = m_clusterRuns[glyphIndex];

Modified: branches/ScribusOIF/scribus/text/shaper.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15999&path=/branches/ScribusOIF/scribus/text/shaper.cpp
==============================================================================
--- branches/ScribusOIF/scribus/text/shaper.cpp (original)
+++ branches/ScribusOIF/scribus/text/shaper.cpp Fri Nov 26 13:10:58 2010
@@ -71,13 +71,15 @@
 				{
 					ref = story->charStyle(cursor) ;
 					items << gs->addItem(itStart, (cursor) - itStart);
+					QString itemStr(story->text(itStart, (cursor) - itStart ));
+					qDebug()<<"ADD ITEM"<<itStart<<(cursor) - itStart <<itemStr;
 				}
 				else
 				{
 					items << gs->addItem(itStart, (cursor) - itStart + 1);
+					QString itemStr(story->text(itStart, (cursor) - itStart + 1));
+					qDebug()<<"ADD ITEM"<<itStart<<(cursor) - itStart + 1<<itemStr;
 				}
-//				QString itemStr(story->text(itStart, (cursor) - itStart + 1));
-//				qDebug()<<"ADD ITEM"<<itStart<<(cursor) - itStart + 1<<itemStr;
 				itStart = cursor;
 			}
 		}




More information about the scribus-commit mailing list