Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jun 28, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Core/Source/DTCoreTextLayoutFrame.m
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ - (void)_buildLinesWithTypesetter
} }


BOOL isAtBeginOfParagraph = (currentParagraphRange.location == lineRange.location); BOOL isAtBeginOfParagraph = (currentParagraphRange.location == lineRange.location);
BOOL isAtEndOfParagraph = (currentParagraphRange.location+currentParagraphRange.length == lineRange.location-1);


CGFloat offset = 0; CGFloat offset = 0;


Expand Down Expand Up @@ -375,7 +374,11 @@ - (void)_buildLinesWithTypesetter


case kCTJustifiedTextAlignment: 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) ) if( !isAtEndOfParagraph && (currentLineMetrics.width > 0.60 * _frame.size.width) )
{ {
// create a justified line and replace the current one with it // create a justified line and replace the current one with it
Expand Down