Skip to content

Commit

Permalink
Revert "Started taking advantage of Skia's new copyTableData to avoid (
Browse files Browse the repository at this point in the history
…flutter#10154)" (flutter#12263)

This reverts commit 6beba53 as it breaks flutter on ios 32-bit devices.
  • Loading branch information
aam authored Sep 13, 2019
1 parent 0897b50 commit 1b63444
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions third_party/txt/src/txt/font_skia.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 <minikin/MinikinFont.h>
Expand All @@ -25,14 +24,21 @@ namespace {

hb_blob_t* GetTable(hb_face_t* face, hb_tag_t tag, void* context) {
SkTypeface* typeface = reinterpret_cast<SkTypeface*>(context);
sk_sp<SkData> 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<char*>(rawData->writable_data()),
rawData->size(), HB_MEMORY_MODE_WRITABLE, rawData,
[](void* ctx) { ((SkData*)ctx)->unref(); });
return hb_blob_create(reinterpret_cast<char*>(buffer), table_size,
HB_MEMORY_MODE_WRITABLE, buffer, free);
}

} // namespace
Expand Down

0 comments on commit 1b63444

Please sign in to comment.