Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Resolves issue #195, justification of the final line of paragraphs. #196

Merged
merged 1 commit into from

2 participants

JasonLion Oliver Drobnik
JasonLion

Justify is still justifying the last line of some paragraphs, despite
pull request #180/ issue #179.

There are two bugs. First, the calculation of isAtEndOfParagraph on
line 172 of DTCoreTextLayoutFrame.m is wrong, checking to see if the
line starts at the end of the paragraph. Second, a br doesn't end the
paragraph but should suppress justification as if it was the end of the
paragraph.

Both issues are solved with this change.

JasonLion JasonLion Prevent justification of the final lines of paragraphs
Justify is still justifying the last line of some paragraphs, despite
pull request #180/ issue #179.

There are two bugs. First, the calculation of isAtEndOfParagraph on
line 172 of DTCoreTextLayoutFrame.m is wrong, checking to see if the
line starts at the end of the paragraph. Second, a br doesn't end the
paragraph but should suppress justification as if it was the end of the
paragraph.

Both issues are solved with this change.
16650b7
Oliver Drobnik Cocoanetics merged commit 3c21d64 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 28, 2012
  1. JasonLion

    Prevent justification of the final lines of paragraphs

    JasonLion authored
    Justify is still justifying the last line of some paragraphs, despite
    pull request #180/ issue #179.
    
    There are two bugs. First, the calculation of isAtEndOfParagraph on
    line 172 of DTCoreTextLayoutFrame.m is wrong, checking to see if the
    line starts at the end of the paragraph. Second, a br doesn't end the
    paragraph but should suppress justification as if it was the end of the
    paragraph.
    
    Both issues are solved with this change.
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 2 deletions.
  1. +5 −2 Core/Source/DTCoreTextLayoutFrame.m
7 Core/Source/DTCoreTextLayoutFrame.m
View
@@ -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
Something went wrong with that request. Please try again.