Add legacy emoji font file for compatibility
Bug: 222362958 Test: Manually verified Flutter Gallary shows emoji. Test: atest CtsTextTestCases CtsGraphicsTestCases Test: atest FontListParserTest Change-Id: If5b5ddfb6d0d46cfb8d27cf66843ae95d4b50e03
This commit is contained in:
parent
e2d43ee89e
commit
e26eb8ce33
@ -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(
|
||||
|
@ -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>
|
||||
|
@ -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);
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user