Roozbeh Pournader | 0e969e2 | 2016-03-09 23:08:45 -0800 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
| 3 | import collections |
Roozbeh Pournader | 5dde087 | 2016-03-31 13:54:56 -0700 | [diff] [blame] | 4 | import copy |
Roozbeh Pournader | 0e969e2 | 2016-03-09 23:08:45 -0800 | [diff] [blame] | 5 | import glob |
| 6 | from os import path |
| 7 | import sys |
| 8 | from xml.etree import ElementTree |
| 9 | |
| 10 | from fontTools import ttLib |
| 11 | |
Roozbeh Pournader | 5dde087 | 2016-03-31 13:54:56 -0700 | [diff] [blame] | 12 | EMOJI_VS = 0xFE0F |
| 13 | |
Roozbeh Pournader | 0e969e2 | 2016-03-09 23:08:45 -0800 | [diff] [blame] | 14 | LANG_TO_SCRIPT = { |
Jungshik Shin | 6c4f9e0 | 2016-03-19 09:32:34 -0700 | [diff] [blame] | 15 | 'as': 'Beng', |
Roozbeh Pournader | 7e04dd1 | 2017-10-13 17:41:31 -0700 | [diff] [blame] | 16 | 'be': 'Cyrl', |
Roozbeh Pournader | 033b222 | 2017-02-22 18:53:39 -0800 | [diff] [blame] | 17 | 'bg': 'Cyrl', |
Jungshik Shin | 6c4f9e0 | 2016-03-19 09:32:34 -0700 | [diff] [blame] | 18 | 'bn': 'Beng', |
Roozbeh Pournader | 033b222 | 2017-02-22 18:53:39 -0800 | [diff] [blame] | 19 | 'cu': 'Cyrl', |
Jungshik Shin | 6c4f9e0 | 2016-03-19 09:32:34 -0700 | [diff] [blame] | 20 | 'cy': 'Latn', |
| 21 | 'da': 'Latn', |
Roozbeh Pournader | 0e969e2 | 2016-03-09 23:08:45 -0800 | [diff] [blame] | 22 | 'de': 'Latn', |
| 23 | 'en': 'Latn', |
| 24 | 'es': 'Latn', |
Jungshik Shin | 6c4f9e0 | 2016-03-19 09:32:34 -0700 | [diff] [blame] | 25 | 'et': 'Latn', |
Roozbeh Pournader | 0e969e2 | 2016-03-09 23:08:45 -0800 | [diff] [blame] | 26 | 'eu': 'Latn', |
Jungshik Shin | 6c4f9e0 | 2016-03-19 09:32:34 -0700 | [diff] [blame] | 27 | 'fr': 'Latn', |
| 28 | 'ga': 'Latn', |
| 29 | 'gu': 'Gujr', |
| 30 | 'hi': 'Deva', |
| 31 | 'hr': 'Latn', |
Roozbeh Pournader | 0e969e2 | 2016-03-09 23:08:45 -0800 | [diff] [blame] | 32 | 'hu': 'Latn', |
| 33 | 'hy': 'Armn', |
Jungshik Shin | 6c4f9e0 | 2016-03-19 09:32:34 -0700 | [diff] [blame] | 34 | 'ja': 'Jpan', |
| 35 | 'kn': 'Knda', |
| 36 | 'ko': 'Kore', |
Roozbeh Pournader | 7e04dd1 | 2017-10-13 17:41:31 -0700 | [diff] [blame] | 37 | 'la': 'Latn', |
Jungshik Shin | 6c4f9e0 | 2016-03-19 09:32:34 -0700 | [diff] [blame] | 38 | 'ml': 'Mlym', |
| 39 | 'mn': 'Cyrl', |
| 40 | 'mr': 'Deva', |
Roozbeh Pournader | 0e969e2 | 2016-03-09 23:08:45 -0800 | [diff] [blame] | 41 | 'nb': 'Latn', |
| 42 | 'nn': 'Latn', |
Jungshik Shin | 6c4f9e0 | 2016-03-19 09:32:34 -0700 | [diff] [blame] | 43 | 'or': 'Orya', |
| 44 | 'pa': 'Guru', |
Roozbeh Pournader | 0e969e2 | 2016-03-09 23:08:45 -0800 | [diff] [blame] | 45 | 'pt': 'Latn', |
Jungshik Shin | 6c4f9e0 | 2016-03-19 09:32:34 -0700 | [diff] [blame] | 46 | 'sl': 'Latn', |
| 47 | 'ta': 'Taml', |
| 48 | 'te': 'Telu', |
| 49 | 'tk': 'Latn', |
Roozbeh Pournader | 0e969e2 | 2016-03-09 23:08:45 -0800 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | def lang_to_script(lang_code): |
| 53 | lang = lang_code.lower() |
| 54 | while lang not in LANG_TO_SCRIPT: |
| 55 | hyphen_idx = lang.rfind('-') |
| 56 | assert hyphen_idx != -1, ( |
| 57 | 'We do not know what script the "%s" language is written in.' |
| 58 | % lang_code) |
| 59 | assumed_script = lang[hyphen_idx+1:] |
| 60 | if len(assumed_script) == 4 and assumed_script.isalpha(): |
| 61 | # This is actually the script |
| 62 | return assumed_script.title() |
| 63 | lang = lang[:hyphen_idx] |
| 64 | return LANG_TO_SCRIPT[lang] |
| 65 | |
| 66 | |
Roozbeh Pournader | 5dde087 | 2016-03-31 13:54:56 -0700 | [diff] [blame] | 67 | def printable(inp): |
| 68 | if type(inp) is set: # set of character sequences |
| 69 | return '{' + ', '.join([printable(seq) for seq in inp]) + '}' |
| 70 | if type(inp) is tuple: # character sequence |
| 71 | return '<' + (', '.join([printable(ch) for ch in inp])) + '>' |
| 72 | else: # single character |
| 73 | return 'U+%04X' % inp |
| 74 | |
| 75 | |
| 76 | def open_font(font): |
Roozbeh Pournader | 0e969e2 | 2016-03-09 23:08:45 -0800 | [diff] [blame] | 77 | font_file, index = font |
| 78 | font_path = path.join(_fonts_dir, font_file) |
| 79 | if index is not None: |
Roozbeh Pournader | 5dde087 | 2016-03-31 13:54:56 -0700 | [diff] [blame] | 80 | return ttLib.TTFont(font_path, fontNumber=index) |
Roozbeh Pournader | 0e969e2 | 2016-03-09 23:08:45 -0800 | [diff] [blame] | 81 | else: |
Roozbeh Pournader | 5dde087 | 2016-03-31 13:54:56 -0700 | [diff] [blame] | 82 | return ttLib.TTFont(font_path) |
| 83 | |
| 84 | |
| 85 | def get_best_cmap(font): |
| 86 | ttfont = open_font(font) |
Roozbeh Pournader | 0e969e2 | 2016-03-09 23:08:45 -0800 | [diff] [blame] | 87 | all_unicode_cmap = None |
| 88 | bmp_cmap = None |
| 89 | for cmap in ttfont['cmap'].tables: |
| 90 | specifier = (cmap.format, cmap.platformID, cmap.platEncID) |
| 91 | if specifier == (4, 3, 1): |
| 92 | assert bmp_cmap is None, 'More than one BMP cmap in %s' % (font, ) |
| 93 | bmp_cmap = cmap |
| 94 | elif specifier == (12, 3, 10): |
| 95 | assert all_unicode_cmap is None, ( |
| 96 | 'More than one UCS-4 cmap in %s' % (font, )) |
| 97 | all_unicode_cmap = cmap |
| 98 | |
| 99 | return all_unicode_cmap.cmap if all_unicode_cmap else bmp_cmap.cmap |
| 100 | |
| 101 | |
Roozbeh Pournader | 5dde087 | 2016-03-31 13:54:56 -0700 | [diff] [blame] | 102 | def get_variation_sequences_cmap(font): |
| 103 | ttfont = open_font(font) |
| 104 | vs_cmap = None |
| 105 | for cmap in ttfont['cmap'].tables: |
| 106 | specifier = (cmap.format, cmap.platformID, cmap.platEncID) |
| 107 | if specifier == (14, 0, 5): |
| 108 | assert vs_cmap is None, 'More than one VS cmap in %s' % (font, ) |
| 109 | vs_cmap = cmap |
| 110 | return vs_cmap |
| 111 | |
| 112 | |
| 113 | def get_emoji_map(font): |
| 114 | # Add normal characters |
| 115 | emoji_map = copy.copy(get_best_cmap(font)) |
| 116 | reverse_cmap = {glyph: code for code, glyph in emoji_map.items()} |
| 117 | |
| 118 | # Add variation sequences |
| 119 | vs_dict = get_variation_sequences_cmap(font).uvsDict |
| 120 | for vs in vs_dict: |
| 121 | for base, glyph in vs_dict[vs]: |
| 122 | if glyph is None: |
| 123 | emoji_map[(base, vs)] = emoji_map[base] |
| 124 | else: |
| 125 | emoji_map[(base, vs)] = glyph |
| 126 | |
| 127 | # Add GSUB rules |
| 128 | ttfont = open_font(font) |
| 129 | for lookup in ttfont['GSUB'].table.LookupList.Lookup: |
Roozbeh Pournader | aa3ee8e | 2017-04-10 13:52:20 -0700 | [diff] [blame] | 130 | if lookup.LookupType != 4: |
| 131 | # Other lookups are used in the emoji font for fallback. |
| 132 | # We ignore them for now. |
| 133 | continue |
Roozbeh Pournader | 5dde087 | 2016-03-31 13:54:56 -0700 | [diff] [blame] | 134 | for subtable in lookup.SubTable: |
| 135 | ligatures = subtable.ligatures |
| 136 | for first_glyph in ligatures: |
| 137 | for ligature in ligatures[first_glyph]: |
| 138 | sequence = [first_glyph] + ligature.Component |
| 139 | sequence = [reverse_cmap[glyph] for glyph in sequence] |
| 140 | sequence = tuple(sequence) |
| 141 | # Make sure no starting subsequence of 'sequence' has been |
| 142 | # seen before. |
| 143 | for sub_len in range(2, len(sequence)+1): |
| 144 | subsequence = sequence[:sub_len] |
| 145 | assert subsequence not in emoji_map |
| 146 | emoji_map[sequence] = ligature.LigGlyph |
| 147 | |
| 148 | return emoji_map |
| 149 | |
| 150 | |
Roozbeh Pournader | 0e969e2 | 2016-03-09 23:08:45 -0800 | [diff] [blame] | 151 | def assert_font_supports_any_of_chars(font, chars): |
| 152 | best_cmap = get_best_cmap(font) |
| 153 | for char in chars: |
| 154 | if char in best_cmap: |
| 155 | return |
| 156 | sys.exit('None of characters in %s were found in %s' % (chars, font)) |
| 157 | |
| 158 | |
Roozbeh Pournader | fa1facc | 2016-03-16 13:53:47 -0700 | [diff] [blame] | 159 | def assert_font_supports_all_of_chars(font, chars): |
| 160 | best_cmap = get_best_cmap(font) |
| 161 | for char in chars: |
| 162 | assert char in best_cmap, ( |
| 163 | 'U+%04X was not found in %s' % (char, font)) |
| 164 | |
| 165 | |
| 166 | def assert_font_supports_none_of_chars(font, chars): |
| 167 | best_cmap = get_best_cmap(font) |
| 168 | for char in chars: |
| 169 | assert char not in best_cmap, ( |
| 170 | 'U+%04X was found in %s' % (char, font)) |
| 171 | |
| 172 | |
Roozbeh Pournader | 5dde087 | 2016-03-31 13:54:56 -0700 | [diff] [blame] | 173 | def assert_font_supports_all_sequences(font, sequences): |
| 174 | vs_dict = get_variation_sequences_cmap(font).uvsDict |
| 175 | for base, vs in sorted(sequences): |
| 176 | assert vs in vs_dict and (base, None) in vs_dict[vs], ( |
| 177 | '<U+%04X, U+%04X> was not found in %s' % (base, vs, font)) |
| 178 | |
| 179 | |
Roozbeh Pournader | 0e969e2 | 2016-03-09 23:08:45 -0800 | [diff] [blame] | 180 | def check_hyphens(hyphens_dir): |
| 181 | # Find all the scripts that need automatic hyphenation |
| 182 | scripts = set() |
| 183 | for hyb_file in glob.iglob(path.join(hyphens_dir, '*.hyb')): |
| 184 | hyb_file = path.basename(hyb_file) |
| 185 | assert hyb_file.startswith('hyph-'), ( |
| 186 | 'Unknown hyphenation file %s' % hyb_file) |
| 187 | lang_code = hyb_file[hyb_file.index('-')+1:hyb_file.index('.')] |
| 188 | scripts.add(lang_to_script(lang_code)) |
| 189 | |
| 190 | HYPHENS = {0x002D, 0x2010} |
| 191 | for script in scripts: |
| 192 | fonts = _script_to_font_map[script] |
| 193 | assert fonts, 'No fonts found for the "%s" script' % script |
| 194 | for font in fonts: |
| 195 | assert_font_supports_any_of_chars(font, HYPHENS) |
| 196 | |
| 197 | |
Roozbeh Pournader | 5dde087 | 2016-03-31 13:54:56 -0700 | [diff] [blame] | 198 | class FontRecord(object): |
| 199 | def __init__(self, name, scripts, variant, weight, style, font): |
| 200 | self.name = name |
| 201 | self.scripts = scripts |
| 202 | self.variant = variant |
| 203 | self.weight = weight |
| 204 | self.style = style |
| 205 | self.font = font |
| 206 | |
| 207 | |
Roozbeh Pournader | 0e969e2 | 2016-03-09 23:08:45 -0800 | [diff] [blame] | 208 | def parse_fonts_xml(fonts_xml_path): |
| 209 | global _script_to_font_map, _fallback_chain |
| 210 | _script_to_font_map = collections.defaultdict(set) |
| 211 | _fallback_chain = [] |
| 212 | tree = ElementTree.parse(fonts_xml_path) |
Seigo Nonaka | 9092dc2 | 2017-01-06 16:54:52 +0900 | [diff] [blame] | 213 | families = tree.findall('family') |
| 214 | # Minikin supports up to 254 but users can place their own font at the first |
| 215 | # place. Thus, 253 is the maximum allowed number of font families in the |
| 216 | # default collection. |
| 217 | assert len(families) < 254, ( |
| 218 | 'System font collection can contains up to 253 font families.') |
| 219 | for family in families: |
Roozbeh Pournader | 0e969e2 | 2016-03-09 23:08:45 -0800 | [diff] [blame] | 220 | name = family.get('name') |
| 221 | variant = family.get('variant') |
| 222 | langs = family.get('lang') |
| 223 | if name: |
| 224 | assert variant is None, ( |
| 225 | 'No variant expected for LGC font %s.' % name) |
| 226 | assert langs is None, ( |
| 227 | 'No language expected for LGC fonts %s.' % name) |
| 228 | else: |
| 229 | assert variant in {None, 'elegant', 'compact'}, ( |
| 230 | 'Unexpected value for variant: %s' % variant) |
| 231 | |
| 232 | if langs: |
| 233 | langs = langs.split() |
| 234 | scripts = {lang_to_script(lang) for lang in langs} |
| 235 | else: |
| 236 | scripts = set() |
| 237 | |
| 238 | for child in family: |
| 239 | assert child.tag == 'font', ( |
| 240 | 'Unknown tag <%s>' % child.tag) |
Jungshik Shin | 88b1114 | 2017-03-17 14:56:17 -0700 | [diff] [blame] | 241 | font_file = child.text.rstrip() |
Roozbeh Pournader | 0e969e2 | 2016-03-09 23:08:45 -0800 | [diff] [blame] | 242 | weight = int(child.get('weight')) |
| 243 | assert weight % 100 == 0, ( |
| 244 | 'Font weight "%d" is not a multiple of 100.' % weight) |
| 245 | |
| 246 | style = child.get('style') |
| 247 | assert style in {'normal', 'italic'}, ( |
| 248 | 'Unknown style "%s"' % style) |
| 249 | |
| 250 | index = child.get('index') |
| 251 | if index: |
| 252 | index = int(index) |
| 253 | |
Roozbeh Pournader | 5dde087 | 2016-03-31 13:54:56 -0700 | [diff] [blame] | 254 | _fallback_chain.append(FontRecord( |
Roozbeh Pournader | 0e969e2 | 2016-03-09 23:08:45 -0800 | [diff] [blame] | 255 | name, |
| 256 | frozenset(scripts), |
| 257 | variant, |
| 258 | weight, |
| 259 | style, |
| 260 | (font_file, index))) |
| 261 | |
| 262 | if name: # non-empty names are used for default LGC fonts |
| 263 | map_scripts = {'Latn', 'Grek', 'Cyrl'} |
| 264 | else: |
| 265 | map_scripts = scripts |
| 266 | for script in map_scripts: |
| 267 | _script_to_font_map[script].add((font_file, index)) |
| 268 | |
| 269 | |
Roozbeh Pournader | 5dde087 | 2016-03-31 13:54:56 -0700 | [diff] [blame] | 270 | def check_emoji_coverage(all_emoji, equivalent_emoji): |
Roozbeh Pournader | 3b3c78e | 2016-07-25 14:04:34 -0700 | [diff] [blame] | 271 | emoji_font = get_emoji_font() |
| 272 | check_emoji_font_coverage(emoji_font, all_emoji, equivalent_emoji) |
Doug Felt | f874a19 | 2016-07-08 17:42:15 -0700 | [diff] [blame] | 273 | |
| 274 | |
| 275 | def get_emoji_font(): |
Roozbeh Pournader | 5dde087 | 2016-03-31 13:54:56 -0700 | [diff] [blame] | 276 | emoji_fonts = [ |
| 277 | record.font for record in _fallback_chain |
| 278 | if 'Zsye' in record.scripts] |
Roozbeh Pournader | 27ec3ac | 2016-03-31 13:05:32 -0700 | [diff] [blame] | 279 | assert len(emoji_fonts) == 1, 'There are %d emoji fonts.' % len(emoji_fonts) |
Doug Felt | f874a19 | 2016-07-08 17:42:15 -0700 | [diff] [blame] | 280 | return emoji_fonts[0] |
Roozbeh Pournader | 5dde087 | 2016-03-31 13:54:56 -0700 | [diff] [blame] | 281 | |
Doug Felt | f874a19 | 2016-07-08 17:42:15 -0700 | [diff] [blame] | 282 | |
| 283 | def check_emoji_font_coverage(emoji_font, all_emoji, equivalent_emoji): |
| 284 | coverage = get_emoji_map(emoji_font) |
Roozbeh Pournader | 5dde087 | 2016-03-31 13:54:56 -0700 | [diff] [blame] | 285 | for sequence in all_emoji: |
| 286 | assert sequence in coverage, ( |
| 287 | '%s is not supported in the emoji font.' % printable(sequence)) |
| 288 | |
| 289 | for sequence in coverage: |
| 290 | if sequence in {0x0000, 0x000D, 0x0020}: |
| 291 | # The font needs to support a few extra characters, which is OK |
| 292 | continue |
| 293 | assert sequence in all_emoji, ( |
| 294 | 'Emoji font should not support %s.' % printable(sequence)) |
| 295 | |
| 296 | for first, second in sorted(equivalent_emoji.items()): |
| 297 | assert coverage[first] == coverage[second], ( |
| 298 | '%s and %s should map to the same glyph.' % ( |
| 299 | printable(first), |
| 300 | printable(second))) |
| 301 | |
| 302 | for glyph in set(coverage.values()): |
| 303 | maps_to_glyph = [seq for seq in coverage if coverage[seq] == glyph] |
| 304 | if len(maps_to_glyph) > 1: |
| 305 | # There are more than one sequences mapping to the same glyph. We |
| 306 | # need to make sure they were expected to be equivalent. |
| 307 | equivalent_seqs = set() |
| 308 | for seq in maps_to_glyph: |
| 309 | equivalent_seq = seq |
| 310 | while equivalent_seq in equivalent_emoji: |
| 311 | equivalent_seq = equivalent_emoji[equivalent_seq] |
| 312 | equivalent_seqs.add(equivalent_seq) |
| 313 | assert len(equivalent_seqs) == 1, ( |
| 314 | 'The sequences %s should not result in the same glyph %s' % ( |
| 315 | printable(equivalent_seqs), |
| 316 | glyph)) |
Roozbeh Pournader | 3b3c78e | 2016-07-25 14:04:34 -0700 | [diff] [blame] | 317 | |
Roozbeh Pournader | fa1facc | 2016-03-16 13:53:47 -0700 | [diff] [blame] | 318 | |
Roozbeh Pournader | 5dde087 | 2016-03-31 13:54:56 -0700 | [diff] [blame] | 319 | def check_emoji_defaults(default_emoji): |
| 320 | missing_text_chars = _emoji_properties['Emoji'] - default_emoji |
Roozbeh Pournader | fa1facc | 2016-03-16 13:53:47 -0700 | [diff] [blame] | 321 | emoji_font_seen = False |
Roozbeh Pournader | 5dde087 | 2016-03-31 13:54:56 -0700 | [diff] [blame] | 322 | for record in _fallback_chain: |
| 323 | if 'Zsye' in record.scripts: |
Roozbeh Pournader | fa1facc | 2016-03-16 13:53:47 -0700 | [diff] [blame] | 324 | emoji_font_seen = True |
| 325 | # No need to check the emoji font |
| 326 | continue |
| 327 | # For later fonts, we only check them if they have a script |
| 328 | # defined, since the defined script may get them to a higher |
yirui | f9936b9 | 2016-09-07 14:37:30 +0900 | [diff] [blame] | 329 | # score even if they appear after the emoji font. However, |
| 330 | # we should skip checking the text symbols font, since |
| 331 | # symbol fonts should be able to override the emoji display |
| 332 | # style when 'Zsym' is explicitly specified by the user. |
| 333 | if emoji_font_seen and (not record.scripts or 'Zsym' in record.scripts): |
Roozbeh Pournader | fa1facc | 2016-03-16 13:53:47 -0700 | [diff] [blame] | 334 | continue |
| 335 | |
Roozbeh Pournader | 7b822e5 | 2016-03-16 18:55:32 -0700 | [diff] [blame] | 336 | # Check default emoji-style characters |
Roozbeh Pournader | 5dde087 | 2016-03-31 13:54:56 -0700 | [diff] [blame] | 337 | assert_font_supports_none_of_chars(record.font, sorted(default_emoji)) |
Roozbeh Pournader | fa1facc | 2016-03-16 13:53:47 -0700 | [diff] [blame] | 338 | |
Roozbeh Pournader | 7b822e5 | 2016-03-16 18:55:32 -0700 | [diff] [blame] | 339 | # Mark default text-style characters appearing in fonts above the emoji |
| 340 | # font as seen |
| 341 | if not emoji_font_seen: |
Roozbeh Pournader | 5dde087 | 2016-03-31 13:54:56 -0700 | [diff] [blame] | 342 | missing_text_chars -= set(get_best_cmap(record.font)) |
Roozbeh Pournader | 7b822e5 | 2016-03-16 18:55:32 -0700 | [diff] [blame] | 343 | |
Roozbeh Pournader | 5dde087 | 2016-03-31 13:54:56 -0700 | [diff] [blame] | 344 | # Noto does not have monochrome glyphs for Unicode 7.0 wingdings and |
| 345 | # webdings yet. |
Roozbeh Pournader | 7b822e5 | 2016-03-16 18:55:32 -0700 | [diff] [blame] | 346 | missing_text_chars -= _chars_by_age['7.0'] |
Roozbeh Pournader | 7b822e5 | 2016-03-16 18:55:32 -0700 | [diff] [blame] | 347 | assert missing_text_chars == set(), ( |
Roozbeh Pournader | 3b3c78e | 2016-07-25 14:04:34 -0700 | [diff] [blame] | 348 | 'Text style version of some emoji characters are missing: ' + |
| 349 | repr(missing_text_chars)) |
Roozbeh Pournader | fa1facc | 2016-03-16 13:53:47 -0700 | [diff] [blame] | 350 | |
| 351 | |
Roozbeh Pournader | 7b822e5 | 2016-03-16 18:55:32 -0700 | [diff] [blame] | 352 | # Setting reverse to true returns a dictionary that maps the values to sets of |
| 353 | # characters, useful for some binary properties. Otherwise, we get a |
| 354 | # dictionary that maps characters to the property values, assuming there's only |
| 355 | # one property in the file. |
| 356 | def parse_unicode_datafile(file_path, reverse=False): |
| 357 | if reverse: |
| 358 | output_dict = collections.defaultdict(set) |
| 359 | else: |
| 360 | output_dict = {} |
| 361 | with open(file_path) as datafile: |
| 362 | for line in datafile: |
Roozbeh Pournader | fa1facc | 2016-03-16 13:53:47 -0700 | [diff] [blame] | 363 | if '#' in line: |
| 364 | line = line[:line.index('#')] |
| 365 | line = line.strip() |
| 366 | if not line: |
| 367 | continue |
Roozbeh Pournader | 5dde087 | 2016-03-31 13:54:56 -0700 | [diff] [blame] | 368 | |
Roozbeh Pournader | 3b3c78e | 2016-07-25 14:04:34 -0700 | [diff] [blame] | 369 | chars, prop = line.split(';')[:2] |
Roozbeh Pournader | 5dde087 | 2016-03-31 13:54:56 -0700 | [diff] [blame] | 370 | chars = chars.strip() |
Roozbeh Pournader | fa1facc | 2016-03-16 13:53:47 -0700 | [diff] [blame] | 371 | prop = prop.strip() |
Roozbeh Pournader | 5dde087 | 2016-03-31 13:54:56 -0700 | [diff] [blame] | 372 | |
| 373 | if ' ' in chars: # character sequence |
| 374 | sequence = [int(ch, 16) for ch in chars.split(' ')] |
| 375 | additions = [tuple(sequence)] |
| 376 | elif '..' in chars: # character range |
| 377 | char_start, char_end = chars.split('..') |
| 378 | char_start = int(char_start, 16) |
| 379 | char_end = int(char_end, 16) |
| 380 | additions = xrange(char_start, char_end+1) |
| 381 | else: # singe character |
| 382 | additions = [int(chars, 16)] |
Roozbeh Pournader | 7b822e5 | 2016-03-16 18:55:32 -0700 | [diff] [blame] | 383 | if reverse: |
Roozbeh Pournader | 5dde087 | 2016-03-31 13:54:56 -0700 | [diff] [blame] | 384 | output_dict[prop].update(additions) |
Roozbeh Pournader | 7b822e5 | 2016-03-16 18:55:32 -0700 | [diff] [blame] | 385 | else: |
Roozbeh Pournader | 5dde087 | 2016-03-31 13:54:56 -0700 | [diff] [blame] | 386 | for addition in additions: |
| 387 | assert addition not in output_dict |
| 388 | output_dict[addition] = prop |
Roozbeh Pournader | 7b822e5 | 2016-03-16 18:55:32 -0700 | [diff] [blame] | 389 | return output_dict |
| 390 | |
| 391 | |
Roozbeh Pournader | aa3ee8e | 2017-04-10 13:52:20 -0700 | [diff] [blame] | 392 | def parse_emoji_variants(file_path): |
Roozbeh Pournader | 5dde087 | 2016-03-31 13:54:56 -0700 | [diff] [blame] | 393 | emoji_set = set() |
| 394 | text_set = set() |
| 395 | with open(file_path) as datafile: |
| 396 | for line in datafile: |
| 397 | if '#' in line: |
| 398 | line = line[:line.index('#')] |
| 399 | line = line.strip() |
| 400 | if not line: |
| 401 | continue |
| 402 | sequence, description, _ = line.split(';') |
| 403 | sequence = sequence.strip().split(' ') |
| 404 | base = int(sequence[0], 16) |
| 405 | vs = int(sequence[1], 16) |
| 406 | description = description.strip() |
| 407 | if description == 'text style': |
| 408 | text_set.add((base, vs)) |
| 409 | elif description == 'emoji style': |
| 410 | emoji_set.add((base, vs)) |
| 411 | return text_set, emoji_set |
| 412 | |
| 413 | |
Roozbeh Pournader | 7b822e5 | 2016-03-16 18:55:32 -0700 | [diff] [blame] | 414 | def parse_ucd(ucd_path): |
| 415 | global _emoji_properties, _chars_by_age |
Roozbeh Pournader | 5dde087 | 2016-03-31 13:54:56 -0700 | [diff] [blame] | 416 | global _text_variation_sequences, _emoji_variation_sequences |
| 417 | global _emoji_sequences, _emoji_zwj_sequences |
Roozbeh Pournader | 7b822e5 | 2016-03-16 18:55:32 -0700 | [diff] [blame] | 418 | _emoji_properties = parse_unicode_datafile( |
| 419 | path.join(ucd_path, 'emoji-data.txt'), reverse=True) |
Roozbeh Pournader | f7a68c1 | 2017-04-04 18:59:31 -0700 | [diff] [blame] | 420 | emoji_properties_additions = parse_unicode_datafile( |
| 421 | path.join(ucd_path, 'additions', 'emoji-data.txt'), reverse=True) |
| 422 | for prop in emoji_properties_additions.keys(): |
| 423 | _emoji_properties[prop].update(emoji_properties_additions[prop]) |
| 424 | |
Roozbeh Pournader | 7b822e5 | 2016-03-16 18:55:32 -0700 | [diff] [blame] | 425 | _chars_by_age = parse_unicode_datafile( |
| 426 | path.join(ucd_path, 'DerivedAge.txt'), reverse=True) |
Roozbeh Pournader | aa3ee8e | 2017-04-10 13:52:20 -0700 | [diff] [blame] | 427 | sequences = parse_emoji_variants( |
| 428 | path.join(ucd_path, 'emoji-variation-sequences.txt')) |
Roozbeh Pournader | 5dde087 | 2016-03-31 13:54:56 -0700 | [diff] [blame] | 429 | _text_variation_sequences, _emoji_variation_sequences = sequences |
| 430 | _emoji_sequences = parse_unicode_datafile( |
| 431 | path.join(ucd_path, 'emoji-sequences.txt')) |
Siyamed Sinir | 6e06ad0 | 2017-04-19 18:18:35 -0700 | [diff] [blame] | 432 | _emoji_sequences.update(parse_unicode_datafile( |
| 433 | path.join(ucd_path, 'additions', 'emoji-sequences.txt'))) |
Roozbeh Pournader | 5dde087 | 2016-03-31 13:54:56 -0700 | [diff] [blame] | 434 | _emoji_zwj_sequences = parse_unicode_datafile( |
| 435 | path.join(ucd_path, 'emoji-zwj-sequences.txt')) |
Roozbeh Pournader | 1800ba4 | 2017-03-17 18:23:23 -0700 | [diff] [blame] | 436 | _emoji_zwj_sequences.update(parse_unicode_datafile( |
| 437 | path.join(ucd_path, 'additions', 'emoji-zwj-sequences.txt'))) |
Roozbeh Pournader | 5dde087 | 2016-03-31 13:54:56 -0700 | [diff] [blame] | 438 | |
| 439 | |
| 440 | def flag_sequence(territory_code): |
| 441 | return tuple(0x1F1E6 + ord(ch) - ord('A') for ch in territory_code) |
| 442 | |
| 443 | |
| 444 | UNSUPPORTED_FLAGS = frozenset({ |
| 445 | flag_sequence('BL'), flag_sequence('BQ'), flag_sequence('DG'), |
| 446 | flag_sequence('EA'), flag_sequence('EH'), flag_sequence('FK'), |
| 447 | flag_sequence('GF'), flag_sequence('GP'), flag_sequence('GS'), |
| 448 | flag_sequence('MF'), flag_sequence('MQ'), flag_sequence('NC'), |
| 449 | flag_sequence('PM'), flag_sequence('RE'), flag_sequence('TF'), |
Roozbeh Pournader | aa3ee8e | 2017-04-10 13:52:20 -0700 | [diff] [blame] | 450 | flag_sequence('WF'), flag_sequence('XK'), flag_sequence('YT'), |
Roozbeh Pournader | 5dde087 | 2016-03-31 13:54:56 -0700 | [diff] [blame] | 451 | }) |
| 452 | |
| 453 | EQUIVALENT_FLAGS = { |
| 454 | flag_sequence('BV'): flag_sequence('NO'), |
| 455 | flag_sequence('CP'): flag_sequence('FR'), |
| 456 | flag_sequence('HM'): flag_sequence('AU'), |
| 457 | flag_sequence('SJ'): flag_sequence('NO'), |
| 458 | flag_sequence('UM'): flag_sequence('US'), |
| 459 | } |
| 460 | |
| 461 | COMBINING_KEYCAP = 0x20E3 |
| 462 | |
| 463 | LEGACY_ANDROID_EMOJI = { |
| 464 | 0xFE4E5: flag_sequence('JP'), |
| 465 | 0xFE4E6: flag_sequence('US'), |
| 466 | 0xFE4E7: flag_sequence('FR'), |
| 467 | 0xFE4E8: flag_sequence('DE'), |
| 468 | 0xFE4E9: flag_sequence('IT'), |
| 469 | 0xFE4EA: flag_sequence('GB'), |
| 470 | 0xFE4EB: flag_sequence('ES'), |
| 471 | 0xFE4EC: flag_sequence('RU'), |
| 472 | 0xFE4ED: flag_sequence('CN'), |
| 473 | 0xFE4EE: flag_sequence('KR'), |
| 474 | 0xFE82C: (ord('#'), COMBINING_KEYCAP), |
| 475 | 0xFE82E: (ord('1'), COMBINING_KEYCAP), |
| 476 | 0xFE82F: (ord('2'), COMBINING_KEYCAP), |
| 477 | 0xFE830: (ord('3'), COMBINING_KEYCAP), |
| 478 | 0xFE831: (ord('4'), COMBINING_KEYCAP), |
| 479 | 0xFE832: (ord('5'), COMBINING_KEYCAP), |
| 480 | 0xFE833: (ord('6'), COMBINING_KEYCAP), |
| 481 | 0xFE834: (ord('7'), COMBINING_KEYCAP), |
| 482 | 0xFE835: (ord('8'), COMBINING_KEYCAP), |
| 483 | 0xFE836: (ord('9'), COMBINING_KEYCAP), |
| 484 | 0xFE837: (ord('0'), COMBINING_KEYCAP), |
| 485 | } |
| 486 | |
| 487 | ZWJ_IDENTICALS = { |
| 488 | # KISS |
| 489 | (0x1F469, 0x200D, 0x2764, 0x200D, 0x1F48B, 0x200D, 0x1F468): 0x1F48F, |
| 490 | # COUPLE WITH HEART |
| 491 | (0x1F469, 0x200D, 0x2764, 0x200D, 0x1F468): 0x1F491, |
| 492 | # FAMILY |
| 493 | (0x1F468, 0x200D, 0x1F469, 0x200D, 0x1F466): 0x1F46A, |
| 494 | } |
| 495 | |
Roozbeh Pournader | aa3ee8e | 2017-04-10 13:52:20 -0700 | [diff] [blame] | 496 | ZWJ = 0x200D |
| 497 | FEMALE_SIGN = 0x2640 |
| 498 | MALE_SIGN = 0x2642 |
| 499 | |
| 500 | GENDER_DEFAULTS = [ |
| 501 | (0x26F9, MALE_SIGN), # PERSON WITH BALL |
| 502 | (0x1F3C3, MALE_SIGN), # RUNNER |
| 503 | (0x1F3C4, MALE_SIGN), # SURFER |
| 504 | (0x1F3CA, MALE_SIGN), # SWIMMER |
| 505 | (0x1F3CB, MALE_SIGN), # WEIGHT LIFTER |
| 506 | (0x1F3CC, MALE_SIGN), # GOLFER |
| 507 | (0x1F46E, MALE_SIGN), # POLICE OFFICER |
| 508 | (0x1F46F, FEMALE_SIGN), # WOMAN WITH BUNNY EARS |
| 509 | (0x1F471, MALE_SIGN), # PERSON WITH BLOND HAIR |
| 510 | (0x1F473, MALE_SIGN), # MAN WITH TURBAN |
| 511 | (0x1F477, MALE_SIGN), # CONSTRUCTION WORKER |
| 512 | (0x1F481, FEMALE_SIGN), # INFORMATION DESK PERSON |
| 513 | (0x1F482, MALE_SIGN), # GUARDSMAN |
| 514 | (0x1F486, FEMALE_SIGN), # FACE MASSAGE |
| 515 | (0x1F487, FEMALE_SIGN), # HAIRCUT |
| 516 | (0x1F575, MALE_SIGN), # SLEUTH OR SPY |
| 517 | (0x1F645, FEMALE_SIGN), # FACE WITH NO GOOD GESTURE |
| 518 | (0x1F646, FEMALE_SIGN), # FACE WITH OK GESTURE |
| 519 | (0x1F647, MALE_SIGN), # PERSON BOWING DEEPLY |
| 520 | (0x1F64B, FEMALE_SIGN), # HAPPY PERSON RAISING ONE HAND |
| 521 | (0x1F64D, FEMALE_SIGN), # PERSON FROWNING |
| 522 | (0x1F64E, FEMALE_SIGN), # PERSON WITH POUTING FACE |
| 523 | (0x1F6A3, MALE_SIGN), # ROWBOAT |
| 524 | (0x1F6B4, MALE_SIGN), # BICYCLIST |
| 525 | (0x1F6B5, MALE_SIGN), # MOUNTAIN BICYCLIST |
| 526 | (0x1F6B6, MALE_SIGN), # PEDESTRIAN |
| 527 | (0x1F926, FEMALE_SIGN), # FACE PALM |
| 528 | (0x1F937, FEMALE_SIGN), # SHRUG |
| 529 | (0x1F938, MALE_SIGN), # PERSON DOING CARTWHEEL |
| 530 | (0x1F939, MALE_SIGN), # JUGGLING |
| 531 | (0x1F93C, MALE_SIGN), # WRESTLERS |
| 532 | (0x1F93D, MALE_SIGN), # WATER POLO |
| 533 | (0x1F93E, MALE_SIGN), # HANDBALL |
| 534 | (0x1F9D6, FEMALE_SIGN), # PERSON IN STEAMY ROOM |
| 535 | (0x1F9D7, FEMALE_SIGN), # PERSON CLIMBING |
| 536 | (0x1F9D8, FEMALE_SIGN), # PERSON IN LOTUS POSITION |
| 537 | (0x1F9D9, FEMALE_SIGN), # MAGE |
| 538 | (0x1F9DA, FEMALE_SIGN), # FAIRY |
| 539 | (0x1F9DB, FEMALE_SIGN), # VAMPIRE |
| 540 | (0x1F9DC, FEMALE_SIGN), # MERPERSON |
| 541 | (0x1F9DD, FEMALE_SIGN), # ELF |
| 542 | (0x1F9DE, FEMALE_SIGN), # GENIE |
| 543 | (0x1F9DF, FEMALE_SIGN), # ZOMBIE |
| 544 | ] |
Doug Felt | f874a19 | 2016-07-08 17:42:15 -0700 | [diff] [blame] | 545 | |
| 546 | def is_fitzpatrick_modifier(cp): |
Roozbeh Pournader | 3b3c78e | 2016-07-25 14:04:34 -0700 | [diff] [blame] | 547 | return 0x1F3FB <= cp <= 0x1F3FF |
| 548 | |
| 549 | |
| 550 | def reverse_emoji(seq): |
| 551 | rev = list(reversed(seq)) |
| 552 | # if there are fitzpatrick modifiers in the sequence, keep them after |
| 553 | # the emoji they modify |
| 554 | for i in xrange(1, len(rev)): |
| 555 | if is_fitzpatrick_modifier(rev[i-1]): |
| 556 | rev[i], rev[i-1] = rev[i-1], rev[i] |
| 557 | return tuple(rev) |
Doug Felt | f874a19 | 2016-07-08 17:42:15 -0700 | [diff] [blame] | 558 | |
| 559 | |
Roozbeh Pournader | 5dde087 | 2016-03-31 13:54:56 -0700 | [diff] [blame] | 560 | def compute_expected_emoji(): |
| 561 | equivalent_emoji = {} |
| 562 | sequence_pieces = set() |
| 563 | all_sequences = set() |
| 564 | all_sequences.update(_emoji_variation_sequences) |
| 565 | |
Raph Levien | 2b8b819 | 2016-08-09 14:28:54 -0700 | [diff] [blame] | 566 | # add zwj sequences not in the current emoji-zwj-sequences.txt |
| 567 | adjusted_emoji_zwj_sequences = dict(_emoji_zwj_sequences) |
| 568 | adjusted_emoji_zwj_sequences.update(_emoji_zwj_sequences) |
Raph Levien | 2b8b819 | 2016-08-09 14:28:54 -0700 | [diff] [blame] | 569 | |
Roozbeh Pournader | aa3ee8e | 2017-04-10 13:52:20 -0700 | [diff] [blame] | 570 | # Add empty flag tag sequence that is supported as fallback |
| 571 | _emoji_sequences[(0x1F3F4, 0xE007F)] = 'Emoji_Tag_Sequence' |
| 572 | |
Roozbeh Pournader | 5dde087 | 2016-03-31 13:54:56 -0700 | [diff] [blame] | 573 | for sequence in _emoji_sequences.keys(): |
| 574 | sequence = tuple(ch for ch in sequence if ch != EMOJI_VS) |
| 575 | all_sequences.add(sequence) |
| 576 | sequence_pieces.update(sequence) |
Roozbeh Pournader | aa3ee8e | 2017-04-10 13:52:20 -0700 | [diff] [blame] | 577 | if _emoji_sequences.get(sequence, None) == 'Emoji_Tag_Sequence': |
Roozbeh Pournader | 63d4d0d | 2017-05-18 18:38:36 -0700 | [diff] [blame] | 578 | # Add reverse of all emoji ZWJ sequences, which are added to the |
| 579 | # fonts as a workaround to get the sequences work in RTL text. |
Roozbeh Pournader | aa3ee8e | 2017-04-10 13:52:20 -0700 | [diff] [blame] | 580 | # TODO: test if these are actually needed by Minikin/HarfBuzz. |
| 581 | reversed_seq = reverse_emoji(sequence) |
| 582 | all_sequences.add(reversed_seq) |
| 583 | equivalent_emoji[reversed_seq] = sequence |
Roozbeh Pournader | 5dde087 | 2016-03-31 13:54:56 -0700 | [diff] [blame] | 584 | |
Raph Levien | 2b8b819 | 2016-08-09 14:28:54 -0700 | [diff] [blame] | 585 | for sequence in adjusted_emoji_zwj_sequences.keys(): |
Roozbeh Pournader | 5dde087 | 2016-03-31 13:54:56 -0700 | [diff] [blame] | 586 | sequence = tuple(ch for ch in sequence if ch != EMOJI_VS) |
| 587 | all_sequences.add(sequence) |
| 588 | sequence_pieces.update(sequence) |
| 589 | # Add reverse of all emoji ZWJ sequences, which are added to the fonts |
| 590 | # as a workaround to get the sequences work in RTL text. |
Roozbeh Pournader | 3b3c78e | 2016-07-25 14:04:34 -0700 | [diff] [blame] | 591 | reversed_seq = reverse_emoji(sequence) |
Roozbeh Pournader | 5dde087 | 2016-03-31 13:54:56 -0700 | [diff] [blame] | 592 | all_sequences.add(reversed_seq) |
| 593 | equivalent_emoji[reversed_seq] = sequence |
| 594 | |
Roozbeh Pournader | aa3ee8e | 2017-04-10 13:52:20 -0700 | [diff] [blame] | 595 | # Remove unsupported flags |
| 596 | all_sequences.difference_update(UNSUPPORTED_FLAGS) |
| 597 | |
| 598 | # Add all tag characters used in flags |
| 599 | sequence_pieces.update(range(0xE0030, 0xE0039 + 1)) |
| 600 | sequence_pieces.update(range(0xE0061, 0xE007A + 1)) |
Roozbeh Pournader | 5dde087 | 2016-03-31 13:54:56 -0700 | [diff] [blame] | 601 | |
| 602 | all_emoji = ( |
| 603 | _emoji_properties['Emoji'] | |
| 604 | all_sequences | |
| 605 | sequence_pieces | |
| 606 | set(LEGACY_ANDROID_EMOJI.keys())) |
| 607 | default_emoji = ( |
| 608 | _emoji_properties['Emoji_Presentation'] | |
| 609 | all_sequences | |
| 610 | set(LEGACY_ANDROID_EMOJI.keys())) |
| 611 | |
Roozbeh Pournader | 5dde087 | 2016-03-31 13:54:56 -0700 | [diff] [blame] | 612 | equivalent_emoji.update(EQUIVALENT_FLAGS) |
| 613 | equivalent_emoji.update(LEGACY_ANDROID_EMOJI) |
| 614 | equivalent_emoji.update(ZWJ_IDENTICALS) |
Roozbeh Pournader | aa3ee8e | 2017-04-10 13:52:20 -0700 | [diff] [blame] | 615 | |
| 616 | for ch, gender in GENDER_DEFAULTS: |
| 617 | equivalent_emoji[(ch, ZWJ, gender)] = ch |
| 618 | for skin_tone in range(0x1F3FB, 0x1F3FF+1): |
| 619 | skin_toned = (ch, skin_tone, ZWJ, gender) |
| 620 | if skin_toned in all_emoji: |
| 621 | equivalent_emoji[skin_toned] = (ch, skin_tone) |
| 622 | |
Roozbeh Pournader | 5dde087 | 2016-03-31 13:54:56 -0700 | [diff] [blame] | 623 | for seq in _emoji_variation_sequences: |
| 624 | equivalent_emoji[seq] = seq[0] |
| 625 | |
| 626 | return all_emoji, default_emoji, equivalent_emoji |
Roozbeh Pournader | fa1facc | 2016-03-16 13:53:47 -0700 | [diff] [blame] | 627 | |
| 628 | |
Roozbeh Pournader | bac1aec | 2016-07-27 13:08:37 -0700 | [diff] [blame] | 629 | def check_vertical_metrics(): |
| 630 | for record in _fallback_chain: |
| 631 | if record.name in ['sans-serif', 'sans-serif-condensed']: |
| 632 | font = open_font(record.font) |
Roozbeh Pournader | ede3a17 | 2016-07-27 16:35:12 -0700 | [diff] [blame] | 633 | assert font['head'].yMax == 2163 and font['head'].yMin == -555, ( |
Roozbeh Pournader | 63d4d0d | 2017-05-18 18:38:36 -0700 | [diff] [blame] | 634 | 'yMax and yMin of %s do not match expected values.' % ( |
| 635 | record.font,)) |
Roozbeh Pournader | ede3a17 | 2016-07-27 16:35:12 -0700 | [diff] [blame] | 636 | |
Roozbeh Pournader | 63d4d0d | 2017-05-18 18:38:36 -0700 | [diff] [blame] | 637 | if record.name in ['sans-serif', 'sans-serif-condensed', |
| 638 | 'serif', 'monospace']: |
Roozbeh Pournader | ede3a17 | 2016-07-27 16:35:12 -0700 | [diff] [blame] | 639 | font = open_font(record.font) |
Roozbeh Pournader | 63d4d0d | 2017-05-18 18:38:36 -0700 | [diff] [blame] | 640 | assert (font['hhea'].ascent == 1900 and |
| 641 | font['hhea'].descent == -500), ( |
| 642 | 'ascent and descent of %s do not match expected ' |
| 643 | 'values.' % (record.font,)) |
| 644 | |
| 645 | |
| 646 | def check_cjk_punctuation(): |
| 647 | cjk_scripts = {'Hans', 'Hant', 'Jpan', 'Kore'} |
| 648 | cjk_punctuation = range(0x3000, 0x301F + 1) |
| 649 | for record in _fallback_chain: |
| 650 | if record.scripts.intersection(cjk_scripts): |
| 651 | # CJK font seen. Stop checking the rest of the fonts. |
| 652 | break |
| 653 | assert_font_supports_none_of_chars(record.font, cjk_punctuation) |
Roozbeh Pournader | bac1aec | 2016-07-27 13:08:37 -0700 | [diff] [blame] | 654 | |
| 655 | |
Roozbeh Pournader | 0e969e2 | 2016-03-09 23:08:45 -0800 | [diff] [blame] | 656 | def main(): |
Roozbeh Pournader | 0e969e2 | 2016-03-09 23:08:45 -0800 | [diff] [blame] | 657 | global _fonts_dir |
Doug Felt | f874a19 | 2016-07-08 17:42:15 -0700 | [diff] [blame] | 658 | target_out = sys.argv[1] |
Roozbeh Pournader | 0e969e2 | 2016-03-09 23:08:45 -0800 | [diff] [blame] | 659 | _fonts_dir = path.join(target_out, 'fonts') |
| 660 | |
| 661 | fonts_xml_path = path.join(target_out, 'etc', 'fonts.xml') |
| 662 | parse_fonts_xml(fonts_xml_path) |
| 663 | |
Roozbeh Pournader | bac1aec | 2016-07-27 13:08:37 -0700 | [diff] [blame] | 664 | check_vertical_metrics() |
| 665 | |
Roozbeh Pournader | 0e969e2 | 2016-03-09 23:08:45 -0800 | [diff] [blame] | 666 | hyphens_dir = path.join(target_out, 'usr', 'hyphen-data') |
| 667 | check_hyphens(hyphens_dir) |
| 668 | |
Roozbeh Pournader | 63d4d0d | 2017-05-18 18:38:36 -0700 | [diff] [blame] | 669 | check_cjk_punctuation() |
| 670 | |
Roozbeh Pournader | 27ec3ac | 2016-03-31 13:05:32 -0700 | [diff] [blame] | 671 | check_emoji = sys.argv[2] |
| 672 | if check_emoji == 'true': |
| 673 | ucd_path = sys.argv[3] |
| 674 | parse_ucd(ucd_path) |
Roozbeh Pournader | 5dde087 | 2016-03-31 13:54:56 -0700 | [diff] [blame] | 675 | all_emoji, default_emoji, equivalent_emoji = compute_expected_emoji() |
| 676 | check_emoji_coverage(all_emoji, equivalent_emoji) |
| 677 | check_emoji_defaults(default_emoji) |
Roozbeh Pournader | fa1facc | 2016-03-16 13:53:47 -0700 | [diff] [blame] | 678 | |
Roozbeh Pournader | 0e969e2 | 2016-03-09 23:08:45 -0800 | [diff] [blame] | 679 | |
| 680 | if __name__ == '__main__': |
| 681 | main() |