Update minikin/sample code to use new GetTable

am: 29abb82

* commit '29abb82198868908ece4600284fa8b7d3ed73f3b':
  Update minikin/sample code to use new GetTable

Change-Id: I5fcae79c42322dcc0533dbd3eb1a51007e089170
This commit is contained in:
Raph Levien 2016-04-08 17:55:14 +00:00 committed by android-build-merger
commit bfc161d8fa
2 changed files with 14 additions and 11 deletions

View File

@ -47,16 +47,20 @@ void MinikinFontSkia::GetBounds(MinikinRect* bounds, uint32_t glyph_id,
bounds->mBottom = skBounds.fBottom;
}
bool MinikinFontSkia::GetTable(uint32_t tag, uint8_t *buf, size_t *size) {
if (buf == NULL) {
const size_t tableSize = mTypeface->getTableSize(tag);
*size = tableSize;
return tableSize != 0;
} else {
const size_t actualSize = mTypeface->getTableData(tag, 0, *size, buf);
*size = actualSize;
return actualSize != 0;
const void* MinikinFontSkia::GetTable(uint32_t tag, size_t* size, MinikinDestroyFunc* destroy) {
// we don't have a buffer to the font data, copy to own buffer
const size_t tableSize = mTypeface->getTableSize(tag);
*size = tableSize;
if (tableSize == 0) {
return nullptr;
}
void* buf = malloc(tableSize);
if (buf == nullptr) {
return nullptr;
}
mTypeface->getTableData(tag, 0, tableSize, buf);
*destroy = free;
return buf;
}
SkTypeface *MinikinFontSkia::GetSkTypeface() {

View File

@ -12,8 +12,7 @@ public:
void GetBounds(MinikinRect* bounds, uint32_t glyph_id,
const MinikinPaint& paint) const;
// If buf is NULL, just update size
bool GetTable(uint32_t tag, uint8_t *buf, size_t *size);
const void* GetTable(uint32_t tag, size_t* size, MinikinDestroyFunc* destroy);
int32_t GetUniqueId() const;