Merge "Preload Roboto-Regualr.ttf" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
4c417f3bde
@@ -1346,6 +1346,19 @@ public class Typeface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
// Preload Roboto-Regular.ttf in Zygote for improving app launch performance.
|
||||||
|
// TODO: add new attribute to fonts.xml to preload fonts in Zygote.
|
||||||
|
preloadFontFile("/system/fonts/Roboto-Regular.ttf");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void preloadFontFile(String filePath) {
|
||||||
|
File file = new File(filePath);
|
||||||
|
if (file.exists()) {
|
||||||
|
nativeWarmUpCache(filePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public static void destroySystemFontMap() {
|
public static void destroySystemFontMap() {
|
||||||
@@ -1464,4 +1477,6 @@ public class Typeface {
|
|||||||
private static native @Nullable long[] nativeReadTypefaces(@NonNull ByteBuffer buffer);
|
private static native @Nullable long[] nativeReadTypefaces(@NonNull ByteBuffer buffer);
|
||||||
|
|
||||||
private static native void nativeForceSetStaticFinalField(String fieldName, Typeface typeface);
|
private static native void nativeForceSetStaticFinalField(String fieldName, Typeface typeface);
|
||||||
|
|
||||||
|
private static native void nativeWarmUpCache(String fileName);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -367,6 +367,12 @@ static jlong Typeface_getFamily(CRITICAL_JNI_PARAMS_COMMA jlong faceHandle, jint
|
|||||||
return reinterpret_cast<jlong>(new FontFamilyWrapper(std::move(family)));
|
return reinterpret_cast<jlong>(new FontFamilyWrapper(std::move(family)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Regular JNI
|
||||||
|
static void Typeface_warmUpCache(JNIEnv* env, jobject, jstring jFilePath) {
|
||||||
|
ScopedUtfChars filePath(env, jFilePath);
|
||||||
|
makeSkDataCached(filePath.c_str(), false /* fs verity */);
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
static const JNINativeMethod gTypefaceMethods[] = {
|
static const JNINativeMethod gTypefaceMethods[] = {
|
||||||
@@ -390,6 +396,7 @@ static const JNINativeMethod gTypefaceMethods[] = {
|
|||||||
(void*)Typeface_forceSetStaticFinalField},
|
(void*)Typeface_forceSetStaticFinalField},
|
||||||
{"nativeGetFamilySize", "(J)I", (void*)Typeface_getFamilySize},
|
{"nativeGetFamilySize", "(J)I", (void*)Typeface_getFamilySize},
|
||||||
{"nativeGetFamily", "(JI)J", (void*)Typeface_getFamily},
|
{"nativeGetFamily", "(JI)J", (void*)Typeface_getFamily},
|
||||||
|
{"nativeWarmUpCache", "(Ljava/lang/String;)V", (void*)Typeface_warmUpCache},
|
||||||
};
|
};
|
||||||
|
|
||||||
int register_android_graphics_Typeface(JNIEnv* env)
|
int register_android_graphics_Typeface(JNIEnv* env)
|
||||||
|
|||||||
Reference in New Issue
Block a user