FormatResult FormatSoftHyphen()
{
if (this.currentLeaf.Current == this.startLeaf.Current)
return FormatResult.Continue;
ParagraphIterator nextIter = this.currentLeaf.GetNextLeaf();
ParagraphIterator prevIter = this.currentLeaf.GetPreviousLeaf();
if (!IsWordLikeElement(prevIter.Current) || !IsWordLikeElement(nextIter.Current))
return FormatResult.Continue;
//--- Save ---------------------------------
ParagraphIterator iter;
int blankCount;
XUnit xPosition;
XUnit lineWidth;
XUnit wordsWidth;
XUnit blankWidth;
SaveBeforeProbing(out iter, out blankCount, out wordsWidth, out xPosition, out lineWidth, out blankWidth);
//------------------------------------------
this.currentLeaf = nextIter;
FormatResult result = FormatElement(nextIter.Current);
//--- Restore ------------------------------
RestoreAfterProbing(iter, blankCount, wordsWidth, xPosition, lineWidth, blankWidth);
//------------------------------------------
if (result == FormatResult.Continue)
return FormatResult.Continue;
RestoreAfterProbing(iter, blankCount, wordsWidth, xPosition, lineWidth, blankWidth);
Rectangle fittingRect = this.formattingArea.GetFittingRect(this.currentYPosition, this.currentVerticalInfo.height);
XUnit hyphenWidth = MeasureString("-");
if (xPosition + hyphenWidth <= fittingRect.X + fittingRect.Width + Tolerance
// If one word fits, but not the hyphen, the formatting must continue with the next leaf
|| prevIter.Current == this.startLeaf.Current)
{
// For Tabs in justified context
if (!IgnoreHorizontalGrowth)
{
this.currentWordsWidth += hyphenWidth;
this.currentLineWidth += hyphenWidth;
}
this.currentLeaf = nextIter;
return FormatResult.NewLine;
}
else
{
this.currentWordsWidth -= this.savedWordWidth;
this.currentLineWidth -= this.savedWordWidth;
this.currentLineWidth -= GetPreviousBlankWidth(prevIter);
this.currentLeaf = prevIter;
return FormatResult.NewLine;
}
}