diff options
Diffstat (limited to 'tools/fonts/fontchain_linter.py')
-rwxr-xr-x | tools/fonts/fontchain_linter.py | 56 |
1 files changed, 4 insertions, 52 deletions
diff --git a/tools/fonts/fontchain_linter.py b/tools/fonts/fontchain_linter.py index 35a0ce60e359..50fce57add39 100755 --- a/tools/fonts/fontchain_linter.py +++ b/tools/fonts/fontchain_linter.py @@ -381,62 +381,14 @@ def hex_strs(sequence): return tuple(f"{s:X}" for s in sequence) return hex(sequence) -def check_plausible_compat_pua(coverage, all_emoji, equivalent_emoji): - # A PUA should point to every RGI emoji and that PUA should be unique to the - # set of equivalent sequences for the emoji. - problems = [] - for seq in all_emoji: - # We're looking to match not-PUA with PUA so filter out existing PUA - if contains_pua(seq): - continue - - # Filter out non-RGI things that end up in all_emoji - if only_tags(seq) or seq in {ZWJ, COMBINING_KEYCAP, EMPTY_FLAG_SEQUENCE}: - continue - - equivalents = [seq] - if seq in equivalent_emoji: - equivalents.append(equivalent_emoji[seq]) - - # If there are problems the hex code is much more useful - log_equivalents = [hex_strs(s) for s in equivalents] - - # The system compat font should NOT include regional indicators as these have been split out - if contains_regional_indicator(seq): - assert not any(s in coverage for s in equivalents), f"Regional indicators not expected in compat font, found {log_equivalents}" - continue - - glyph = {coverage[e] for e in equivalents} - if len(glyph) != 1: - problems.append(f"{log_equivalents} should all point to the same glyph") - continue - glyph = next(iter(glyph)) - - pua = {s for s, g in coverage.items() if contains_pua(s) and g == glyph} - if not pua: - problems.append(f"Expected PUA for {log_equivalents} but none exist") - continue - - assert not problems, "\n".join(sorted(problems)) + f"\n{len(problems)} PUA problems" - -def check_emoji_compat(all_emoji, equivalent_emoji): +def check_emoji_not_compat(all_emoji, equivalent_emoji): compat_psnames = set() for emoji_font in get_emoji_fonts(): ttf = open_font(emoji_font) psname = get_psname(ttf) - is_compat_font = "meta" in ttf and 'Emji' in ttf["meta"].data - if not is_compat_font: - continue - compat_psnames.add(psname) - - # If the font has compat metadata it should have PUAs for emoji sequences - coverage = get_emoji_map(emoji_font) - check_plausible_compat_pua(coverage, all_emoji, equivalent_emoji) - - - # NotoColorEmoji must be a Compat font. - assert 'NotoColorEmoji' in compat_psnames, 'NotoColorEmoji MUST be a compat font' + if "meta" in ttf: + assert 'Emji' not in ttf["meta"].data, 'NotoColorEmoji MUST NOT be a compat font' def check_emoji_font_coverage(emoji_fonts, all_emoji, equivalent_emoji): @@ -847,7 +799,7 @@ def main(): ucd_path = sys.argv[3] parse_ucd(ucd_path) all_emoji, default_emoji, equivalent_emoji = compute_expected_emoji() - check_emoji_compat(all_emoji, equivalent_emoji) + check_emoji_not_compat(all_emoji, equivalent_emoji) check_emoji_coverage(all_emoji, equivalent_emoji) check_emoji_defaults(default_emoji) |