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

Commit 1232382a authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Add legacy emoji font file for compatibility" into tm-dev am: e93f2d09

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17072947

Change-Id: Ia50f762c46d500893837b6d0be6e1294e5d9e31b
parents ee19740c e93f2d09
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -355,6 +355,27 @@ public final class FontListParserTest {
        assertThat(config.getAliases()).isEmpty();
    }

    @Test
    public void ignore() throws Exception {
        String xml = "<?xml version='1.0' encoding='UTF-8'?>"
                + "<familyset>"
                + "  <family name='sans-serif'>"
                + "    <font>test.ttf</font>"
                + "  </family>"
                + "  <family lang='und-Zsye' ignore='true'>"
                + "    <font>emoji_legacy.ttf</font>"
                + "  </family>"
                + "  <family lang='und-Zsye'>"
                + "    <font>emoji.ttf</font>"
                + "  </family>"
                + "</familyset>";
        FontConfig config = readFamilies(xml, true /* include non-existing font files */);
        List<FontConfig.FontFamily> families = config.getFontFamilies();
        assertThat(families.size()).isEqualTo(2);  // legacy one should be ignored.
        assertThat(families.get(1).getFontList().get(0).getFile().getName())
                .isEqualTo("emoji.ttf");
    }

    private FontConfig readFamilies(String xml, boolean allowNonExisting)
            throws IOException, XmlPullParserException {
        ByteArrayInputStream buffer = new ByteArrayInputStream(
+3 −0
Original line number Diff line number Diff line
@@ -1328,6 +1328,9 @@
              postScriptName="NotoSerifCJKjp-Regular">NotoSerifCJK-Regular.ttc
        </font>
    </family>
    <family lang="und-Zsye" ignore="true">
        <font weight="400" style="normal">NotoColorEmojiLegacy.ttf</font>
    </family>
    <family lang="und-Zsye">
        <font weight="400" style="normal">NotoColorEmoji.ttf</font>
    </family>
+4 −1
Original line number Diff line number Diff line
@@ -218,6 +218,7 @@ public class FontListParser {
        final String name = parser.getAttributeValue(null, "name");
        final String lang = parser.getAttributeValue("", "lang");
        final String variant = parser.getAttributeValue(null, "variant");
        final String ignore = parser.getAttributeValue(null, "ignore");
        final List<FontConfig.Font> fonts = new ArrayList<>();
        while (keepReading(parser)) {
            if (parser.getEventType() != XmlPullParser.START_TAG) continue;
@@ -240,7 +241,9 @@ public class FontListParser {
                intVariant = FontConfig.FontFamily.VARIANT_ELEGANT;
            }
        }
        if (fonts.isEmpty()) {

        boolean skip = (ignore != null && (ignore.equals("true") || ignore.equals("1")));
        if (skip || fonts.isEmpty()) {
            return null;
        }
        return new FontConfig.FontFamily(fonts, name, LocaleList.forLanguageTags(lang), intVariant);
+7 −0
Original line number Diff line number Diff line
@@ -243,6 +243,8 @@ def parse_fonts_xml(fonts_xml_path):
        name = family.get('name')
        variant = family.get('variant')
        langs = family.get('lang')
        ignoreAttr = family.get('ignore')

        if name:
            assert variant is None, (
                'No variant expected for LGC font %s.' % name)
@@ -259,6 +261,11 @@ def parse_fonts_xml(fonts_xml_path):
        name = family.get('name')
        variant = family.get('variant')
        langs = family.get('lang')
        ignoreAttr = family.get('ignore')
        ignore = ignoreAttr == 'true' or ignoreAttr == '1'

        if ignore:
            continue

        if langs:
            langs = langs.split()