summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sample/MinikinSkia.cpp22
-rw-r--r--sample/MinikinSkia.h3
2 files changed, 14 insertions, 11 deletions
diff --git a/sample/MinikinSkia.cpp b/sample/MinikinSkia.cpp
index feda8ad..c4971bb 100644
--- a/sample/MinikinSkia.cpp
+++ b/sample/MinikinSkia.cpp
@@ -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() {
diff --git a/sample/MinikinSkia.h b/sample/MinikinSkia.h
index 25ac1b0..e1d7bf6 100644
--- a/sample/MinikinSkia.h
+++ b/sample/MinikinSkia.h
@@ -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;