Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #363 from rmaz/master

Line truncation terminated at paragraph boundaries
  • Loading branch information...
commit 7d5a719837e22fcc9c53bf2cef96dd5affbae190 2 parents 3985528 + fec2561
Oliver Drobnik authored
Showing with 8 additions and 4 deletions.
  1. +8 −4 Core/Source/DTCoreTextLayoutFrame.m
12 Core/Source/DTCoreTextLayoutFrame.m
View
@@ -157,6 +157,7 @@ - (void)_buildLinesWithTypesetter
DTTextBlock *currentTextBlock = nil;
DTTextBlock *previousTextBlock = nil;
+ BOOL truncateLine;
do
{
@@ -234,8 +235,8 @@ - (void)_buildLinesWithTypesetter
CTParagraphStyleGetValueForSpecifier(paragraphStyle, kCTParagraphStyleSpecifierParagraphSpacing, sizeof(currentParaMetrics.paragraphSpacing), &currentParaMetrics.paragraphSpacing);
}
- BOOL truncateLine = ((self.numberOfLines>0 && [typesetLines count]+1==self.numberOfLines) ||
- (_numberLinesFitInFrame>0 && _numberLinesFitInFrame==[typesetLines count]+1));
+ truncateLine = ((self.numberOfLines>0 && [typesetLines count]+1==self.numberOfLines) ||
+ (_numberLinesFitInFrame>0 && _numberLinesFitInFrame==[typesetLines count]+1));
CTLineRef line;
if(!truncateLine)
{
@@ -244,8 +245,11 @@ - (void)_buildLinesWithTypesetter
}
else
{
+ // extend the line to the end of the current paragraph
+ // if we extend to the entire to the entire text range
+ // it is possible to pull lines up from paragraphs below us
NSRange oldLineRange = lineRange;
- lineRange.length = maxIndex-lineRange.location;
+ lineRange.length = NSMaxRange(currentParagraphRange)-lineRange.location;
line = CTTypesetterCreateLine(typesetter, CFRangeMake(lineRange.location, lineRange.length));
// convert lineBreakMode to CoreText type
@@ -529,7 +533,7 @@ - (void)_buildLinesWithTypesetter
previousLine = newLine;
//previousLineMetrics = currentLineMetrics;
}
- while (lineRange.location < maxIndex);
+ while (lineRange.location < maxIndex && !truncateLine);
_lines = typesetLines;
Please sign in to comment.
Something went wrong with that request. Please try again.