From 7d492128b695589615cf862b2142dca56b8551e5 Mon Sep 17 00:00:00 2001 From: Alexander Aprelev Date: Fri, 13 Sep 2019 10:24:28 -0700 Subject: [PATCH] Revert "Started taking advantage of Skia's new copyTableData to avoid (#10154)" (flutter/engine#12263) This reverts commit 1440d6a5465d3c22b199f56b5a2ceaea7963b183 as it breaks flutter on ios 32-bit devices. --- .../third_party/txt/src/txt/font_skia.cc | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/engine/src/flutter/third_party/txt/src/txt/font_skia.cc b/engine/src/flutter/third_party/txt/src/txt/font_skia.cc index c825b93dd1..e0dc263929 100644 --- a/engine/src/flutter/third_party/txt/src/txt/font_skia.cc +++ b/engine/src/flutter/third_party/txt/src/txt/font_skia.cc @@ -15,7 +15,6 @@ */ #include "font_skia.h" -#include "third_party/skia/include/core/SkData.h" #include "third_party/skia/include/core/SkFont.h" #include @@ -25,14 +24,21 @@ namespace { hb_blob_t* GetTable(hb_face_t* face, hb_tag_t tag, void* context) { SkTypeface* typeface = reinterpret_cast(context); - sk_sp data = typeface->copyTableData(tag); - if (!data) { + + const size_t table_size = typeface->getTableSize(tag); + if (table_size == 0) + return nullptr; + void* buffer = malloc(table_size); + if (buffer == nullptr) + return nullptr; + + size_t actual_size = typeface->getTableData(tag, 0, table_size, buffer); + if (table_size != actual_size) { + free(buffer); return nullptr; } - SkData* rawData = data.release(); - return hb_blob_create(reinterpret_cast(rawData->writable_data()), - rawData->size(), HB_MEMORY_MODE_WRITABLE, rawData, - [](void* ctx) { ((SkData*)ctx)->unref(); }); + return hb_blob_create(reinterpret_cast(buffer), table_size, + HB_MEMORY_MODE_WRITABLE, buffer, free); } } // namespace