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

Commit c8f060c9 authored by Chet Haase's avatar Chet Haase
Browse files

Read font info from system config files

This change adds new files in /system/etc: system_fonts.xml and
fallback_fonts.xml. The change also allows a third file to be added
by vendors in /vendor/etc/fallback_fonts.xml. These files, loaded at
boot time, mimic the logic that used to be in code, but which is
now configurable through editing these files, making the system more
flexible and easy to work with for us and vendors as future fonts
are added to the system.

Change-Id: I209f1ef08a5279b376b89a880241906387efd576
parent 649a1418
Loading
Loading
Loading
Loading
+47 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
    Fallback Fonts

    This file specifies the fonts, and the priority order, that will be searched for any
    glyphs not handled by the default fonts specified in /system/etc/system_fonts.xml.
    Each entry consists of a family tag and a list of files (file names) which support that
    family. The fonts for each family are listed in the order of the styles that they
    handle (the order is: regular, bold, italic, and bold-italic). The order in which the
    families are listed in this file represents the order in which these fallback fonts
    will be searched for glyphs that are not supported by the default system fonts (which are
    found in /system/etc/system_fonts.xml).

    Note that there is not nameset for fallback fonts, unlike the fonts specified in
    system_fonts.xml. The ability to support specific names in fallback fonts may be supported
    in the future. For now, the lack of files entries here is an indicator to the system that
    these are fallback fonts, instead of default named system fonts.

    There is another optional file in /vendor/etc/fallback_fonts.xml. That file can be used to
    provide references to other font families that should be used in addition to the default
    fallback fonts. That file can also specify the order in which the fallback fonts should be
    searched, to ensure that a vendor-provided font will be used before another fallback font
    which happens to handle the same glyph.
-->
<familyset>
    <family>
        <fileset>
            <file>DroidSansArabic.ttf</file>
        </fileset>
    </family>
    <family>
        <fileset>
            <file>DroidSansHebrew-Regular.ttf</file>
            <file>DroidSansHebrew-Bold.ttf</file>
        </fileset>
    </family>
    <family>
        <fileset>
            <file>DroidSansThai.ttf</file>
        </fileset>
    </family>
    <family>
        <fileset>
            <file>DroidSansFallback.ttf</file>
        </fileset>
    </family>
</familyset>
+3 −1
Original line number Diff line number Diff line
@@ -30,4 +30,6 @@ PRODUCT_COPY_FILES := \
    frameworks/base/data/fonts/DroidSansFallback.ttf:system/fonts/DroidSansFallback.ttf \
    frameworks/base/data/fonts/AndroidClock.ttf:system/fonts/AndroidClock.ttf \
    frameworks/base/data/fonts/AndroidClock_Highlight.ttf:system/fonts/AndroidClock_Highlight.ttf \
    frameworks/base/data/fonts/AndroidClock_Solid.ttf:system/fonts/AndroidClock_Solid.ttf
    frameworks/base/data/fonts/AndroidClock_Solid.ttf:system/fonts/AndroidClock_Solid.ttf \
    frameworks/base/data/fonts/system_fonts.xml:system/etc/system_fonts.xml \
    frameworks/base/data/fonts/fallback_fonts.xml:system/etc/fallback_fonts.xml
+68 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
    System Fonts

    This file lists the font families that will be used by default for all supported glyphs.
    Each entry consists of a family, various names that are supported by that family, and
    up to four font files. The font files are listed in the order of the styles which they
    support: regular, bold, italic and bold-italic. If less than four styles are listed, then
    the styles with no associated font file will be supported by the other font files listed.

    The first family is also the default font, which handles font request that have not specified
    specific font names.

    Any glyph that is not handled by the system fonts will cause a search of the fallback fonts.
    The default fallback fonts are specified in the file /system/etc/fallback_fonts.xml, and there
    is an optional file which may be supplied by vendors to specify other fallback fonts to use
    in /vendor/etc/fallback_fonts.xml.
-->
<familyset>

    <family>
        <nameset>
            <name>sans-serif</name>
            <name>arial</name>
            <name>helvetica</name>
            <name>tahoma</name>
            <name>verdana</name>
        </nameset>
        <fileset>
            <file>DroidSans.ttf</file>
            <file>DroidSans-Bold.ttf</file>
        </fileset>
    </family>

    <family>
        <nameset>
            <name>serif</name>
            <name>times</name>
            <name>times new roman</name>
            <name>palatino</name>
            <name>georgia</name>
            <name>baskerville</name>
            <name>goudy</name>
            <name>fantasy</name>
            <name>cursive</name>
            <name>ITC Stone Serif</name>
        </nameset>
        <fileset>
            <file>DroidSerif-Regular.ttf</file>
            <file>DroidSerif-Bold.ttf</file>
            <file>DroidSerif-Italic.ttf</file>
            <file>DroidSerif-BoldItalic.ttf</file>
        </fileset>
    </family>

    <family>
        <nameset>
            <name>monospace</name>
            <name>courier</name>
            <name>courier new</name>
            <name>monaco</name>
        </nameset>
        <fileset>
            <file>DroidSansMono.ttf</file>
        </fileset>
    </family>

</familyset>
+51 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
    Vendor-provided fallback fonts

    This file can be edited to add references to fonts that are not installed or referenced in the
    default system. The file should then be placed in /vendor/etc/fallback_fonts.xml.

    For example, vendors might want to build configurations for locales that are
    better served by fonts which either handle glyphs not supported in the default fonts or which
    handle these glyphs differently than the default fallback fonts.
    Each entry in this list is a "family", which consists of a list of "files"
    (the filenames for that family). The files objects are
    provided in the order of the styles supported for that family: regular, bold, italic, and
    bold-italic. Only providing one font means that all styles will be rendered with that font.
    Providing two means that these two fonts will render regular and bold fonts (italics will
    be mapped to these two fonts).

    There is also an optional "order" attribute on the Family tag. This specifies the index at
    which that family of fonts should be inserted in the fallback font list, where the
    default fallback fonts on the system (in /system/etc/fallback_fonts.xml) start at index 0.
    If no 'order' attribute is supplied, that family will be inserted either at the end of the
    current fallback list (if no order was supplied for any previous family in this file) or
    after the previous family (if there was an order specified previously). Typically, vendors
    may want to supply an order for the first family that puts this set of fonts at the appropriate
    place in the overall fallback fonts. The order of this list determines which fallback font
    will be used to support any glyphs that are not handled by the default system fonts.

    The sample configuration below is an example of how one might provide two families of fonts
    that get inserted at the first and second (0  and 1) position in the overall fallback fonts.

    See /system/etc/system_fonts.xml and /system/etc/fallback_fonts.xml for more information
    and to understand the order in which the default system fonts are loaded and structured for
    lookup.
-->

<!-- Sample fallback font additions to the default fallback list. These fonts will be added
    to the top two positions of the fallback list, since the first has an order of 0. -->
<!--
<familyset>
    <family order="0">
        <fileset>
            <file>MyFont.ttf</file>
        </fileset>
    </family>
    <family>
        <fileset>
            <file>MyOtherFont.ttf</file>
        </fileset>
    </family>
</familyset>
-->
 No newline at end of file