Merge "Extract flag font from NotoColorEmoji" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
80a8cf86c0
@@ -304,11 +304,6 @@ public class ForwardDeleteTest {
|
|||||||
forwardDelete(state, 0);
|
forwardDelete(state, 0);
|
||||||
state.assertEquals("|");
|
state.assertEquals("|");
|
||||||
|
|
||||||
// Regional indicator symbol + COMBINING ENCLOSING KEYCAP
|
|
||||||
state.setByString("| U+1F1FA U+20E3");
|
|
||||||
forwardDelete(state, 0);
|
|
||||||
state.assertEquals("|");
|
|
||||||
|
|
||||||
// COMBINING ENCLOSING KEYCAP + emoji modifier
|
// COMBINING ENCLOSING KEYCAP + emoji modifier
|
||||||
state.setByString("| '1' U+20E3 U+1F3FB");
|
state.setByString("| '1' U+20E3 U+1F3FB");
|
||||||
forwardDelete(state, 0);
|
forwardDelete(state, 0);
|
||||||
@@ -408,11 +403,6 @@ public class ForwardDeleteTest {
|
|||||||
// forwardDelete(state, 0);
|
// forwardDelete(state, 0);
|
||||||
// state.assertEquals("|");
|
// state.assertEquals("|");
|
||||||
|
|
||||||
// Regional indicator symbol + emoji modifier
|
|
||||||
state.setByString("| U+1F1FA U+1F3FB");
|
|
||||||
forwardDelete(state, 0);
|
|
||||||
state.assertEquals("|");
|
|
||||||
|
|
||||||
// Emoji modifier + regional indicator symbol
|
// Emoji modifier + regional indicator symbol
|
||||||
state.setByString("| U+1F466 U+1F3FB U+1F1FA");
|
state.setByString("| U+1F466 U+1F3FB U+1F1FA");
|
||||||
forwardDelete(state, 0);
|
forwardDelete(state, 0);
|
||||||
|
|||||||
@@ -1331,6 +1331,9 @@
|
|||||||
<family lang="und-Zsye">
|
<family lang="und-Zsye">
|
||||||
<font weight="400" style="normal">NotoColorEmoji.ttf</font>
|
<font weight="400" style="normal">NotoColorEmoji.ttf</font>
|
||||||
</family>
|
</family>
|
||||||
|
<family lang="und-Zsye">
|
||||||
|
<font weight="400" style="normal">NotoColorEmojiFlags.ttf</font>
|
||||||
|
</family>
|
||||||
<family lang="und-Zsym">
|
<family lang="und-Zsym">
|
||||||
<font weight="400" style="normal">NotoSansSymbols-Regular-Subsetted2.ttf</font>
|
<font weight="400" style="normal">NotoSansSymbols-Regular-Subsetted2.ttf</font>
|
||||||
</family>
|
</family>
|
||||||
|
|||||||
@@ -117,9 +117,10 @@ def get_emoji_map(font):
|
|||||||
reverse_cmap = {glyph: code for code, glyph in emoji_map.items() if not contains_pua(code) }
|
reverse_cmap = {glyph: code for code, glyph in emoji_map.items() if not contains_pua(code) }
|
||||||
|
|
||||||
# Add variation sequences
|
# Add variation sequences
|
||||||
vs_dict = get_variation_sequences_cmap(font).uvsDict
|
vs_cmap = get_variation_sequences_cmap(font)
|
||||||
for vs in vs_dict:
|
if vs_cmap:
|
||||||
for base, glyph in vs_dict[vs]:
|
for vs in vs_cmap.uvsDict:
|
||||||
|
for base, glyph in vs_cmap.uvsDict[vs]:
|
||||||
if glyph is None:
|
if glyph is None:
|
||||||
emoji_map[(base, vs)] = emoji_map[base]
|
emoji_map[(base, vs)] = emoji_map[base]
|
||||||
else:
|
else:
|
||||||
@@ -310,17 +311,12 @@ def parse_fonts_xml(fonts_xml_path):
|
|||||||
|
|
||||||
|
|
||||||
def check_emoji_coverage(all_emoji, equivalent_emoji):
|
def check_emoji_coverage(all_emoji, equivalent_emoji):
|
||||||
emoji_font = get_emoji_font()
|
emoji_fonts = get_emoji_fonts()
|
||||||
check_emoji_font_coverage(emoji_font, all_emoji, equivalent_emoji)
|
check_emoji_font_coverage(emoji_fonts, all_emoji, equivalent_emoji)
|
||||||
|
|
||||||
|
|
||||||
def get_emoji_font():
|
def get_emoji_fonts():
|
||||||
emoji_fonts = [
|
return [ record.font for record in _all_fonts if 'Zsye' in record.scripts ]
|
||||||
record.font for record in _all_fonts
|
|
||||||
if 'Zsye' in record.scripts]
|
|
||||||
assert len(emoji_fonts) == 1, 'There are %d emoji fonts.' % len(emoji_fonts)
|
|
||||||
return emoji_fonts[0]
|
|
||||||
|
|
||||||
|
|
||||||
def is_pua(x):
|
def is_pua(x):
|
||||||
return 0xE000 <= x <= 0xF8FF or 0xF0000 <= x <= 0xFFFFD or 0x100000 <= x <= 0x10FFFD
|
return 0xE000 <= x <= 0xF8FF or 0xF0000 <= x <= 0xFFFFD or 0x100000 <= x <= 0x10FFFD
|
||||||
@@ -331,22 +327,33 @@ def contains_pua(sequence):
|
|||||||
else:
|
else:
|
||||||
return is_pua(sequence)
|
return is_pua(sequence)
|
||||||
|
|
||||||
|
def get_psname(ttf):
|
||||||
|
return str(next(x for x in ttf['name'].names
|
||||||
|
if x.platformID == 3 and x.platEncID == 1 and x.nameID == 6))
|
||||||
|
|
||||||
def check_emoji_compat():
|
def check_emoji_compat():
|
||||||
ttf = open_font(get_emoji_font())
|
for emoji_font in get_emoji_fonts():
|
||||||
|
ttf = open_font(emoji_font)
|
||||||
|
psname = get_psname(ttf)
|
||||||
|
|
||||||
|
# If the font file is NotoColorEmoji, it must be Compat font.
|
||||||
|
if psname == 'NotoColorEmoji':
|
||||||
meta = ttf['meta']
|
meta = ttf['meta']
|
||||||
assert meta, 'Compat font must have meta table'
|
assert meta, 'Compat font must have meta table'
|
||||||
assert 'Emji' in meta.data, 'meta table should have \'Emji\' data.'
|
assert 'Emji' in meta.data, 'meta table should have \'Emji\' data.'
|
||||||
|
|
||||||
def check_emoji_font_coverage(emoji_font, all_emoji, equivalent_emoji):
|
def check_emoji_font_coverage(emoji_fonts, all_emoji, equivalent_emoji):
|
||||||
coverage = get_emoji_map(emoji_font)
|
coverages = []
|
||||||
|
for emoji_font in emoji_fonts:
|
||||||
|
coverages.append(get_emoji_map(emoji_font))
|
||||||
|
|
||||||
errors = []
|
errors = []
|
||||||
|
|
||||||
for sequence in all_emoji:
|
for sequence in all_emoji:
|
||||||
if not sequence in coverage:
|
if all([sequence not in coverage for coverage in coverages]):
|
||||||
errors.append('%s is not supported in the emoji font.' % printable(sequence))
|
errors.append('%s is not supported in the emoji font.' % printable(sequence))
|
||||||
|
|
||||||
|
for coverage in coverages:
|
||||||
for sequence in coverage:
|
for sequence in coverage:
|
||||||
if sequence in {0x0000, 0x000D, 0x0020}:
|
if sequence in {0x0000, 0x000D, 0x0020}:
|
||||||
# The font needs to support a few extra characters, which is OK
|
# The font needs to support a few extra characters, which is OK
|
||||||
@@ -360,6 +367,7 @@ def check_emoji_font_coverage(emoji_font, all_emoji, equivalent_emoji):
|
|||||||
errors.append('%s support unexpected in the emoji font.' % printable(sequence))
|
errors.append('%s support unexpected in the emoji font.' % printable(sequence))
|
||||||
|
|
||||||
for first, second in equivalent_emoji.items():
|
for first, second in equivalent_emoji.items():
|
||||||
|
for coverage in coverages:
|
||||||
if first not in coverage or second not in coverage:
|
if first not in coverage or second not in coverage:
|
||||||
continue # sequence will be reported missing
|
continue # sequence will be reported missing
|
||||||
if coverage[first] != coverage[second]:
|
if coverage[first] != coverage[second]:
|
||||||
@@ -367,6 +375,7 @@ def check_emoji_font_coverage(emoji_font, all_emoji, equivalent_emoji):
|
|||||||
printable(first),
|
printable(first),
|
||||||
printable(second)))
|
printable(second)))
|
||||||
|
|
||||||
|
for coverage in coverages:
|
||||||
for glyph in set(coverage.values()):
|
for glyph in set(coverage.values()):
|
||||||
maps_to_glyph = [
|
maps_to_glyph = [
|
||||||
seq for seq in coverage if coverage[seq] == glyph and not contains_pua(seq) ]
|
seq for seq in coverage if coverage[seq] == glyph and not contains_pua(seq) ]
|
||||||
|
|||||||
Reference in New Issue
Block a user