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

Commit d06d32bc authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Use fontation SkTypeface backend" into main

parents 7efe495c 3008d3c2
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -215,3 +215,10 @@ flag {
  bug: "355296926"
  is_exported: true
}

flag {
  name: "use_fontation_by_default"
  namespace: "text"
  description: "Use Fontation(Skrifa) as a default text reader."
  bug: "405267306"
}
+9 −0
Original line number Diff line number Diff line
@@ -43,6 +43,15 @@ inline bool typeface_redesign_readonly() {
#endif  // __ANDROID__
}

inline bool use_fontation_by_default() {
#ifdef __ANDROID__
    static bool flag = com_android_text_flags_use_fontation_by_default();
    return flag;
#else
    return true;
#endif  // __ANDROID__
}

}  // namespace text_feature

namespace view_accessibility_flags {
+10 −0
Original line number Diff line number Diff line
@@ -238,6 +238,16 @@ enum DebugLevel {

#define PROPERTY_EARLY_PRELOAD_GL_CONTEXT "debug.hwui.early_preload_gl_context"

/**
 * Property for font reading library.
 */
#define PROPERTY_SKTYPEFACE_BACKEND "debug.hwui.text.backend"

enum class SkTypefaceBackend {
    kAuto = 0,
    kFreeType = 1,
    kFontation = 2,
};
///////////////////////////////////////////////////////////////////////////////
// Misc
///////////////////////////////////////////////////////////////////////////////
+1 −3
Original line number Diff line number Diff line
@@ -160,9 +160,7 @@ 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<SkFontMgr> fm = android::FreeTypeFontMgr();
    LOG_ALWAYS_FATAL_IF(fm == nullptr, "Could not load FreeType SkFontMgr");
    sk_sp<SkTypeface> typeface = fm->makeFromStream(std::move(fontData));
    sk_sp<SkTypeface> typeface = android::makeSkTypeface(std::move(fontData), SkFontArguments());
    LOG_ALWAYS_FATAL_IF(typeface == nullptr, "Failed to make typeface from %s", kRobotoFont);

    std::shared_ptr<minikin::MinikinFont> font = std::make_shared<MinikinFontSkia>(
+1 −2
Original line number Diff line number Diff line
@@ -126,8 +126,7 @@ static bool addSkTypeface(NativeFamilyBuilder* builder, sk_sp<SkData>&& data, in
    args.setCollectionIndex(ttcIndex);
    args.setVariationDesignPosition({skVariation.data(), static_cast<int>(skVariation.size())});

    sk_sp<SkFontMgr> fm = android::FreeTypeFontMgr();
    sk_sp<SkTypeface> face(fm->makeFromStream(std::move(fontData), args));
    sk_sp<SkTypeface> face = makeSkTypeface(std::move(fontData), args);
    if (face == NULL) {
        ALOGE("addFont failed to create font, invalid request");
        builder->axes.clear();
Loading