Skip to content
This repository
Browse code

Fixed problem with underline/stroke/highlight extending past text

  • Loading branch information...
commit c1f43231482d6abac9707e1f547a81cad13de010 1 parent 1afd065
Oliver Drobnik authored March 16, 2013

Showing 1 changed file with 7 additions and 2 deletions. Show diff stats Hide diff stats

  1. 9  Core/Source/DTCoreTextLayoutFrame.m
9  Core/Source/DTCoreTextLayoutFrame.m
@@ -1000,6 +1000,13 @@ - (void)drawInContext:(CGContextRef)context drawImages:(BOOL)drawImages drawLink
1000 1000
 			
1001 1001
 			if (drawStrikeOut||drawUnderline||backgroundColor)
1002 1002
 			{
  1003
+				// calculate area covered by non-whitespace
  1004
+				CGRect lineFrame = oneLine.frame;
  1005
+				lineFrame.size.width -= oneLine.trailingWhitespaceWidth;
  1006
+				
  1007
+				// exclude trailing whitespace so that we don't underline too much
  1008
+				CGRect runStrokeBounds = CGRectIntersection(lineFrame, oneRun.frame);
  1009
+
1003 1010
 				// get text color or use black
1004 1011
 				id color = [oneRun.attributes objectForKey:(id)kCTForegroundColorAttributeName];
1005 1012
 				
@@ -1020,8 +1027,6 @@ - (void)drawInContext:(CGContextRef)context drawImages:(BOOL)drawImages drawLink
1020 1027
 					CGContextSetGrayStrokeColor(context, 0, 1.0);
1021 1028
 				}
1022 1029
 				
1023  
-				CGRect runStrokeBounds = oneRun.frame;
1024  
-				
1025 1030
 				NSInteger superscriptStyle = [[oneRun.attributes objectForKey:(id)kCTSuperscriptAttributeName] integerValue];
1026 1031
 				
1027 1032
 				switch (superscriptStyle) 

0 notes on commit c1f4323

Please sign in to comment.
Something went wrong with that request. Please try again.