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

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

Merge "Use run based APIs for iterating fonts" into main

parents 4cc6b39f 3c07e21b
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -49,6 +49,15 @@ inline bool letter_spacing_justification() {
#endif  // __ANDROID__
}

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

}  // namespace text_feature

}  // namespace android
+33 −16
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@
#include <cutils/compiler.h>
#include <log/log.h>
#include <minikin/Layout.h>

#include "FeatureFlags.h"
#include "MinikinSkia.h"
#include "Paint.h"
#include "Typeface.h"
@@ -71,6 +73,20 @@ public:
    static void forFontRun(const minikin::Layout& layout, Paint* paint, F& f) {
        float saveSkewX = paint->getSkFont().getSkewX();
        bool savefakeBold = paint->getSkFont().isEmbolden();
        if (text_feature::typeface_redesign()) {
            for (uint32_t runIdx = 0; runIdx < layout.getFontRunCount(); ++runIdx) {
                uint32_t start = layout.getFontRunStart(runIdx);
                uint32_t end = layout.getFontRunEnd(runIdx);
                const minikin::FakedFont& fakedFont = layout.getFontRunFont(runIdx);

                std::shared_ptr<minikin::MinikinFont> font = fakedFont.typeface();
                SkFont* skfont = &paint->getSkFont();
                MinikinFontSkia::populateSkFont(skfont, font.get(), fakedFont.fakery);
                f(start, end);
                skfont->setSkewX(saveSkewX);
                skfont->setEmbolden(savefakeBold);
            }
        } else {
            const minikin::MinikinFont* curFont = nullptr;
            size_t start = 0;
            size_t nGlyphs = layout.nGlyphs();
@@ -94,6 +110,7 @@ public:
                skfont->setEmbolden(savefakeBold);
            }
        }
    }
};

}  // namespace android