Skip to content

Commit

Permalink
Merge 4319d11 into 6d03c84
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffrwon committed Sep 6, 2016
2 parents 6d03c84 + 4319d11 commit 0af3357
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions Core/Source/CTLineUtils.m
Expand Up @@ -74,9 +74,23 @@ CFIndex getTruncationIndex(CTLineRef line, CTLineRef trunc)
CFArrayRef lineRuns = CTLineGetGlyphRuns(line);
CFIndex lineRunsCount = CFArrayGetCount(lineRuns);

CTRunRef lineLastRun = CFArrayGetValueAtIndex(lineRuns, lineRunsCount - truncCount - 1);

CFRange lastRunRange = CTRunGetStringRange(lineLastRun);

return lastRunRange.location = lastRunRange.length;
CFIndex index = lineRunsCount - truncCount - 1;

// If the index is negative, CFArrayGetValueAtIndex will crash on iOS 10 beta.
// We will just return 0 because on iOS 9, CFArrayGetValueAtIndex would have
// returned nil anyways and the return truncation index would be 0.
// Apple might have enabled an assert that only appears in the iOS 10 beta
// release, but we will just avoid passing invalid arguments just to be safe.
if (index < 0)
{
return 0;
}
else
{
CTRunRef lineLastRun = CFArrayGetValueAtIndex(lineRuns, index);

CFRange lastRunRange = CTRunGetStringRange(lineLastRun);

return lastRunRange.location = lastRunRange.length;
}
}

0 comments on commit 0af3357

Please sign in to comment.