@@ -461,8 +461,6 @@ - (CGRect)rectForRange:(NSRange)range
461461 CFArrayRef runs = CTLineGetGlyphRuns (line);
462462 CFIndex runCount = CFArrayGetCount (runs);
463463
464- // Iterate through each of the "runs" (i.e. a chunk of text) and find the runs that
465- // intersect with the range.
466464 for (CFIndex k = 0 ; k < runCount; k++)
467465 {
468466 CTRunRef run = CFArrayGetValueAtIndex (runs, k);
@@ -473,20 +471,18 @@ - (CGRect)rectForRange:(NSRange)range
473471
474472 if (intersectedRunRange.length == 0 )
475473 {
476- // This run doesn't intersect the range, so skip it.
477474 continue ;
478475 }
479476
480477 CGFloat ascent = 0 .0f ;
481478 CGFloat descent = 0 .0f ;
482479 CGFloat leading = 0 .0f ;
483480
484- // Use of 'leading' doesn't properly highlight Japanese-character link.
485481 CGFloat width = (CGFloat)CTRunGetTypographicBounds (run,
486482 CFRangeMake (0 , 0 ),
487483 &ascent,
488484 &descent,
489- NULL ); // &leading);
485+ NULL );
490486 CGFloat height = ascent + descent;
491487
492488 CGFloat xOffset = CTLineGetOffsetForStringIndex (line, CTRunGetStringRange (run).location , nil );
@@ -768,6 +764,7 @@ - (void)drawHighlightWithRect:(CGRect)rect
768764 CGRect highlightRect = [self rectForRange: linkRange
769765 inLine: line
770766 lineOrigin: lineOrigins[i]];
767+
771768 highlightRect = CGRectOffset (highlightRect, 0 , -rect.origin .y );
772769 if (!CGRectIsEmpty (highlightRect))
773770 {
@@ -844,7 +841,8 @@ - (void)drawText:(NSAttributedString *)attributedString
844841
845842 if (lastLineRange.length > 0 )
846843 {
847- // 移除掉最后一个对象...(其实这个地方有点问题,也有可能需要移除最后 2 个对象,因为 attachment 宽度的关系)
844+ // 移除掉最后一个对象...
845+ // 其实这个地方有点问题,也有可能需要移除最后 2 个对象,因为 attachment 宽度的关系
848846 [truncationString deleteCharactersInRange: NSMakeRange (lastLineRange.length - 1 , 1 )];
849847 }
850848 [truncationString appendAttributedString: tokenString];
@@ -909,7 +907,7 @@ - (void)drawAttachments
909907 CGFloat lineHeight = lineAscent + lineDescent;
910908 CGFloat lineBottomY = lineOrigin.y - lineDescent;
911909
912- // 遍历以找到对应的 attachment 进行绘制
910+ // 遍历找到对应的 attachment 进行绘制
913911 for (CFIndex k = 0 ; k < runCount; k++)
914912 {
915913 CTRunRef run = CFArrayGetValueAtIndex (runs, k);
0 commit comments