Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flag icons are broken #14

Open
gornostal opened this issue Oct 3, 2020 · 21 comments
Open

Flag icons are broken #14

gornostal opened this issue Oct 3, 2020 · 21 comments

Comments

@gornostal
Copy link
Member

gornostal commented Oct 3, 2020

image
Although flag emojies are copied correctly to the clipboard


The issue occurs with noto and blobs theme
👉 Workaround: Select a fallback theme different from noto and blobs

@gornostal
Copy link
Member Author

@MyriaCore Any ideas where to look for a cause of this bug?

@MyriaCore
Copy link
Contributor

Sorry for late reply. I'll start digging around

@gornostal
Copy link
Member Author

gornostal commented Oct 12, 2020

No worries! And thanks for looking!

@MyriaCore
Copy link
Contributor

image
mine works, weird. I've done a ton of weird hacks to my stuff since tho, might have been something I changed. What emoji pack are u using?

@MyriaCore
Copy link
Contributor

It appears to only affect noto and blobs:

With noto:

image

With blobs:

image

With apple:

image

@gornostal
Copy link
Member Author

noto

After merging I did some minor refactoring, but I also tested tested with the version from your branch and I saw the same issue there.

@gornostal
Copy link
Member Author

It appears to only affect noto and blobs:

Indeed.

@MyriaCore
Copy link
Contributor

image

The icon entries for most of these flags are null in blobmoji / noto. Maybe a codepoint mismatch?

@gornostal
Copy link
Member Author

Aah.. I had noto as a fallback theme too.
Changing it helped.

So I guess it's not a bug then. I'm going to close it

@gornostal
Copy link
Member Author

Or you think it is a bug and the flags should be there with noto?

@MyriaCore
Copy link
Contributor

Yeah, I think so. I don't think these flags are new, so it's probably not an emoji 13 thing, right? AFAIK noto and blob should support full emoji 11 (or maybe 12).

@gornostal
Copy link
Member Author

I think I agree.
I also think that at this point you know much more about emojies than I do, so I'll trust your opinion.
I haven't heard about noto or other emoji packs before your PR 😀

@MyriaCore
Copy link
Contributor

MyriaCore commented Oct 12, 2020

This is the unicode.org listing for the lithuania flag. The listed codepoint is U+1F1F1 U+1F1F9.

Here's the function where we generate the URL to get the image:

def codepoint_to_url(codepoint, style):
"""
Given an emoji's codepoint (e.g. 'U+FE0E') and a non-apple emoji style,
returns a url to to the png image of the emoji in that style.
Only works for style = 'twemoji', 'noto', and 'blobmoji'.
"""
base = codepoint.replace('U+', '').lower()
if style == 'twemoji':
# See discussion in commit 8115b76 for more information about
# why the base needs to be patched like this.
patched = re.sub(r'0*([1-9a-f][0-9a-f]*)', lambda m: m.group(1),
base.replace(' ', '-').replace('fe0f-20e3', '20e3').replace('1f441-fe0f-200d-1f5e8-fe0f', '1f441-200d-1f5e8'))
response = requests.get('https://github.com/twitter/twemoji/raw/gh-pages/v/latest')
version = response.text if response.ok else None
if version:
return 'https://github.com/twitter/twemoji/raw/gh-pages/v/%s/72x72/%s.png' \
% (version, patched)
else:
return 'https://github.com/twitter/twemoji/raw/master/assets/72x72/%s.png' \
% patched
elif style == 'noto':
return 'https://github.com/googlefonts/noto-emoji/raw/master/png/128/emoji_u%s.png' \
% base.replace(' ', '_')
elif style == 'blobmoji':
return 'https://github.com/C1710/blobmoji/raw/master/png/128/emoji_u%s.png' \
% base.replace(' ', '_')

base for this codepoint should be "1f1f1-1f1f9", so it probably attempts to retrieve the URL here, which 404's.

@gornostal
Copy link
Member Author

ah.. I see

@MyriaCore
Copy link
Contributor

$ python -c 'print("🇱🇹".encode("unicode-escape"))'
b'\\U0001f1f1\\U0001f1f9'

So the codepoint seems correct. Maybe there's some schema that noto and blob is using that I didn't properly enforce.

@MyriaCore
Copy link
Contributor

MyriaCore commented Oct 12, 2020

After looking at the makefile for the blobmoji project, I've determined that the schema for the flags is actually :

  • https://github.com/C1710/blobmoji/raw/master/third_party/region-flags/png/%s.png

... where %s is the BCP 47 country/region/subregion code. See the readme for the region-flags dir.

@MyriaCore
Copy link
Contributor

MyriaCore commented Oct 12, 2020

Also in the readme for blobmoji:

Also note that the images in the font might differ from the original assets. In particular the flag images in the font are PNG images to which transforms have been applied to standardize the size and generate the wave and border shadow. We do not have SVG versions that reflect these transforms.

This explains why the flags are so detailed, and why they don't appear to have other non-country flags (like the trans flag or the pirate flag)

@MyriaCore
Copy link
Contributor

There's a similar passage in the readme for noto emoji. This is kinda worrying.

@gornostal the way I see it, we have 3 options:

  1. Close the issue and cry. It looks like it'd be pretty difficult to add support for these emojis from this data source.
  2. Try to see if their makefile can be modified to maintain these transformations in image form.
  3. Find a different datasource for the noto and blob emoji set, like emojipedia. Related: EmojiSpider.py Refactor #15

@MyriaCore
Copy link
Contributor

MyriaCore commented Oct 12, 2020

Wait NVM, I'm super wrong I think. I think that the flags are turned into emojis, since there's an unknown_flag_aliases file.

@MyriaCore
Copy link
Contributor

It looks like the make the name for the flag emojis here. The names are reformatted in 04x hex.

Not sure why the normal URL of just:

https://github.com/C1710/blobmoji/raw/master/png/128/emoji_u1f1f1_1f1f9.png

doesn't work then.

@gornostal
Copy link
Member Author

I think it's fine because there's a fallback theme. If it's set correctly the issue is gone.
Thanks a lot for looking into this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants