diff options
| -rw-r--r-- | libs/hwui/hwui/MinikinSkia.cpp | 17 | ||||
| -rw-r--r-- | libs/hwui/hwui/MinikinSkia.h | 2 | ||||
| -rw-r--r-- | libs/hwui/hwui/Typeface.cpp | 15 |
3 files changed, 13 insertions, 21 deletions
diff --git a/libs/hwui/hwui/MinikinSkia.cpp b/libs/hwui/hwui/MinikinSkia.cpp index a52abfc9888a..f172473d1652 100644 --- a/libs/hwui/hwui/MinikinSkia.cpp +++ b/libs/hwui/hwui/MinikinSkia.cpp @@ -65,23 +65,6 @@ void MinikinFontSkia::GetBounds(minikin::MinikinRect* bounds, uint32_t glyph_id, bounds->mBottom = skBounds.fBottom; } -const void* MinikinFontSkia::GetTable(uint32_t tag, size_t* size, - minikin::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() const { return mTypeface.get(); } diff --git a/libs/hwui/hwui/MinikinSkia.h b/libs/hwui/hwui/MinikinSkia.h index 1ea99fd899a9..3ee916c6e8b1 100644 --- a/libs/hwui/hwui/MinikinSkia.h +++ b/libs/hwui/hwui/MinikinSkia.h @@ -37,8 +37,6 @@ public: void GetBounds(minikin::MinikinRect* bounds, uint32_t glyph_id, const minikin::MinikinPaint &paint) const; - const void* GetTable(uint32_t tag, size_t* size, minikin::MinikinDestroyFunc* destroy); - SkTypeface* GetSkTypeface() const; sk_sp<SkTypeface> RefSkTypeface() const; diff --git a/libs/hwui/hwui/Typeface.cpp b/libs/hwui/hwui/Typeface.cpp index f95d98cac8d6..ca43156e88a1 100644 --- a/libs/hwui/hwui/Typeface.cpp +++ b/libs/hwui/hwui/Typeface.cpp @@ -23,10 +23,14 @@ #include "Typeface.h" #include <pthread.h> +#include <fcntl.h> // For tests. +#include <sys/stat.h> // For tests. +#include <sys/mman.h> // For tests. #include "MinikinSkia.h" #include "SkTypeface.h" #include "SkPaint.h" +#include "SkStream.h" // Fot tests. #include <minikin/FontCollection.h> #include <minikin/FontFamily.h> @@ -116,11 +120,18 @@ void Typeface::setDefault(Typeface* face) { void Typeface::setRobotoTypefaceForTest() { const char* kRobotoFont = "/system/fonts/Roboto-Regular.ttf"; - sk_sp<SkTypeface> typeface = SkTypeface::MakeFromFile(kRobotoFont); + + int fd = open(kRobotoFont, O_RDONLY); + LOG_ALWAYS_FATAL_IF(fd == -1, "Failed to open file %s", kRobotoFont); + struct stat st = {}; + LOG_ALWAYS_FATAL_IF(fstat(fd, &st) == -1, "Failed to stat file %s", kRobotoFont); + void* data = mmap(nullptr, st.st_size, PROT_READ, MAP_SHARED, fd, 0); + std::unique_ptr<SkMemoryStream> fontData(new SkMemoryStream(data, st.st_size)); + sk_sp<SkTypeface> typeface = SkTypeface::MakeFromStream(fontData.release()); LOG_ALWAYS_FATAL_IF(typeface == nullptr, "Failed to make typeface from %s", kRobotoFont); minikin::FontFamily* family = new minikin::FontFamily(); - minikin::MinikinFont* font = new MinikinFontSkia(std::move(typeface), nullptr, 0, 0); + minikin::MinikinFont* font = new MinikinFontSkia(std::move(typeface), data, st.st_size, 0); family->addFont(font); font->Unref(); |