Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e3510a82 authored by Seigo Nonaka's avatar Seigo Nonaka
Browse files

Deprecate fonts.xml and add hidden font_fallback.xml

Not to break the apps that reads fonts.xml and add new features to
the system font customization at the same time, this CL introduces
new hidden XML file font_fallback.xml which is currently a copy of
the fonts.xml.

The fonts.xml still exists but may not contain the latest system font
settings due to compatibility problems. Application should use the
public API for accessing system installed fonts which is available
from API29.

Bug: 281769620
Test: atest CtsGraphicsTestCases
Test: atest CtsTextTestCases
Change-Id: I556b5fffb0c78f0c6150b472fd240b9a546de93f
Merged-In: I556b5fffb0c78f0c6150b472fd240b9a546de93f
parent e7627bd7
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -52,3 +52,8 @@ prebuilt_etc {
    name: "fonts.xml",
    src: "fonts.xml",
}

prebuilt_etc {
    name: "font_fallback.xml",
    src: "font_fallback.xml",
}
+1626 −0

File added.

Preview size limit exceeded, changes collapsed.

+1 −0
Original line number Diff line number Diff line
@@ -17,4 +17,5 @@
PRODUCT_PACKAGES := \
    DroidSansMono.ttf \
    AndroidClock.ttf \
    font_fallback.xml \
    fonts.xml
+12 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
    DEPRECATED: This XML file is no longer a source of the font files installed
    in the system.

    For the device vendors: please add your font configurations to the
    platform/frameworks/base/data/font_fallback.xml and also add it to this XML
    file as much as possible for apps that reads this XML file.

    For the application developers: please stop reading this XML file and use
    android.graphics.fonts.SystemFonts#getAvailableFonts Java API or
    ASystemFontIterator_open NDK API for getting list of system installed
    font files.

    WARNING: Parsing of this file by third-party apps is not supported. The
    file, and the font files it refers to, will be renamed and/or moved out
    from their respective location in the next Android release, and/or the
+14 −1
Original line number Diff line number Diff line
@@ -46,7 +46,7 @@ import java.util.Set;
public final class SystemFonts {
    private static final String TAG = "SystemFonts";

    private static final String FONTS_XML = "/system/etc/fonts.xml";
    private static final String FONTS_XML = "/system/etc/font_fallback.xml";
    /** @hide */
    public static final String SYSTEM_FONT_DIR = "/system/fonts/";
    private static final String OEM_XML = "/product/etc/fonts_customization.xml";
@@ -207,6 +207,19 @@ public final class SystemFonts {
        fallbackListMap.put(familyName, fallback);
    }

    /**
     * Get the updated FontConfig for testing purposes.
     * @hide
     */
    public static @NonNull FontConfig getSystemFontConfigForTesting(
            @NonNull String fontsXmlPath,
            @Nullable Map<String, File> updatableFontMap,
            long lastModifiedDate,
            int configVersion) {
        return getSystemFontConfigInternal(fontsXmlPath, SYSTEM_FONT_DIR, OEM_XML, OEM_FONT_DIR,
                updatableFontMap, lastModifiedDate, configVersion);
    }

    /**
     * Get the updated FontConfig.
     *
Loading