Full source code of the Emojis class
I took quite a bit of time to implement emojis for hostnames in Jimmy. These are displayed in bookmarks and in the tab for the current domain, because I think they brgin a bit of color, and also to facilitate immediate visual recognition of the domain you are on or are about to visit.
They work by taking a SHA256 hash of the domain name and extracting an emoji codepoint from that. At the start of the Emoji class, I have a list of utf8 character ranges that contain emojis, sorted by "most attractive" to "least attractive" (as judged by me). Here is that list:
private var codepoints = [ 0x1F300...0x1F5FF, // Misc Symbols and Pictographs 0x1F680...0x1F6FF, // Transport and Map 0x1F600...0x1F64F, // Emoticons 0x1F1E6...0x1F1FF, // Regional country flags 0x2600...0x26FF, // Misc symbols 9728 - 9983 0x2700...0x27BF, // Dingbats 0x1F900...0x1F9FF, // Supplemental Symbols and Pictographs 129280 - 129535 65024...65039, // Variation selector 9100...9300, // Misc items ]
I then calculate the SHA256 hash of the hostname and convert it to a hex string, the first 8 characters of which are kept to generate the emoji with.
for each codepoint range, I then convert that hex string to a number modulo the number of codepoints in the range, to be able to get a single emoji codepoint corresponding to the generated hash. The code then checks if that emoji codepoint actually exists on macOs by generating a png from a known existing emoji and from the one that we are trying to generate. If the two are the same size, it means the emoji was sucessfully generated from that codepoint, and from now on it will be the emoji for that domain name.
If the emoji was not correctly generated however, it means in does not exist in Apple's font, and we try again with the next codepoint.
Hopefully an existing emoji will be found before we reach the end of the codepoints, but if not the ❓ emoji is returned.
Was this class does not do at the moment, but definitely should, is cache the emoji for each hostname, to that this whole rigmarole need not be run each time the interface requests an emoji for a domain.
If you're interested, you can find the full source code for the Emoji class at the link below:
Also, I just discovered this proposal to add favicons to Gemini, which probably makes my implementation useless and / or annoying for those that chose to add a favicon to their capsule...