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

Line truncation terminated at paragraph boundaries #363

Merged
merged 1 commit into from
Mar 29, 2013
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
12 changes: 8 additions & 4 deletions Core/Source/DTCoreTextLayoutFrame.m
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ - (void)_buildLinesWithTypesetter

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

do
{
Expand Down Expand Up @@ -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)
{
Expand All @@ -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
Expand Down Expand Up @@ -529,7 +533,7 @@ - (void)_buildLinesWithTypesetter
previousLine = newLine;
//previousLineMetrics = currentLineMetrics;
}
while (lineRange.location < maxIndex);
while (lineRange.location < maxIndex && !truncateLine);

_lines = typesetLines;

Expand Down