Fix core text font metrics - scale to em size and convert float to int
Review URL: http://codereview.appspot.com/4654070 git-svn-id: http://skia.googlecode.com/svn/trunk@1737 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
213c42bb69
commit
98dfb05a85
@ -718,7 +718,7 @@ static bool getWidthAdvance(CTFontRef ctFont, int gId, int16_t* data) {
|
||||
CGGlyph glyph = gId;
|
||||
CTFontGetAdvancesForGlyphs(ctFont, kCTFontHorizontalOrientation, &glyph,
|
||||
&advance, 1);
|
||||
*data = advance.width;
|
||||
*data = sk_float_round2int(advance.width);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -727,6 +727,8 @@ SkAdvancedTypefaceMetrics* SkFontHost::GetAdvancedTypefaceMetrics(
|
||||
uint32_t fontID,
|
||||
SkAdvancedTypefaceMetrics::PerGlyphInfo perGlyphInfo) {
|
||||
CTFontRef ctFont = GetFontRefFromFontID(fontID);
|
||||
ctFont = CTFontCreateCopyWithAttributes(ctFont, CTFontGetUnitsPerEm(ctFont)
|
||||
NULL, NULL);
|
||||
SkAdvancedTypefaceMetrics* info = new SkAdvancedTypefaceMetrics;
|
||||
CFStringRef fontName = CTFontCopyPostScriptName(ctFont);
|
||||
// Reserve enough room for the worst-case string,
|
||||
@ -806,6 +808,7 @@ SkAdvancedTypefaceMetrics* SkFontHost::GetAdvancedTypefaceMetrics(
|
||||
getAdvanceData(ctFont, glyphCount, &getWidthAdvance));
|
||||
}
|
||||
|
||||
CFSafeRelease(ctFont);
|
||||
return info;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user