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

Commit 2beacf93 authored by Kevin Lubick's avatar Kevin Lubick Committed by Android (Google) Code Review
Browse files

Merge "Use FreeType FontMgr instead of default when loading roboto font for tests" into main

parents e4387bfe 8abf724d
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 =