在IOS 7中获得内核

在IOS 7中获得内核,ios,objective-c,fonts,Ios,Objective C,Fonts,我是IOS新手。 所以我的问题是,我需要在两个字形之间进行紧排。 首先我试着这样: NSString *text = @"AB"; NSDictionary* stringAttrs = @{ NSFontAttributeName : self.level.font, NSKernAttributeName:@0.0f }; CGSize size = [text sizeWithAttributes:stringAttrs]; //For better understan

我是IOS新手。 所以我的问题是,我需要在两个字形之间进行紧排。 首先我试着这样:

NSString *text = @"AB";
NSDictionary* stringAttrs = @{ NSFontAttributeName : self.level.font,         
NSKernAttributeName:@0.0f };
CGSize size = [text sizeWithAttributes:stringAttrs];

//For better understanding
NSString *textA = @"A";
NSString *textB = @"B";
CGSize sizeA = [text sizeWithAttributes:stringAttrs];
CGSize sizeB = [text sizeWithAttributes:stringAttrs];
double kerning = size.width - sizeA.width - size.widthB;
我想,对于单个符号,宽度将是没有前进的。但我错了。这对我没有帮助。比我试过的要多

CFStringRef str = (__bridge CFStringRef)@"A";
CFIndex count = CFStringGetLength(str);

CTFontRef font = CTFontCreateWithName((CFStringRef)@"Lora", 100, NULL);

UniChar *characters = (UniChar *)malloc(sizeof(UniChar) * count);
CGGlyph *glyphs = (CGGlyph *)malloc(sizeof(CGGlyph) * count);

CFStringGetCharacters(str, CFRangeMake(0, count), characters);
CTFontGetGlyphsForCharacters(font, characters, glyphs, count);

CGSize *sizeCore = malloc(count * sizeof(CGSize));
CGRect *rectCore = malloc(count * sizeof(CGRect));

double adv = CTFontGetAdvancesForGlyphs (font,
                                         kCTFontHorizontalOrientation,
                                         glyphs,
                                         sizeCore,
                                         count);

CGRect rect = CTFontGetBoundingRectsForGlyphs (font,
                                               kCTFontHorizontalOrientation,
                                               glyphs,
                                               rectCore,
                                               count);

double kerning = adv - rect.size.width; (== 0)
adv
给出了与
rect.size.width
相同的值,甚至在第一次尝试时给出了相同的值
size.width

有客人吗?或链接,我可以找到答案。
对不起,我犯了错误

我发现在ios 7中,字距调整不能与某些字体配合使用。见我对这个问题的回答:

也许它适用于不同的字体