summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Kevin Lubick <kjlubick@google.com> 2023-11-21 22:42:14 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2023-11-21 22:42:14 +0000
commit2beacf93dca89e092521f9911aa3ca3f83a74d5d (patch)
treef262d2ef9778fc12580c34c782b05445b575020a
parente4387bfe1e58286e8f535836152352a74403f271 (diff)
parent8abf724d3c9d6093c03ce8fb4f7865da72d9c8a1 (diff)
Merge "Use FreeType FontMgr instead of default when loading roboto font for tests" into main
-rw-r--r--libs/hwui/hwui/Typeface.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/libs/hwui/hwui/Typeface.cpp b/libs/hwui/hwui/Typeface.cpp
index b63ee1bd3d98..a9d1a2aed8cc 100644
--- a/libs/hwui/hwui/Typeface.cpp
+++ b/libs/hwui/hwui/Typeface.cpp
@@ -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 =