Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Line truncation terminated at paragraph boundaries #363

Merged
merged 1 commit into from

2 participants

@rmaz

A small patch to truncate lines only up to their paragraph range. This fixes a bug we had where a truncated line would cause successive paragraphs to be pulled up into the truncated line, if there was a line break before the end of the line truncation.

Richard Mazorodze only truncate lines up to the end of the current paragraph, so that t…
…he paragraph below does not get rendered in the truncated line
fec2561
@Cocoanetics Cocoanetics merged commit 7d5a719 into Cocoanetics:master
@Cocoanetics
Owner

@rmaz Didn't test it, but I trust you. Could you maybe also look at the #364 issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 27, 2013
  1. only truncate lines up to the end of the current paragraph, so that t…

    Richard Mazorodze authored
    …he paragraph below does not get rendered in the truncated line
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 4 deletions.
  1. +8 −4 Core/Source/DTCoreTextLayoutFrame.m
View
12 Core/Source/DTCoreTextLayoutFrame.m
@@ -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;
Something went wrong with that request. Please try again.