Skip to content

Commit

Permalink
Merge pull request #363 from rmaz/master
Browse files Browse the repository at this point in the history
Line truncation terminated at paragraph boundaries
  • Loading branch information
odrobnik committed Mar 29, 2013
2 parents 3985528 + fec2561 commit 7d5a719
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Core/Source/DTCoreTextLayoutFrame.m
Expand Up @@ -157,6 +157,7 @@ - (void)_buildLinesWithTypesetter


DTTextBlock *currentTextBlock = nil; DTTextBlock *currentTextBlock = nil;
DTTextBlock *previousTextBlock = nil; DTTextBlock *previousTextBlock = nil;
BOOL truncateLine;


do do
{ {
Expand Down Expand Up @@ -234,8 +235,8 @@ - (void)_buildLinesWithTypesetter
CTParagraphStyleGetValueForSpecifier(paragraphStyle, kCTParagraphStyleSpecifierParagraphSpacing, sizeof(currentParaMetrics.paragraphSpacing), &currentParaMetrics.paragraphSpacing); CTParagraphStyleGetValueForSpecifier(paragraphStyle, kCTParagraphStyleSpecifierParagraphSpacing, sizeof(currentParaMetrics.paragraphSpacing), &currentParaMetrics.paragraphSpacing);
} }


BOOL truncateLine = ((self.numberOfLines>0 && [typesetLines count]+1==self.numberOfLines) || truncateLine = ((self.numberOfLines>0 && [typesetLines count]+1==self.numberOfLines) ||
(_numberLinesFitInFrame>0 && _numberLinesFitInFrame==[typesetLines count]+1)); (_numberLinesFitInFrame>0 && _numberLinesFitInFrame==[typesetLines count]+1));
CTLineRef line; CTLineRef line;
if(!truncateLine) if(!truncateLine)
{ {
Expand All @@ -244,8 +245,11 @@ - (void)_buildLinesWithTypesetter
} }
else 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; NSRange oldLineRange = lineRange;
lineRange.length = maxIndex-lineRange.location; lineRange.length = NSMaxRange(currentParagraphRange)-lineRange.location;
line = CTTypesetterCreateLine(typesetter, CFRangeMake(lineRange.location, lineRange.length)); line = CTTypesetterCreateLine(typesetter, CFRangeMake(lineRange.location, lineRange.length));


// convert lineBreakMode to CoreText type // convert lineBreakMode to CoreText type
Expand Down Expand Up @@ -529,7 +533,7 @@ - (void)_buildLinesWithTypesetter
previousLine = newLine; previousLine = newLine;
//previousLineMetrics = currentLineMetrics; //previousLineMetrics = currentLineMetrics;
} }
while (lineRange.location < maxIndex); while (lineRange.location < maxIndex && !truncateLine);


_lines = typesetLines; _lines = typesetLines;


Expand Down

0 comments on commit 7d5a719

Please sign in to comment.