From b11b963ed14d952cc2eb85e272780f92fa5b8b09 Mon Sep 17 00:00:00 2001 From: Kohsuke Yatoh Date: Mon, 16 Nov 2020 10:41:58 -0800 Subject: Prepare switching font loading to system server. Currently, fonts are loaded in Zygote. This CL adds a preparation to switch it to system server and bindApplication(), so that system server will be able to update font map at runtime. (1) Zygote will be initialized without fonts. (2) System server will maintain a serialized font map in ashmem. (3) Apps will load font map from the ashmem in bindApplication(). The change is guarded by Typeface.ENABLE_LAZY_TYPEFACE_INITIALIZATION, and the new behavior is disabled by default. I tested with ENABLE_LAZY_TYPEFACE_INITIALIZATION = true. Bug: 172891184 Test: atest FrameworksCoreTests:TypefaceTest Test: atest CtsGraphicsTestCases Test: atest CtsTextTestCases Test: atest CtsWidgetTestCases Change-Id: I40832962a4b27f6160c4dc6268689c52f6a4dd33 --- core/java/android/widget/TextView.java | 3 +++ 1 file changed, 3 insertions(+) (limited to 'core/java/android/widget/TextView.java') diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index 2357f368c428..02a930017906 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -964,6 +964,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener * @hide */ public static void preloadFontCache() { + if (Typeface.ENABLE_LAZY_TYPEFACE_INITIALIZATION) { + return; + } Paint p = new Paint(); p.setAntiAlias(true); // Ensure that the Typeface is loaded here. -- cgit v1.2.3