Permalink
Browse files

Fixed problem with underline/stroke/highlight extending past text

  • Loading branch information...
odrobnik committed Mar 16, 2013
1 parent 1afd065 commit c1f43231482d6abac9707e1f547a81cad13de010
Showing with 7 additions and 2 deletions.
  1. +7 −2 Core/Source/DTCoreTextLayoutFrame.m
@@ -1000,6 +1000,13 @@ - (void)drawInContext:(CGContextRef)context drawImages:(BOOL)drawImages drawLink
if (drawStrikeOut||drawUnderline||backgroundColor)
{
+ // calculate area covered by non-whitespace
+ CGRect lineFrame = oneLine.frame;
+ lineFrame.size.width -= oneLine.trailingWhitespaceWidth;
+
+ // exclude trailing whitespace so that we don't underline too much
+ CGRect runStrokeBounds = CGRectIntersection(lineFrame, oneRun.frame);
+
// get text color or use black
id color = [oneRun.attributes objectForKey:(id)kCTForegroundColorAttributeName];
@@ -1020,8 +1027,6 @@ - (void)drawInContext:(CGContextRef)context drawImages:(BOOL)drawImages drawLink
CGContextSetGrayStrokeColor(context, 0, 1.0);
}
- CGRect runStrokeBounds = oneRun.frame;
-
NSInteger superscriptStyle = [[oneRun.attributes objectForKey:(id)kCTSuperscriptAttributeName] integerValue];
switch (superscriptStyle)

0 comments on commit c1f4323

Please sign in to comment.