Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Color for Unicode Emoji

It's possible to include Emoji characters in modern browsers, but how can one make it a single color and choose that color?

For example, here is some Emoji and some regular (plane 0) Unicode symbols. All should be red, but only the symbols are rendered in red.

Emoji color attempt

Associated HTML + CSS:

<p>   🐘🐧🐼 </p> <p>   β™₯β˜…β„Ή </div>  p {   font-size: 3em;   color: red } 
like image 297
mahemoff Avatar asked Sep 05 '15 13:09

mahemoff


People also ask

Does Unicode include emoji?

The emoji are spread throughout many blocks of Unicode. See Unicode Emoji Charts for a listing of the emoji characters.

Does UTF-8 include emoji?

Emojis look like images, or icons, but they are not. They are letters (characters) from the UTF-8 (Unicode) character set.


2 Answers

Yes, you can color them!

div {    color: transparent;      text-shadow: 0 0 0 red;  }
<div>πŸš€πŸŽ­πŸ˜»</div>
like image 57
Tigran Avatar answered Oct 21 '22 08:10

Tigran


Not every emoji works the same. Some are old textual symbols that now have an (optional or default) colorful representation, others were explicitly (only) as emojis. That means, some Unicode codepoints should have two possible representations, text and emoji. Authors and users should be able to express their preference for one or the other. This is currently done with otherwise invisible variation selectors U+FE0E (text, VS-15) and U+FE0F (emoji, VS-16), but higher-level solutions (e.g. for CSS) have been proposed.

The text-style emojis are monochromatic and should be displayed in the foreground color, i.e. currentcolor in CSS, just like any other glyph. The Unicode Consortium provides an overview of emojis by style (beta version). You should be able to append &#xFE0E; in HTML to select the textual variant with anything in the columns labeled β€œDefault Text Style; has VSs” and β€œDefault Emoji Style; has VSs”. This doesn’t include the example emojis 🐘🐧🐼 and many others, though.

p {    color: red; font-size: 3em; margin: 0;    text-transform: text;           /* proposed */    font-variant-emoji: text;       /* proposed */    font-variant-color: monochrome; /* proposed */    font-color: monochrome;         /* proposed */    font-palette: dark;             /* drafted for CSS Fonts Level 4 */  }  p.hack {    color: rgba(100%, 0%, 0%, 0);    text-shadow: 0 0 0 red;  }  p.font {    font-family: Emojione, Noto, Twemoji, Symbola;  }  @font-face { /* http://emojione.com/developers/ */    font-family: Emojione;    src: local("EmojiOne BW"), local("EmojiOne"), local("Emoji One"),          /*   https://cdn.rawgit.com/Ranks/emojione/master/assets/fonts/emojione-bw.otf – monochrome only, deprecated, removed              https://cdn.rawgit.com/Ranks/emojione/master/assets/fonts/emojione-android.ttf – with hack              https://cdn.rawgit.com/Ranks/emojione/master/assets/fonts/emojione-apple.ttf – with hack */         url("https://cdn.rawgit.com/Ranks/emojione/master/assets/fonts/emojione-svg.woff2") format("woff2"),         url("https://cdn.rawgit.com/Ranks/emojione/master/assets/fonts/emojione-svg.woff") format("woff"),         url("https://cdn.rawgit.com/Ranks/emojione/master/assets/fonts/emojione-svg.otf") format("truetype");  }  @font-face { /* https://www.google.com/get/noto/#noto-emoji-zsye */    font-family: Noto;    src: local("Noto Emoji"), local("Noto Color Emoji"), local("Noto"),          url("https://cdn.rawgit.com/googlei18n/noto-emoji/master/fonts/NotoEmoji-Regular.ttf");  }  @font-face { /* https://github.com/eosrei/twemoji-color-font/releases */    font-family: Twemoji;    src: local("Twemoji");  }  @font-face { /* http://users.teilar.gr/~g1951d/ */    font-family: Symbola;    src: local("Symbola");  }
<p title="🐘🐧🐼β™₯β˜…β„ΉπŸ’€πŸ‘Œ without variation selectors">&#x1F418; &#x1F427; &#x1F43C; &#x2665; &#x2605; &#x2139; &#x1F480; &#x1F44C;</p>  <p title="🐘🐧🐼β™₯β˜…β„ΉπŸ’€πŸ‘Œ with text variation selector 15">&#x1F418;&#xFE0E; &#x1F427;&#xFE0E; &#x1F43C;&#xFE0E; &#x2665;&#xFE0E; &#x2605;&#xFE0E; &#x2139;&#xFE0E; &#x1F480;&#xFE0E; &#x1F44C;&#xFE0E;</p>  <p title="🐘🐧🐼β™₯β˜…β„ΉπŸ’€πŸ‘Œ with emoji variation selector 16">&#x1F418;&#xFE0F; &#x1F427;&#xFE0F; &#x1F43C;&#xFE0F; &#x2665;&#xFE0F; &#x2605;&#xFE0F; &#x2139;&#xFE0F; &#x1F480;&#xFE0F; &#x1F44C;&#xFE0F;</p>  <p title="🐘🐧🐼β™₯β˜…β„ΉπŸ’€πŸ‘Œ with `text-shadow` hack" class="hack">&#x1F418; &#x1F427; &#x1F43C; &#x2665; &#x2605; &#x2139; &#x1F480; &#x1F44C;</p>  <p title="🐘🐧🐼β™₯β˜…β„ΉπŸ’€πŸ‘Œ with custom font" class="font">&#x1F418; &#x1F427; &#x1F43C; &#x2665; &#x2605; &#x2139; &#x1F480; &#x1F44C;</p>

I’ve added πŸ’€ U+1F480 Skull and πŸ‘Œ U+1F44C OK Hand Sign because the background should show through their β€œeyes” and I’ve used numeric character references just to make the code more obvious and more robust against copy-and-paste errors.

It has been proposed, however, that both variation selectors can be applied to any character, which would have no effect in most cases. Note that some vendors, especially Samsung, are already shipping (default) emoji glyphs for several other characters (goo.gl/a4yK6p or goo.gl/DqtHcc).

like image 31
Crissov Avatar answered Oct 21 '22 06:10

Crissov