r17260 by fschmid - Better justification for text on a path. Paragraph aligning "justified" now enlarges only the spaces between words,

scribus-commit scribus-commit at lists.scribus.net
Sun Jan 29 19:26:04 UTC 2012


Author: fschmid
Date: Sun Jan 29 19:26:04 2012
New Revision: 17260

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17260
Log:
Better justification for text on a path. Paragraph aligning "justified" now enlarges only the spaces between words,
alignment "forced justified" enlarges the spacing between all glyphs.

Modified:
    trunk/Scribus/scribus/pageitem.cpp
    trunk/Scribus/scribus/pageitem_pathtext.cpp
    trunk/Scribus/scribus/ui/nodeeditpalette.cpp
    trunk/Scribus/scribus/ui/propertiespalette_text.cpp

Modified: trunk/Scribus/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17260&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp (original)
+++ trunk/Scribus/scribus/pageitem.cpp Sun Jan 29 19:26:04 2012
@@ -6858,7 +6858,7 @@
 
 void PageItem::setPolyClip(int up, int down)
 {
-	if (PoLine.size() < 4)
+	if (PoLine.size() < 3)
 		return;
 	double rot;
 	int upval = up;

Modified: trunk/Scribus/scribus/pageitem_pathtext.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17260&path=/trunk/Scribus/scribus/pageitem_pathtext.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_pathtext.cpp (original)
+++ trunk/Scribus/scribus/pageitem_pathtext.cpp Sun Jan 29 19:26:04 2012
@@ -200,6 +200,8 @@
 		}
 		chstr.clear();
 	}
+	int spaceCount = 0;
+	double wordExtra = 0;
 	for (a = firstChar; a < itemRenderText.length(); ++a)
 	{
 		hl = itemRenderText.item(a);
@@ -207,13 +209,15 @@
 		if (chstr[0] == SpecialChars::PAGENUMBER || chstr[0] == SpecialChars::PARSEP || chstr[0] == SpecialChars::PAGECOUNT
 			|| chstr[0] == SpecialChars::TAB || chstr[0] == SpecialChars::LINEBREAK)
 			continue;
+		if (chstr[0] == SpecialChars::BLANK)
+			spaceCount++;
 		if (a < itemRenderText.length()-1)
 			chstr += itemRenderText.text(a+1, 1);
 		hl->glyph.yadvance = 0;
 		layoutGlyphs(itemRenderText.charStyle(a), chstr, hl->glyph);
 		hl->glyph.shrink();
 		if (hl->hasObject())
-			totalTextLen += (hl->embedded.getItem()->gWidth + hl->embedded.getItem()->lineWidth()) * hl->glyph.scaleH;
+			totalTextLen += (hl->embedded.getItem()->width() + hl->embedded.getItem()->lineWidth()) * hl->glyph.scaleH;
 		else
 			totalTextLen += hl->glyph.wide()+hl->fontSize() * hl->tracking() / 10000.0;
 	}
@@ -230,7 +234,20 @@
 		}
 		if (itemRenderText.paragraphStyle(0).alignment() == 1)
 			CurX = (totalCurveLen - totalTextLen) / 2.0;
-		if ((itemRenderText.paragraphStyle(0).alignment() == 3) || (itemRenderText.paragraphStyle(0).alignment() == 4))
+		if (itemRenderText.paragraphStyle(0).alignment() == 3)
+		{
+			if (spaceCount != 0)
+			{
+				extraOffset = 0;
+				wordExtra = (totalCurveLen - Extra  - totalTextLen) / static_cast<double>(spaceCount);
+			}
+			else
+			{
+				extraOffset = (totalCurveLen - Extra  - totalTextLen) / static_cast<double>(itemRenderText.length());
+				wordExtra = 0;
+			}
+		}
+		if (itemRenderText.paragraphStyle(0).alignment() == 4)
 			extraOffset = (totalCurveLen - Extra  - totalTextLen) / static_cast<double>(itemRenderText.length());
 	}
 #ifndef NLS_PROTO
@@ -252,7 +269,7 @@
 		layoutGlyphs(itemRenderText.charStyle(a), chstr, hl->glyph);
 		hl->glyph.shrink();                                                           // HACK
 		if (hl->hasObject())
-			dx = (hl->embedded.getItem()->gWidth + hl->embedded.getItem()->lineWidth()) * hl->glyph.scaleH / 2.0;
+			dx = (hl->embedded.getItem()->width() + hl->embedded.getItem()->lineWidth()) * hl->glyph.scaleH / 2.0;
 		else
 			dx = hl->glyph.wide() / 2.0;
 		CurX += dx;
@@ -353,7 +370,9 @@
 		MaxChars = a+1;
 		CurX -= dx;
 		if (hl->hasObject())
-			CurX += (hl->embedded.getItem()->gWidth + hl->embedded.getItem()->lineWidth()) * hl->glyph.scaleH;
+			CurX += (hl->embedded.getItem()->width() + hl->embedded.getItem()->lineWidth()) * hl->glyph.scaleH + extraOffset;
+		else if (hl->ch == SpecialChars::BLANK)
+			CurX += hl->glyph.wide()+hl->fontSize() * hl->tracking() / 10000.0 + wordExtra + extraOffset;
 		else
 			CurX += hl->glyph.wide()+hl->fontSize() * hl->tracking() / 10000.0 + extraOffset;
 	}

Modified: trunk/Scribus/scribus/ui/nodeeditpalette.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17260&path=/trunk/Scribus/scribus/ui/nodeeditpalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/nodeeditpalette.cpp (original)
+++ trunk/Scribus/scribus/ui/nodeeditpalette.cpp Sun Jan 29 19:26:04 2012
@@ -564,6 +564,8 @@
 		currItem->ClipEdited = true;
 		currItem->FrameType = 3;
 		doc->AdjustItemSize(currItem);
+		if (currItem->itemType() == PageItem::PathText)
+			currItem->updatePolyClip();
 		doc->regionsChanged()->update(QRectF());
 		emit DocChanged();
 	}
@@ -588,6 +590,8 @@
 		}
 		doc->nodeEdit.moveClipPoint(currItem, np);
 		doc->AdjustItemSize(currItem, true, true);
+		if (currItem->itemType() == PageItem::PathText)
+			currItem->updatePolyClip();
 		doc->regionsChanged()->update(QRectF());
 		emit DocChanged();
 	}
@@ -860,6 +864,9 @@
 		doc->nodeEdit.SegP1 = -1;
 		doc->nodeEdit.SegP2 = -1;
 		doc->nodeEdit.SelNode.clear();
+		PageItem *currItem = doc->m_Selection->itemAt(0);
+		if (currItem->itemType() == PageItem::PathText)
+			currItem->updatePolyClip();
 	}
 	PolySplit->setEnabled( false );
 	BezierClose->setEnabled( false );
@@ -879,6 +886,9 @@
 		doc->nodeEdit.SelNode.clear();
 		EditCont->setChecked(false);
 		ToggleConMode();
+		PageItem *currItem = doc->m_Selection->itemAt(0);
+		if (currItem->itemType() == PageItem::PathText)
+			currItem->updatePolyClip();
 	}
 	PolySplit->setEnabled( false );
 	BezierClose->setEnabled( false );

Modified: trunk/Scribus/scribus/ui/propertiespalette_text.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17260&path=/trunk/Scribus/scribus/ui/propertiespalette_text.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/propertiespalette_text.cpp (original)
+++ trunk/Scribus/scribus/ui/propertiespalette_text.cpp Sun Jan 29 19:26:04 2012
@@ -822,6 +822,7 @@
 		return;
 	m_item->textPathType = pathTextWidgets->pathTextType->currentIndex();
 	m_item->update();
+	m_doc->regionsChanged()->update(QRect());
 }
 
 void PropertiesPalette_Text::handlePathFlip()
@@ -831,6 +832,7 @@
 	m_item->textPathFlipped = pathTextWidgets->flippedPathText->isChecked();
 	m_item->updatePolyClip();
 	m_item->update();
+	m_doc->regionsChanged()->update(QRect());
 }
 
 void PropertiesPalette_Text::handlePathLine()
@@ -849,6 +851,7 @@
 	m_doc->AdjustItemSize(m_item);
 	m_item->updatePolyClip();
 	m_item->update();
+	m_doc->regionsChanged()->update(QRect());
 }
 
 void PropertiesPalette_Text::handlePathOffs()
@@ -859,6 +862,7 @@
 	m_doc->AdjustItemSize(m_item);
 	m_item->updatePolyClip();
 	m_item->update();
+	m_doc->regionsChanged()->update(QRect());
 }
 
 void PropertiesPalette_Text::fillLangCombo(QMap<QString,QString> langMap)




More information about the scribus-commit mailing list