Проблемы CTLineGetTypographicBounds

Код извлечен из кода выборки SimpleTextInput с битовой модификацией.

Создайте фрейм:

self.font = [UIFont systemFontOfSize:18.f];
CTFontRef ctFont = CTFontCreateWithName((CFStringRef) self.font.fontName, self.font.pointSize, NULL);        
self.attributes = [[NSDictionary dictionaryWithObject:(id)ctFont forKey:(NSString *)kCTFontAttributeName] retain];
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:self.text attributes:self.attributes];    

_framesetter = CTFramesetterCreateWithAttributedString((CFAttributedStringRef)attributedString);

// Create the Core Text frame using our current view rect bounds
UIBezierPath *path = [UIBezierPath bezierPathWithRect:self.bounds];
_frame =  CTFramesetterCreateFrame(_framesetter, CFRangeMake(0, 0), [path CGPath], NULL);

строка ниже: любая строка кадра (получить с помощью CTFrameGetLines (_frame) ):

CGFloat ascent, descent, leading;
CTLineGetTypographicBounds(line, &ascent, &descent, &leading);
CGPoint origin;
CTFrameGetLineOrigins(_frame, CFRangeMake(i, 1), &origin);

Проблемы:

  1. подъем, полученный из CTLineGetTypographicBounds или ctFont, равен 13.860352, а self.font.ascender - 16.860352. Где эти 3 точки несоответствие?
  2. descent равно 4,139648, интерлиньяж равен 0, поэтому ascent + descent + lead = 18, но self.font.lineHeight и высота строки, вычисленные путем вычитания начала смежных строк, равны 22. Откуда взялось это расхождение в 4 пункта. ?

6
задан an0 16 June 2011 в 19:28
поделиться