Permalink
Browse files

Merge pull request #196 from JasonLion/master

Resolves issue #195, justification of the final line of paragraphs.
  • Loading branch information...
2 parents 27a734b + 16650b7 commit 3c21d64863350c98c9e4a513506b43fc674aef69 @odrobnik odrobnik committed Jun 28, 2012
Showing with 5 additions and 2 deletions.
  1. +5 −2 Core/Source/DTCoreTextLayoutFrame.m
@@ -170,7 +170,6 @@ - (void)_buildLinesWithTypesetter
}
BOOL isAtBeginOfParagraph = (currentParagraphRange.location == lineRange.location);
- BOOL isAtEndOfParagraph = (currentParagraphRange.location+currentParagraphRange.length == lineRange.location-1);
CGFloat offset = 0;
@@ -375,7 +374,11 @@ - (void)_buildLinesWithTypesetter
case kCTJustifiedTextAlignment:
{
- // only justify if not last line and if the line widht is longer than 60% of the frame to avoid over-stretching
+ BOOL isAtEndOfParagraph = (currentParagraphRange.location+currentParagraphRange.length <= lineRange.location+lineRange.length || // JTL 28/June/2012
+ [[_attributedStringFragment string] characterAtIndex:lineRange.location+lineRange.length-1]==0x2028); // JTL 28/June/2012
+
+ // only justify if not last line, not <br>, and if the line width is longer than 60% of the frame
+ // avoids over-stretching
if( !isAtEndOfParagraph && (currentLineMetrics.width > 0.60 * _frame.size.width) )
{
// create a justified line and replace the current one with it

0 comments on commit 3c21d64

Please sign in to comment.