Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8abf724d authored by Kevin Lubick's avatar Kevin Lubick
Browse files

Use FreeType FontMgr instead of default when loading roboto font for tests

Change-Id: I8943f5f12d3d61a15d7fc1fe7091a8685eeb7bdd
parent d908e5f2
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -25,8 +25,9 @@

#include "MinikinSkia.h"
#include "SkPaint.h"
#include "SkStream.h"  // Fot tests.
#include "SkStream.h"  // For tests.
#include "SkTypeface.h"
#include "utils/TypefaceUtils.h"

#include <minikin/FontCollection.h>
#include <minikin/FontFamily.h>
@@ -186,7 +187,9 @@ void Typeface::setRobotoTypefaceForTest() {
    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<SkStreamAsset> fontData(new SkMemoryStream(data, st.st_size));
    sk_sp<SkTypeface> typeface = SkTypeface::MakeFromStream(std::move(fontData));
    sk_sp<SkFontMgr> fm = android::FreeTypeFontMgr();
    LOG_ALWAYS_FATAL_IF(fm == nullptr, "Could not load FreeType SkFontMgr");
    sk_sp<SkTypeface> typeface = fm->makeFromStream(std::move(fontData));
    LOG_ALWAYS_FATAL_IF(typeface == nullptr, "Failed to make typeface from %s", kRobotoFont);

    std::shared_ptr<minikin::MinikinFont> font =