r15838 by pierremarc - Made it possible to display a paragraph

scribus-commit scribus-commit at lists.scribus.net
Wed Nov 10 15:31:24 CET 2010


Author: pierremarc
Date: Wed Nov 10 14:31:24 2010
New Revision: 15838

URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=15838
Log:
Made it possible to display a paragraph

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

Modified: branches/ScribusOIF/scribus/fonts/scface_ttf.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15838&path=/branches/ScribusOIF/scribus/fonts/scface_ttf.cpp
==============================================================================
--- branches/ScribusOIF/scribus/fonts/scface_ttf.cpp (original)
+++ branches/ScribusOIF/scribus/fonts/scface_ttf.cpp Wed Nov 10 14:31:24 2010
@@ -795,7 +795,7 @@
 				stackY = positions[ ( ( gIdx + 1 ) * 2 ) + 1];
 				glList << curGlyph;
 				charList << indices[gIdx];
-				qDebug()<<"icu"<<story->text(indices[gIdx],1)<< curGlyph.glyph <<curGlyph.xadvance <<curGlyph.yoffset ;
+				qDebug()<<"icu"<<text.at(indices[gIdx])<< curGlyph.glyph <<curGlyph.xadvance <<curGlyph.yoffset ;
 			}
 		}
 		icuLE->reset();
@@ -809,7 +809,7 @@
 		for(unsigned int i(0); i < glList.count(); ++i)
 		{
 			const GlyphLayout& g(glList.at(i));
-			const le_int32& c(charList.at(i));
+			const le_int32& c(charList.at(i) + gs->itemTextPosition(item));
 			curGlyph->glyph = g.glyph;
 			curGlyph->xadvance = g.xadvance;
 			curGlyph->xoffset = g.xoffset;
@@ -882,7 +882,7 @@
 			curGlyph->yoffset = gp.y_offset;
 			curGlyph->glyph = gi.codepoint;
 
-			gs->markCluster(item, gi.cluster, curGlyph);
+			gs->markCluster(item, gi.cluster + gs->itemTextPosition(item) , curGlyph);
 
 			qDebug()<<"ScFace_ttf::shapeText:" <<curGlyph->glyph <<glyphWidth(gi.codepoint, fSize) <<curGlyph->xadvance <<curGlyph->xoffset;
 

Modified: branches/ScribusOIF/scribus/text/blocklayouter.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15838&path=/branches/ScribusOIF/scribus/text/blocklayouter.cpp
==============================================================================
--- branches/ScribusOIF/scribus/text/blocklayouter.cpp (original)
+++ branches/ScribusOIF/scribus/text/blocklayouter.cpp Wed Nov 10 14:31:24 2010
@@ -75,6 +75,7 @@
 	y += parStyle.lineSpacing();
 
 	VBox * resultBox(new VBox);
+	resultBox->moveTo(x,y);
 	double width(m_textFrame->width());
 	int curPos(startPos);
 	while(curPos < endPos)

Modified: branches/ScribusOIF/scribus/text/boxes.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15838&path=/branches/ScribusOIF/scribus/text/boxes.cpp
==============================================================================
--- branches/ScribusOIF/scribus/text/boxes.cpp (original)
+++ branches/ScribusOIF/scribus/text/boxes.cpp Wed Nov 10 14:31:24 2010
@@ -424,40 +424,6 @@
 
 void GlyphBox::render(ScPainter* p, const RenderOptions& renderOptions) const
 {
-	int first = m_charStart - m_glyphs->itemTextPosition(m_item);
-	int end = m_charEnd - m_glyphs->itemTextPosition(m_item); // wrong, it asserts that there are as many glyphs as characters
-	// the item to be rendered
-	unsigned int rItem(m_item);
-	unsigned int join(0);
-	// First see if first and end matches begining and end of m_item;
-	if((first == 0) && (end == m_glyphs->itemCharCount(m_item)))
-	{
-		rItem = m_item;
-		join = 0;
-	}
-	// test if the run starts with the item but finishes elsewhere
-	else if((first == 0) && (end != m_glyphs->itemCharCount(m_item)))
-	{
-		rItem = m_item;
-		m_glyphs->splitItem(m_item, end - first);
-		join = 1;
-	}
-	// test if the run does not start with the item but finishes with it
-	else if((first != 0) && (end == m_glyphs->itemCharCount(m_item)))
-	{
-		rItem = m_item + 1;
-		m_glyphs->splitItem(m_item, first);
-		join = 1;
-	}
-	// test if the run does not match the item at all
-	else if((first != 0) && (end != m_glyphs->itemCharCount(m_item)))
-	{
-		rItem = m_item + 1;
-		m_glyphs->splitItem(m_item, first);
-		m_glyphs->splitItem(rItem, end - first);
-		join = 2;
-
-	}
 	const CharStyle& style(m_glyphs->story()->charStyle(m_charStart));
 p->save();
 p->setPen(Qt::lightGray);
@@ -490,15 +456,31 @@
 		strokeColor.setAlphaF(shade / 100.0);
 		p->setPen(strokeColor, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
 	}
-	GlyphLayout* layout = m_glyphs->itemGlyphStart(rItem);
-	for (unsigned int i(0); i < m_glyphs->itemGlyphCount(rItem); ++i)
-	{
+
+	Cluster cluster(m_glyphs->itemStart(m_item));
+	while(cluster.textPosition() <= m_charEnd)
+	{
+		if(cluster.textPosition() < m_charStart)
+		{
+			if(m_glyphs->haveNext(cluster))
+			{
+				cluster = m_glyphs->next(cluster);
+				continue;
+			}
+			else
+				break;
+		}
+		GlyphLayout* layout = cluster.glyphs();
 		uint glyph = layout->glyph;
-//		qDebug() << "render glyph" << glyph << "width" << layout->xadvance  << "font" << style.font().scName() << "@" << x() << y() ;
+		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))
 		{
 			layout->renderControlChar(p, renderOptions, style);
+			if(m_glyphs->haveNext(cluster))
+				cluster = m_glyphs->next(cluster);
+			else
+				break;
 			continue;
 		}
 		else if (glyph == (ScFace::CONTROL_GLYPHS + SpecialChars::NBSPACE.unicode()) ||
@@ -509,8 +491,13 @@
 		
 		if (glyph >= ScFace::CONTROL_GLYPHS || (style.effects() & ScStyle_SuppressSpace)) 
 		{
-			qDebug() << "render GlyphBox: skipping" << glyph;
+//			qDebug() << "render GlyphBox: skipping" << glyph;
 			// all those are empty
+
+			if(m_glyphs->haveNext(cluster))
+				cluster = m_glyphs->next(cluster);
+			else
+				break;
 			continue;
 		}
 		//	if (style.font().canRender(QChar(glyph)))
@@ -539,12 +526,13 @@
 		 }
 		 */	
 		p->translate(layout->xadvance, 0);
-		layout++;
+		if(m_glyphs->haveNext(cluster))
+			cluster = m_glyphs->next(cluster);
+		else
+			break;
 	}
 	p->restore();
 
-	for(unsigned int j(0); j < join; ++j)
-		m_glyphs->joinItem(m_item);
 }
 
 

Modified: branches/ScribusOIF/scribus/text/glyphlayout.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15838&path=/branches/ScribusOIF/scribus/text/glyphlayout.cpp
==============================================================================
--- branches/ScribusOIF/scribus/text/glyphlayout.cpp (original)
+++ branches/ScribusOIF/scribus/text/glyphlayout.cpp Wed Nov 10 14:31:24 2010
@@ -51,7 +51,7 @@
 			p->translate(0, -(fontSize / 10.0) * (style.baselineOffset() / 1000.0));
 		double glxSc = scaleH * fontSize / 100.0;
 		double glySc = scaleV * fontSize / 100.0;
-		qDebug() << "renderOutlines: glyph" << glyph << "stroke" << style.strokeColor() << "fill" << style.fillColor() << "scale" << glxSc << glySc << "translate" << xoffset << yoffset - ((fontSize / 10.0) * scaleV);
+//		qDebug() << "renderOutlines: glyph" << glyph << "stroke" << style.strokeColor() << "fill" << style.fillColor() << "scale" << glxSc << glySc << "translate" << xoffset << yoffset - ((fontSize / 10.0) * scaleV);
 
 		p->scale(glxSc, glySc);
 		//			p->setFillMode(1);

Modified: branches/ScribusOIF/scribus/text/glyphstore.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15838&path=/branches/ScribusOIF/scribus/text/glyphstore.cpp
==============================================================================
--- branches/ScribusOIF/scribus/text/glyphstore.cpp (original)
+++ branches/ScribusOIF/scribus/text/glyphstore.cpp Wed Nov 10 14:31:24 2010
@@ -72,7 +72,7 @@
 	return unsigned(m_items.count());		
 }
 
-QList<uint> GlyphStore::findIems(int start, int end) const
+QList<uint> GlyphStore::findItems(int start, int end) const
 {
 	QList<uint> ret;
 	bool first(true);

Modified: branches/ScribusOIF/scribus/text/glyphstore.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15838&path=/branches/ScribusOIF/scribus/text/glyphstore.h
==============================================================================
--- branches/ScribusOIF/scribus/text/glyphstore.h (original)
+++ branches/ScribusOIF/scribus/text/glyphstore.h Wed Nov 10 14:31:24 2010
@@ -166,7 +166,7 @@
 	/// returns the first item that contains textposition 'pos'
 	uint findItem(int pos) const;
 	/// returns a list of items for an interval of text positions
-	QList<uint> findIems(int start, int end) const;
+	QList<uint> findItems(int start, int end) const;
 	
 	/// returns the number of glyphs in this item
 	uint itemGlyphCount(uint i) const;

Modified: branches/ScribusOIF/scribus/text/shaper.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15838&path=/branches/ScribusOIF/scribus/text/shaper.cpp
==============================================================================
--- branches/ScribusOIF/scribus/text/shaper.cpp (original)
+++ branches/ScribusOIF/scribus/text/shaper.cpp Wed Nov 10 14:31:24 2010
@@ -42,7 +42,7 @@
 	}
 
 	// reset items for this run. Radical!
-	QList<uint> items(gs->findIems(start, end));
+	QList<uint> items(gs->findItems(start, end));
 	gs->deleteItems(items);
 	items.clear();
 

Modified: branches/ScribusOIF/scribus/text/textlayout.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15838&path=/branches/ScribusOIF/scribus/text/textlayout.cpp
==============================================================================
--- branches/ScribusOIF/scribus/text/textlayout.cpp (original)
+++ branches/ScribusOIF/scribus/text/textlayout.cpp Wed Nov 10 14:31:24 2010
@@ -349,6 +349,9 @@
 	while(parIdx >= 0)
 	{
 		int startOfPar(qMax(m_story->startOfParagraph(parIdx), m_firstInFrame));
+//		while((startOfPar < m_story->length() )
+//			&& (m_story->text(startOfPar,1) == SpecialChars::PARSEP))
+//			++startOfPar;
 		int endOfPar(m_story->endOfParagraph(parIdx));
 		if(endOfPar <= startOfPar)
 		{




More information about the scribus-commit mailing list