Merge "Fix TextLayoutCache issue when loading Font tables (DO NOT MERGE)" into ics-mr1

This commit is contained in:
Fabrice Di Meglio
2011-12-06 15:47:27 -08:00
committed by Android (Google) Code Review
2 changed files with 4 additions and 19 deletions

View File

@@ -211,22 +211,7 @@ const HB_FontClass harfbuzzSkiaClass = {
HB_Error harfbuzzSkiaGetTable(void* voidface, const HB_Tag tag, HB_Byte* buffer, HB_UInt* len)
{
FontData* data = reinterpret_cast<FontData*>(voidface);
SkTypeface* typeface = data->typeFace;
const size_t tableSize = SkFontHost::GetTableSize(typeface->uniqueID(), tag);
if (!tableSize)
return HB_Err_Invalid_Argument;
// If Harfbuzz specified a NULL buffer then it's asking for the size of the table.
if (!buffer) {
*len = tableSize;
return HB_Err_Ok;
}
if (*len < tableSize)
return HB_Err_Invalid_Argument;
SkFontHost::GetTableData(typeface->uniqueID(), tag, 0, tableSize, buffer);
return HB_Err_Ok;
return HB_Err_Invalid_Argument;
}
} // namespace android

View File

@@ -346,9 +346,6 @@ void TextLayoutCacheValue::initShaperItem(HB_ShaperItem& shaperItem, HB_FontRec*
font->x_scale = 1;
font->y_scale = 1;
shaperItem.font = font;
shaperItem.face = HB_NewFace(shaperItem.font, harfbuzzSkiaGetTable);
// Reset kerning
shaperItem.kerning_applied = false;
@@ -360,8 +357,11 @@ void TextLayoutCacheValue::initShaperItem(HB_ShaperItem& shaperItem, HB_FontRec*
fontData->flags = paint->getFlags();
fontData->hinting = paint->getHinting();
shaperItem.font = font;
shaperItem.font->userData = fontData;
shaperItem.face = HB_NewFace(NULL, harfbuzzSkiaGetTable);
// We cannot know, ahead of time, how many glyphs a given script run
// will produce. We take a guess that script runs will not produce more
// than twice as many glyphs as there are code points plus a bit of