Comments (5)
Ok I deleted my previous comment talking about trial-and-error since I found the spec. In particular, it says:
an emoji modifier must immediately follow [the] base emoji character
and
Emoji presentation selectors are neither needed nor recommended for emoji characters when they are followed by emoji modifiers, and should not be used in newly generated emoji modifier sequences; the emoji modifier automatically implies the emoji presentation style.
I think that suggests processing emojis like this. You're welcome to adopt that implementation for this library if you like, tried to heavily comment and test it both from the perspective of "does this format correctly" and "does this render correctly (on Apple platforms, at least)".
One note about non-Swift implementations is that you'll probably need to look up the scalar (codepoint) properties (isVariationSelector
, isEmojiModifier
, isEmojiModifierBase
) from an external lookup table. I'm pretty sure that unicode.org provides such and I believe that this library already parses some of them.
from gemoji.
The Gist linked from my previous comment doesn't support applying different modifiers to each person in a multi-person grouping. I'm currently adding support for that and will probably publish the result as a Swift package rather than continue to add to the Gist.
In the meantime, I'd like to call out a limitation of the algorithm in the Gist: it won't work for 👭, 👫, and 👬. That's because those emojis consist of a single scalar, whereas applying different modifiers to each person in the grouping would require representing the groupings as a ZWJ sequence. This means that we have to convert those emojis into a sequence before applying the algorithm:
extension String {
var modifiableBySkinTone: String {
switch self {
case "👭": return "\u{0001F469}\u{200D}\u{0001F91D}\u{200D}\u{0001F469}"
case "👫": return "\u{0001F469}\u{200D}\u{0001F91D}\u{200D}\u{0001F468}"
case "👬": return "\u{0001F468}\u{200D}\u{0001F91D}\u{200D}\u{0001F468}"
default: return self
}
}
}
I hoped to submit some sort of PR to add these "sequence forms" to this project's database, the idea being that a capable platform¹ could only ever store and display those versions of 👭, 👫, and 👬 and so avoid having to convert the single-scalar versions in the process of applying skin tones.
Unfortunately, these sequences only render as single characters when they contain modifiers, at least on macOS 10.15.4. Apple probably didn't bother adding code to make the base sequences render given that they can display the single-scalar versions instead.
¹Supporting Emoji 12.0, which I think is when the sequence forms were added, per the spec—whereas the single-scalar emoji date back to Emoji 6.0, says the database.
from gemoji.
Two more gotchas I've found:
Firstly, the basic algorithm may return results that won't actually render in cases where platforms haven't generally added support for rendering all the different variants. I'm specifically talking about many of the multi-person groupings. In these cases, the database correctly omits skin_tones
and so the fix is to simply skip trying to modify such emoji.
More problematic is that skin_tones
may be true
in cases where only some platforms will render the different variants. This is because "in some circumstances, display of an emoji modifier… should be suppressed", per the spec. As an example, Apple depicts 🏂 without any visible skin whereas Android shows skin. This means that my Swift implementation (for use in iOS) should return no variants for 🏂 whereas implementations for other platforms would need to behave differently.
from gemoji.
Thanks for sharing your finding so far!
I am unable to provide advice on how to implement support for skin tone modifiers on top of gemoji since I've never done it. The library does report which emoji supports skin tone modifiers, but intentionally does not yet provide any facilities to generate or parse emoji with skin tones because we haven't figured out proper support for this yet, so the implementation is left to the users.
from gemoji.
With #165 merged, you can now call the raw_skin_tone_variants
method on an emoji character to get a set of 5 unicode sequences that have each of the skin tone modifiers inserted at the right place.
from gemoji.
Related Issues (20)
- Suggestions for where to get emoji images? HOT 6
- Choose wether to type out emojis with an underscore or with a space HOT 2
- Df HOT 1
- Release v4 HOT 5
- Import Emoji 14.0 HOT 2
- Import Emoji 15.0 HOT 9
- Cypher rat HOT 2
- amor
- Beginless Ranges are not supported in ruby '<2.7' HOT 3
- Skin tones in GitHub flavored markdown HOT 1
- Add an 'Accessibility' icon that can be used in Discussions HOT 1
- Emoji-quantum-computers HOT 5
- Laura wins, croft money!
- thenounproject is a great source of free icons
- Suggestion for finding reliable sources to emoji's Spanish aliases and tags HOT 1
- I don’t know what I’m doing yet
- TNj@[email protected]
- THINGS TO KNOW WHILE INSTALLING ROOF HOT 1
- JADITA BETA_APP HOT 1
- If you want something with a [commercial license](https://github.com/twitter/twemoji-parser/blob/master/LICENSE.md), I think https://github.com/twitter/twemoji works. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gemoji.