{"id":270743,"date":"2018-05-15T07:02:37","date_gmt":"2018-05-15T14:02:37","guid":{"rendered":"http:\/\/css-tricks.com\/?p=270743"},"modified":"2018-05-15T07:02:37","modified_gmt":"2018-05-15T14:02:37","slug":"it-all-started-with-emoji-color-typography-on-the-web","status":"publish","type":"post","link":"https:\/\/css-tricks.com\/it-all-started-with-emoji-color-typography-on-the-web\/","title":{"rendered":"It All Started With Emoji: Color Typography on the Web"},"content":{"rendered":"
\n\u201cTypography on the web is in single color: characters are either black or red, never black and red \u2026Then emoji hit the scene, became part of Unicode, and therefore could be expressed by characters — or \u201cglyphs\u201d in font terminology. The smiley, levitating businessman and the infamous pile of poo became true siblings to letters, numbers and punctuation marks.\u201d<\/p>\n
— Roel Nieskens<\/a><\/p>\n<\/blockquote>\n
Using emojis in code is easy<\/em>. Head over to emojipedia<\/a> and copy and paste one in.<\/p>\n
<\/p>\n
In HTML: <\/p>\n
<\/figure>\nOr in CSS:<\/p>\n
<\/figure>\nAnd JavaScript, too:<\/p>\n
<\/figure>\n(Alternatively, you can specify emoji with a Unicode codepoint.) <\/p>\n
However, you might run into a problem…<\/p>\n
Lost in translation: Emoji\u2019s consistency problem<\/h3>\n
The diversity of emoji across platforms might not sound like a major problem. However, these sometimes radical<\/em> inconsistencies leave room for drastic miscommunication. Infamously, the \u201cgrinning face with smiling eyes\u201d emoji ends up as a pained grimace on older Apple systems. <\/p>\n
This was such a big deal that even The Washington Post covered it.<\/figcaption><\/figure>\n A harmless and playful watergun emoji might show up as a deadly firearm. <\/p>\n
Courtesy of Emojipedia.<\/a><\/figcaption><\/figure>\n And who knows how many romances were dashed by Google\u2019s utterly bizarre hairy heart<\/em> emoji?<\/p>\n
🤮This has since been rectified by Google<\/figcaption><\/figure>\n Unicode standardizes what each emoji should represent with a terse description but the visual design is down to the various platforms. <\/p>\n
Color fonts to the rescue!<\/h3>\n
The solution? Use an emoji font.<\/em> Adobe has released a font called EmojiOne<\/a><\/em> and Twitter open-sourced Twemoji<\/a>. More are likely to follow.<\/p>\n
@font-face {\r\n font-family: 'emoji';\r\n src: url('emojione-svg.woff2')\r\n format('woff2');\r\n}<\/code><\/pre>\n
If a user types into an HTML
input<\/code> or
textarea<\/code>, they will see your fancy custom emoji. ❤️ <\/p>\n
An input in Firefox.<\/figcaption><\/figure>\n Emoji fonts also have the benefit of avoiding the pixelation seen in scaled-up raster emoji. If you happen to want really large<\/em> emoji, an SVG-in-Opentype font is clearly the superior choice.<\/p>\n
On the left, a standard Apple dogface emoji looking pixelated. On the right, smooth SVG-in-Opentype emoji characters from Emojione and Twemoji, respectively. Unicode (right) clearly doesn\u2019t specify a breed!<\/figcaption><\/figure>\n Browser support<\/h3>\n
Confusingly, color fonts aren\u2019t one standard but rather four<\/em> 🙄. OpenType is the font format used on the web. When emoji were added to unicode, the big players realized that multi-color support needed to be added to OpenType in some way. Different companies came up with a diversity of solutions. The fonts are still .ttf, .woff or .woff2 — but internally they\u2019re a bit different. I pieced together this support table using a tool called Chromacheck<\/a>: <\/p>\n
\n
\n <\/td>\n Chrome<\/th>\n Safari<\/th>\n Edge<\/th>\n Firefox<\/th>\n<\/tr>\n \n SVG-in-Opentype<\/th>\n ❌<\/td>\n ❌<\/td>\n ✅<\/td>\n ✅<\/td>\n<\/tr>\n \n COLR\/CPAL<\/th>\n ✅<\/td>\n ✅<\/td>\n ✅<\/td>\n ✅<\/td>\n<\/tr>\n \n SBIX<\/th>\n ✅<\/td>\n ✅<\/td>\n ✅<\/td>\n ❌<\/td>\n<\/tr>\n \n CBDT\/CBLC<\/th>\n ✅<\/td>\n ❌<\/td>\n ✅<\/td>\n ❌<\/td>\n<\/tr>\n<\/table>\n We\u2019ve learned why<\/em> color fonts were invented. But it\u2019s not all<\/em> about emoji…<\/p>\n
Multicoloured alphabets<\/h3>\n