joypixels / emojione

[Archived] The world's largest independent emoji font. Maintained at https://github.com/joypixels/emoji-toolkit.
https://www.joypixels.com
Other
4.46k stars 536 forks source link

ruleset.py created by create_ruleset.py doesn't include 'diversity' category #628

Open ogreverse opened 5 years ago

ogreverse commented 5 years ago

HI.

When I integrated new emojione into my project, I noticed that emojis related to the category of diversity were not displayed. Apparently there was a problem in create_ruleset.py and I fixed it like below.

    shortcode_replace[shortname] = unicode_hex
    category_replace[shortname] = value['category']

+   if value['diversity']:
+      category_replace[shortname] = 'diversity'
+
    if '-' not in unicode_hex:
        unicode_char = chr(int(unicode_hex, 16))
        unicode_replace[unicode_char.encode('utf-8')] = shortname

I'd like to get ruleset.py to be compatible with old emoji's shortnames besides. I added the codes like below.

        unicode_char = ''.join(chr(int(part, 16)) for part in parts)
        unicode_replace[unicode_char.encode('utf-8')] = shortname

+  if value['shortname_alternates']:
+      for shortname_alternate in value['shortname_alternates']:
+          shortcode_replace[shortname_alternate] = shortcode_replace[shortname]
+          category_replace[shortname_alternate] = category_replace[shortname]
+
print(unicode_replace)
print(shortcode_replace)
print(ascii_replace)