Merge "Remove obsolete interface GetTable."
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user