Loading libs/hwui/hwui/Typeface.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -76,6 +76,7 @@ Typeface* Typeface::createRelative(Typeface* src, Typeface::Style style) { result->fBaseWeight = resolvedFace->fBaseWeight; result->fAPIStyle = style; result->fStyle = computeRelativeStyle(result->fBaseWeight, style); result->fIsVariationInstance = resolvedFace->fIsVariationInstance; } return result; } Loading @@ -88,6 +89,7 @@ Typeface* Typeface::createAbsolute(Typeface* base, int weight, bool italic) { result->fBaseWeight = resolvedFace->fBaseWeight; result->fAPIStyle = computeAPIStyle(weight, italic); result->fStyle = computeMinikinStyle(weight, italic); result->fIsVariationInstance = resolvedFace->fIsVariationInstance; } return result; } Loading @@ -109,6 +111,7 @@ Typeface* Typeface::createFromTypefaceWithVariation(Typeface* src, result->fBaseWeight = resolvedFace->fBaseWeight; result->fAPIStyle = resolvedFace->fAPIStyle; result->fStyle = resolvedFace->fStyle; result->fIsVariationInstance = true; } return result; } Loading @@ -121,6 +124,7 @@ Typeface* Typeface::createWithDifferentBaseWeight(Typeface* src, int weight) { result->fBaseWeight = weight; result->fAPIStyle = resolvedFace->fAPIStyle; result->fStyle = computeRelativeStyle(weight, result->fAPIStyle); result->fIsVariationInstance = resolvedFace->fIsVariationInstance; } return result; } Loading Loading @@ -170,6 +174,7 @@ Typeface* Typeface::createFromFamilies(std::vector<std::shared_ptr<minikin::Font result->fBaseWeight = weight; result->fAPIStyle = computeAPIStyle(weight, italic); result->fStyle = computeMinikinStyle(weight, italic); result->fIsVariationInstance = false; return result; } Loading libs/hwui/hwui/Typeface.h +3 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,9 @@ public: // base weight in CSS-style units, 1..1000 int fBaseWeight; // True if the Typeface is already created for variation settings. bool fIsVariationInstance; static const Typeface* resolveDefault(const Typeface* src); // The following three functions create new Typeface from an existing Typeface with a different Loading libs/hwui/jni/text/TextShaper.cpp +11 −3 Original line number Diff line number Diff line Loading @@ -68,7 +68,7 @@ static void releaseLayout(jlong ptr) { static jlong shapeTextRun(const uint16_t* text, int textSize, int start, int count, int contextStart, int contextCount, minikin::Bidi bidiFlags, const Paint& paint, const Typeface* typeface) { const Typeface* resolvedFace = Typeface::resolveDefault(typeface); minikin::MinikinPaint minikinPaint = MinikinUtils::prepareMinikinPaint(&paint, typeface); minikin::Layout layout = MinikinUtils::doLayout(&paint, bidiFlags, typeface, Loading Loading @@ -103,8 +103,16 @@ static jlong shapeTextRun(const uint16_t* text, int textSize, int start, int cou fontId = it->second; // We've seen it. } else { fontId = fonts.size(); // This is new to us. Create new one. std::shared_ptr<minikin::Font> font = std::make_shared<minikin::Font>( fakedFont.font, fakedFont.fakery.variationSettings()); std::shared_ptr<minikin::Font> font; if (resolvedFace->fIsVariationInstance) { // The optimization for target SDK 35 or before because the variation instance // is already created and no runtime variation resolution happens on such // environment. font = fakedFont.font; } else { font = std::make_shared<minikin::Font>(fakedFont.font, fakedFont.fakery.variationSettings()); } fonts.push_back(reinterpret_cast<jlong>(new FontWrapper(std::move(font)))); fakedToFontIds.insert(std::make_pair(fakedFont, fontId)); } Loading Loading
libs/hwui/hwui/Typeface.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -76,6 +76,7 @@ Typeface* Typeface::createRelative(Typeface* src, Typeface::Style style) { result->fBaseWeight = resolvedFace->fBaseWeight; result->fAPIStyle = style; result->fStyle = computeRelativeStyle(result->fBaseWeight, style); result->fIsVariationInstance = resolvedFace->fIsVariationInstance; } return result; } Loading @@ -88,6 +89,7 @@ Typeface* Typeface::createAbsolute(Typeface* base, int weight, bool italic) { result->fBaseWeight = resolvedFace->fBaseWeight; result->fAPIStyle = computeAPIStyle(weight, italic); result->fStyle = computeMinikinStyle(weight, italic); result->fIsVariationInstance = resolvedFace->fIsVariationInstance; } return result; } Loading @@ -109,6 +111,7 @@ Typeface* Typeface::createFromTypefaceWithVariation(Typeface* src, result->fBaseWeight = resolvedFace->fBaseWeight; result->fAPIStyle = resolvedFace->fAPIStyle; result->fStyle = resolvedFace->fStyle; result->fIsVariationInstance = true; } return result; } Loading @@ -121,6 +124,7 @@ Typeface* Typeface::createWithDifferentBaseWeight(Typeface* src, int weight) { result->fBaseWeight = weight; result->fAPIStyle = resolvedFace->fAPIStyle; result->fStyle = computeRelativeStyle(weight, result->fAPIStyle); result->fIsVariationInstance = resolvedFace->fIsVariationInstance; } return result; } Loading Loading @@ -170,6 +174,7 @@ Typeface* Typeface::createFromFamilies(std::vector<std::shared_ptr<minikin::Font result->fBaseWeight = weight; result->fAPIStyle = computeAPIStyle(weight, italic); result->fStyle = computeMinikinStyle(weight, italic); result->fIsVariationInstance = false; return result; } Loading
libs/hwui/hwui/Typeface.h +3 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,9 @@ public: // base weight in CSS-style units, 1..1000 int fBaseWeight; // True if the Typeface is already created for variation settings. bool fIsVariationInstance; static const Typeface* resolveDefault(const Typeface* src); // The following three functions create new Typeface from an existing Typeface with a different Loading
libs/hwui/jni/text/TextShaper.cpp +11 −3 Original line number Diff line number Diff line Loading @@ -68,7 +68,7 @@ static void releaseLayout(jlong ptr) { static jlong shapeTextRun(const uint16_t* text, int textSize, int start, int count, int contextStart, int contextCount, minikin::Bidi bidiFlags, const Paint& paint, const Typeface* typeface) { const Typeface* resolvedFace = Typeface::resolveDefault(typeface); minikin::MinikinPaint minikinPaint = MinikinUtils::prepareMinikinPaint(&paint, typeface); minikin::Layout layout = MinikinUtils::doLayout(&paint, bidiFlags, typeface, Loading Loading @@ -103,8 +103,16 @@ static jlong shapeTextRun(const uint16_t* text, int textSize, int start, int cou fontId = it->second; // We've seen it. } else { fontId = fonts.size(); // This is new to us. Create new one. std::shared_ptr<minikin::Font> font = std::make_shared<minikin::Font>( fakedFont.font, fakedFont.fakery.variationSettings()); std::shared_ptr<minikin::Font> font; if (resolvedFace->fIsVariationInstance) { // The optimization for target SDK 35 or before because the variation instance // is already created and no runtime variation resolution happens on such // environment. font = fakedFont.font; } else { font = std::make_shared<minikin::Font>(fakedFont.font, fakedFont.fakery.variationSettings()); } fonts.push_back(reinterpret_cast<jlong>(new FontWrapper(std::move(font)))); fakedToFontIds.insert(std::make_pair(fakedFont, fontId)); } Loading