diff options
| author | 2023-08-29 15:16:59 +0900 | |
|---|---|---|
| committer | 2023-09-01 07:19:09 +0900 | |
| commit | 5da9ab7a09a4e6ef3b78a768af5c0459aa344197 (patch) | |
| tree | d3803d25e5a195e1e6545e5f72e4b2313e41f703 /graphics/java/android | |
| parent | ecc63bcb4e55997ac825ce45b083557bd97c4084 (diff) | |
Use fonts_fallback XML only when flag is ON.
Bug: 281769620
Test: m
Change-Id: I04f664da947f1cbac0bb6764c9a9a7cd3b157e27
Diffstat (limited to 'graphics/java/android')
| -rw-r--r-- | graphics/java/android/graphics/Typeface.java | 5 | ||||
| -rw-r--r-- | graphics/java/android/graphics/fonts/SystemFonts.java | 26 |
2 files changed, 28 insertions, 3 deletions
diff --git a/graphics/java/android/graphics/Typeface.java b/graphics/java/android/graphics/Typeface.java index 9fb627fcc501..4c4e8fa9c088 100644 --- a/graphics/java/android/graphics/Typeface.java +++ b/graphics/java/android/graphics/Typeface.java @@ -1475,7 +1475,10 @@ public class Typeface { String locale = SystemProperties.get("persist.sys.locale", "en-US"); String script = ULocale.addLikelySubtags(ULocale.forLanguageTag(locale)).getScript(); - FontConfig config = SystemFonts.getSystemPreinstalledFontConfig(); + // The feature flag cannot be referred from Zygote. Use legacy fonts.xml for preloading font + // files. + // TODO(nona): Use new XML file once the feature is fully launched. + FontConfig config = SystemFonts.getSystemPreinstalledFontConfigFromLegacyXml(); for (int i = 0; i < config.getFontFamilies().size(); ++i) { FontConfig.FontFamily family = config.getFontFamilies().get(i); if (!family.getLocaleList().isEmpty()) { diff --git a/graphics/java/android/graphics/fonts/SystemFonts.java b/graphics/java/android/graphics/fonts/SystemFonts.java index 36bfb98e726b..9810022abfed 100644 --- a/graphics/java/android/graphics/fonts/SystemFonts.java +++ b/graphics/java/android/graphics/fonts/SystemFonts.java @@ -48,6 +48,8 @@ public final class SystemFonts { private static final String TAG = "SystemFonts"; private static final String FONTS_XML = "/system/etc/font_fallback.xml"; + private static final String LEGACY_FONTS_XML = "/system/etc/fonts.xml"; + /** @hide */ public static final String SYSTEM_FONT_DIR = "/system/fonts/"; private static final String OEM_XML = "/product/etc/fonts_customization.xml"; @@ -230,7 +232,13 @@ public final class SystemFonts { long lastModifiedDate, int configVersion ) { - return getSystemFontConfigInternal(FONTS_XML, SYSTEM_FONT_DIR, OEM_XML, OEM_FONT_DIR, + final String fontsXml; + if (com.android.text.flags.Flags.deprecateFontsXml()) { + fontsXml = FONTS_XML; + } else { + fontsXml = LEGACY_FONTS_XML; + } + return getSystemFontConfigInternal(fontsXml, SYSTEM_FONT_DIR, OEM_XML, OEM_FONT_DIR, updatableFontMap, lastModifiedDate, configVersion); } @@ -255,10 +263,24 @@ public final class SystemFonts { * @hide */ public static @NonNull FontConfig getSystemPreinstalledFontConfig() { - return getSystemFontConfigInternal(FONTS_XML, SYSTEM_FONT_DIR, OEM_XML, OEM_FONT_DIR, null, + final String fontsXml; + if (com.android.text.flags.Flags.deprecateFontsXml()) { + fontsXml = FONTS_XML; + } else { + fontsXml = LEGACY_FONTS_XML; + } + return getSystemFontConfigInternal(fontsXml, SYSTEM_FONT_DIR, OEM_XML, OEM_FONT_DIR, null, 0, 0); } + /** + * @hide + */ + public static @NonNull FontConfig getSystemPreinstalledFontConfigFromLegacyXml() { + return getSystemFontConfigInternal(LEGACY_FONTS_XML, SYSTEM_FONT_DIR, OEM_XML, OEM_FONT_DIR, + null, 0, 0); + } + /* package */ static @NonNull FontConfig getSystemFontConfigInternal( @NonNull String fontsXml, @NonNull String systemFontDir, |