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

Already on GitHub? Sign in to your account

Line truncation terminated at paragraph boundaries #363

Merged
merged 1 commit into from Mar 29, 2013
Jump to file or symbol
Failed to load files and symbols.
+8 −4
Split
@@ -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;