@@ -304,14 +304,17 @@ - (void)drawLists:(id<EnrichedViewHost>)host
304304 if ([markerFormat
305305 isEqualToString:
306306 @" EnrichedOrderedList" ]) {
307+ CGPoint glyphLocation = [self locationForGlyphAtIndex: lineGlyphRange.location];
308+ CGFloat absoluteBaselineY = origin.y + rect.origin .y + glyphLocation.y ;
307309 NSString *marker = [self
308310 getDecimalMarkerForList: host
309311 charIndex: charIdx];
312+
310313 [self drawDecimal: host
311314 marker: marker
312315 markerAttributes: markerAttributes
313316 origin: origin
314- usedRect: usedRect
317+ baselineY: absoluteBaselineY
315318 indent: indent];
316319 } else if ([markerFormat
317320 isEqualToString:
@@ -439,13 +442,16 @@ - (void)drawDecimal:(id<EnrichedViewHost>)host
439442 marker : (NSString *)marker
440443 markerAttributes : (NSDictionary *)markerAttributes
441444 origin : (CGPoint)origin
442- usedRect : (CGRect) usedRect
445+ baselineY : (CGFloat) baselineY
443446 indent : (CGFloat)indent {
444447 CGFloat gapWidth = [host.config orderedListGapWidth ];
445448 CGSize markerSize = [marker sizeWithAttributes: markerAttributes];
446449 CGFloat markerX = origin.x + indent - gapWidth - markerSize.width / 2 ;
447- CGFloat centerY = CGRectGetMidY (usedRect) + origin.y ;
448- CGFloat markerY = centerY - markerSize.height / 2.0 ;
450+ UIFont *markerFont = markerAttributes[NSFontAttributeName ];
451+
452+ // drawAtPoint draws from the top-left bounding box of the string.
453+ // (baselineY - ascender) exactly pinpoints the top edge of the text
454+ CGFloat markerY = baselineY - markerFont.ascender ;
449455
450456 [marker drawAtPoint: CGPointMake (markerX, markerY)
451457 withAttributes: markerAttributes];
0 commit comments