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:
vandebo@chromium.org 2011-06-28 16:33:21 +00:00
parent 213c42bb69
commit 98dfb05a85

View File

@ -718,7 +718,7 @@ static bool getWidthAdvance(CTFontRef ctFont, int gId, int16_t* data) {
CGGlyph glyph = gId; CGGlyph glyph = gId;
CTFontGetAdvancesForGlyphs(ctFont, kCTFontHorizontalOrientation, &glyph, CTFontGetAdvancesForGlyphs(ctFont, kCTFontHorizontalOrientation, &glyph,
&advance, 1); &advance, 1);
*data = advance.width; *data = sk_float_round2int(advance.width);
return true; return true;
} }
@ -727,6 +727,8 @@ SkAdvancedTypefaceMetrics* SkFontHost::GetAdvancedTypefaceMetrics(
uint32_t fontID, uint32_t fontID,
SkAdvancedTypefaceMetrics::PerGlyphInfo perGlyphInfo) { SkAdvancedTypefaceMetrics::PerGlyphInfo perGlyphInfo) {
CTFontRef ctFont = GetFontRefFromFontID(fontID); CTFontRef ctFont = GetFontRefFromFontID(fontID);
ctFont = CTFontCreateCopyWithAttributes(ctFont, CTFontGetUnitsPerEm(ctFont)
NULL, NULL);
SkAdvancedTypefaceMetrics* info = new SkAdvancedTypefaceMetrics; SkAdvancedTypefaceMetrics* info = new SkAdvancedTypefaceMetrics;
CFStringRef fontName = CTFontCopyPostScriptName(ctFont); CFStringRef fontName = CTFontCopyPostScriptName(ctFont);
// Reserve enough room for the worst-case string, // Reserve enough room for the worst-case string,
@ -806,6 +808,7 @@ SkAdvancedTypefaceMetrics* SkFontHost::GetAdvancedTypefaceMetrics(
getAdvanceData(ctFont, glyphCount, &getWidthAdvance)); getAdvanceData(ctFont, glyphCount, &getWidthAdvance));
} }
CFSafeRelease(ctFont);
return info; return info;
} }