Skip to content

Commit

Permalink
Wrap text-on-path beyond end on closed paths
Browse files Browse the repository at this point in the history
  • Loading branch information
eudoxos committed Jul 8, 2017
1 parent 61e2c10 commit 4aba5e1
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions scribus/pageitem_pathtext.cpp
Expand Up @@ -172,6 +172,9 @@ void PageItem_PathText::DrawObj_Item(ScPainter *p, QRectF cullingArea)
if (glyphRuns.isEmpty()) if (glyphRuns.isEmpty())
return; return;


// enable seamless crossing past the endpoint for closed curve
bool curveClosed=PoLine.isBezierClosed();

foreach (const GlyphCluster& run, glyphRuns) foreach (const GlyphCluster& run, glyphRuns)
{ {
totalTextLen += run.width(); totalTextLen += run.width();
Expand Down Expand Up @@ -209,7 +212,7 @@ void PageItem_PathText::DrawObj_Item(ScPainter *p, QRectF cullingArea)
extraOffset = (totalCurveLen - m_textDistanceMargins.left() - totalTextLen) / static_cast<double>(itemText.length()); extraOffset = (totalCurveLen - m_textDistanceMargins.left() - totalTextLen) / static_cast<double>(itemText.length());
} }
int firstRun = 0; int firstRun = 0;
if (totalTextLen + m_textDistanceMargins.left() > totalCurveLen && itemText.paragraphStyle(0).direction() == ParagraphStyle::RTL) if (!curveClosed && totalTextLen + m_textDistanceMargins.left() > totalCurveLen && itemText.paragraphStyle(0).direction() == ParagraphStyle::RTL)
{ {
double totalLenDiff = totalTextLen + m_textDistanceMargins.left() - totalCurveLen; double totalLenDiff = totalTextLen + m_textDistanceMargins.left() - totalCurveLen;
while (firstRun < glyphRuns.count()) while (firstRun < glyphRuns.count())
Expand All @@ -233,13 +236,21 @@ void PageItem_PathText::DrawObj_Item(ScPainter *p, QRectF cullingArea)
CurX += dx; CurX += dx;
CurY = 0; CurY = 0;
double currPerc = currPath.percentAtLength(CurX); double currPerc = currPath.percentAtLength(CurX);
// sticks out to the next segment
if (currPerc >= 0.9999999) if (currPerc >= 0.9999999)
{ {
currPathIndex++; currPathIndex++;
if (currPathIndex == pathList.count()) if (currPathIndex == pathList.count())
{ {
MaxChars = run.firstChar(); if (curveClosed)
break; {
currPathIndex=0; // start from beginning again
}
else
{
MaxChars = run.firstChar();
break;
}
} }
currPath = pathList[currPathIndex]; currPath = pathList[currPathIndex];
CurX = dx; CurX = dx;
Expand Down

0 comments on commit 4aba5e1

Please sign in to comment.