From 146c6a93d722ba9e8e259650646394f159f5e352 Mon Sep 17 00:00:00 2001 From: Kohsuke Yatoh Date: Sat, 16 Jul 2022 00:15:41 +0000 Subject: [PATCH] Replace getFamilies() with getFamilyAt(). Following minikin signature change. Bug: 174672300 Test: m libhwui Test: m libandroid Change-Id: I25c5d27c406f49b5ee91a7f4390484296d4a6c7f --- libs/hwui/jni/Typeface.cpp | 14 +++++++------- native/android/system_fonts.cpp | 7 ++++--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/libs/hwui/jni/Typeface.cpp b/libs/hwui/jni/Typeface.cpp index e79b395412b07..30d6d0009d3b1 100644 --- a/libs/hwui/jni/Typeface.cpp +++ b/libs/hwui/jni/Typeface.cpp @@ -111,15 +111,15 @@ static jlong Typeface_createFromArray(JNIEnv *env, jobject, jlongArray familyArr std::vector> familyVec; Typeface* typeface = (fallbackPtr == 0) ? nullptr : toTypeface(fallbackPtr); if (typeface != nullptr) { - const std::vector>& fallbackFamilies = - toTypeface(fallbackPtr)->fFontCollection->getFamilies(); - familyVec.reserve(families.size() + fallbackFamilies.size()); + const std::shared_ptr& fallbackCollection = + toTypeface(fallbackPtr)->fFontCollection; + familyVec.reserve(families.size() + fallbackCollection->getFamilyCount()); for (size_t i = 0; i < families.size(); i++) { FontFamilyWrapper* family = reinterpret_cast(families[i]); familyVec.emplace_back(family->family); } - for (size_t i = 0; i < fallbackFamilies.size(); i++) { - familyVec.emplace_back(fallbackFamilies[i]); + for (size_t i = 0; i < fallbackCollection->getFamilyCount(); i++) { + familyVec.emplace_back(fallbackCollection->getFamilyAt(i)); } } else { familyVec.reserve(families.size()); @@ -360,13 +360,13 @@ static void Typeface_forceSetStaticFinalField(JNIEnv *env, jclass cls, jstring f // Critical Native static jint Typeface_getFamilySize(CRITICAL_JNI_PARAMS_COMMA jlong faceHandle) { - return toTypeface(faceHandle)->fFontCollection->getFamilies().size(); + return toTypeface(faceHandle)->fFontCollection->getFamilyCount(); } // Critical Native static jlong Typeface_getFamily(CRITICAL_JNI_PARAMS_COMMA jlong faceHandle, jint index) { std::shared_ptr family = - toTypeface(faceHandle)->fFontCollection->getFamilies()[index]; + toTypeface(faceHandle)->fFontCollection->getFamilyAt(index); return reinterpret_cast(new FontFamilyWrapper(std::move(family))); } diff --git a/native/android/system_fonts.cpp b/native/android/system_fonts.cpp index 9fe792958cefa..4df745ff6a200 100644 --- a/native/android/system_fonts.cpp +++ b/native/android/system_fonts.cpp @@ -248,9 +248,10 @@ ASystemFontIterator* ASystemFontIterator_open() { minikin::SystemFonts::getFontMap( [&fonts](const std::vector>& collections) { for (const auto& fc : collections) { - for (const auto& family : fc->getFamilies()) { - for (uint32_t i = 0; i < family->getNumFonts(); ++i) { - const minikin::Font* font = family->getFont(i); + for (uint32_t i = 0; i < fc->getFamilyCount(); ++i) { + const auto& family = fc->getFamilyAt(i); + for (uint32_t j = 0; j < family->getNumFonts(); ++j) { + const minikin::Font* font = family->getFont(j); std::optional locale; uint32_t localeId = font->getLocaleListId();