-
Notifications
You must be signed in to change notification settings - Fork 707
[css-fonts][css-text] Variation Selection of Colorful (Emoji) or Monochrome Glyphs #352
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
Comments
To clarify the interaction of these properties, can you confirm whether these are the intended outcome of the following combinations?
If I've got that all correct, my remaining questions are:
|
Both of the vector-format chromatic font options in OpenType v.3 use palettes, via the CPAL table, so a way to override these from CSS is needed. Putting this in an at-rule allows the same font to be used with different palettes at the same time. |
Oh, I only checked css-fonts-3 briefly and thus missed that Nevertheless, my point regarding
|
Just a quick comment on the `text-transform` aspect... If we decide to handle this by manipulating variant selectors, then I
think this should be handled as a separate `text-variant` property, and not mixed up with what, to an author, is more clearly
a text transformation.
~fantasai
|
I'm confused what this thread is talking about. It looks like the first comment was about choosing emoji/text representation, the same functionality as VS15/VS16. But then other people are talking about changing color palette only for Emoji fonts. Which are we talking about? Either way, this is about font selection and rendering, they should be font-, not in text-. |
This issue is about both features and how to distinguish them, @kojiishi.
Controlling the font palette of multi-color fonts belongs in css-fonts, on the other hand, maybe with considerations in css-color. The features interact insofar that requesting a monochrome palette is often almost the same as transforming all emojis to |
The two features aren't really connected in any meaningful way, except weakly by metaphor. Emoji switching is changing the entire glyph used to render the codepoint; multicolor fonts just let you specify the color palette directly. In particular, rendering a multicolor font with monochrome is the default - if you don't invoke the Since the OP was about emoji transformation, let's stick with that topic. You can split off a separate font palette discussion to another issue. |
That isn't what is currently implemented. Does something in the spec say this? |
There is a related question on Stack Overflow. The answers suggest some shadow hacks to get monochrome or outlined emoji glyphs. |
The lack of being able to enforce monochrome glyphs instead of colorful emojis is an important reason for symbol fonts to use PUA code points, which leads to a11y problems, e.g. FortAwesome/Font-Awesome#222. |
I'd like to echo Chris's question - on iOS and macOS we have different defaults. I believe that according to Unicode this is allowed; if this behavior doesn't follow web content specs I'd love to hear about it. |
For triggering emoji presentation style (often triggered by variation selectors), UTR51 explicitly states "Some systems may also provide this distinction with higher-level markup, rather than variation sequences." Therefore, the This behavior is implemented by the 'cmap' table in the font. That is, drawing the string U+2603 U+FE0E in a font may actually end up drawing a different glyph ID than if you drew the string U+2603 U+FE0F using the same font. This has particular implications for font fallback - the strings above may map to glyph ID 0, which means that a fallback font may be chosen. This affects layout because the fallback font may have different metrics than the requested font. On the other hand, color palettes are implemented after glyph selection, meaning they have no effect on font fallback. Palette selection describes how to draw a glyph once you already have a glyph ID in hand. Importantly, it also can't change the metrics of the glyph, meaning it doesn't affect layout. Because of this, the two concepts should be kept separate, and should be triggered with orthogonal properties. Telling a font to draw with a text presentation while also specifying a color palette should be legal and valid. (Perhaps most fonts won't react to the color palette in this situation, but it's totally possible to build a font which would.) |
Another note: WebKit has the concept of a "fast" text code path and a "complex" text code path. Variation selectors trigger the complex text code path (but regular emoji don't). Therefore, if we implemented this property by adding variation selector code points to every emoji, it would likely have some performance impact. Therefore, the "text-transform" model is inaccurate. |
Since I’ve missed it before myself, please note that UTR51 already specifies a higher-level method to express the author’s preferred style of emoji-enabled code points, using BCP47 hence
<html lang="en-Latn-u-em-default" /> <!-- default style, either colorful emoji or monochrome text --> :lang(*-u-em-text) {text-transform-variation: text;} /* text style */
[lang*="u-em-emoji"] {text-transform-variation: emoji;} /* emoji style */
:script(Zsym) {font-script-overwrite: "Zsye"} /* ISO 15924 alpha-4 script tags,
hypothetic selector and property */ I don’t think any browser honors such language codes yet. |
This is a perversion of the lang attribute. |
That’s why it should be handled by and in CSS. |
The fonts.xml in Android has: <family lang="und-Zsye">
<font weight="400" style="normal">NotoColorEmoji.ttf</font>
</family> So any apps running on recent Android will get the behavior. |
So, it seems that we've settled on:
I propose a new property, which is allowed to affect font fallback (see #854 (comment)):
This property behaves as if the appropriate variation selector is specified on all the characters which accept them (as defined by Unicode), but only if the character doesn't already have a variation selector. |
How would this affect the actual choice of font? I.e., whether to use the font-family stack, or whether to bypass it and grab a system emoji font? One way to retro-actively describe the current behavior, while still allowing authors to specify alternative emoji fonts (full or mono-color) would be:
That said, if these are the rules, I think full-color/monochrome might be better keywords than text/emoji. Also: If there are Unicode variation selector characters in the text, should they over-ride the |
@litherum If I understand the UTC correctly, they consider the VS solution a clutch and would like higher-level protocols (like CSS or font features) to take precedence. Richard Ishida @r12a is W3C’s (i18n) liaison contact for Unicode – I didn’t find anyone else to ping at Github (e.g. Addison Philips, Unicode’s Rick McGowan or Mark Davis, Apple’s Peter Edberg, except for Google’s Markus Scherer @markusicu) who may know better [whom to ask]. @AmeliaBR With your proposed wording, I’m not sure about this, but maybe another preference should be covered by the respective property as well: bitmap versus vector glyphs. As you may know, Apple and Google are currently using PNG-based emojis, whereas Microsoft, Mozilla and Adobe (and W3C) back vector-based solutions. Opentype 1.8 standardizes all of them. (Usually, only the vector formats could interact well with |
Right now, browsers don't have agreement about how exactly variation selectors interact with font selection (See #854). Apple platforms have particular behavior which it would be valuable to emulate in Apple browsers. I don't know about other platforms' / browsers' algorithms. Until that issue has an agreement on how variation selectors work, we shouldn't specify exactly how this property, and therefore variation selectors, work with relation to font fallback. Instead, we should only say that it can affect font fallback.
CSS operates on elements, which hold sequences of code points in them. Variation selector code points modify a specific code point in the sequence. Because variation selectors are specific to a particular code point inside the text node, variation selectors should have a higher precedence than the CSS applied on the entire element. The CSS property should set a default which individual characters can opt-out of. (The only alternative would be for the web author to have to create around individual character clusters just to set the presentation style, which no author wants to do) |
This decision is traditionally made inside the font file. If the web author wants to use a bitmap glyph as opposed to a vector glyph, the web author should just set a different font on the element. |
RESOLVED (3/8/17): add font-presentation to the spec and have it affect font fallback. |
That's a good point. So the
I really don't like the idea of creating a new property that affects a browser behavior without specifying how it does so. That's a recipe for incompatible implementations. |
Glad to see the resolution to move ahead. Looking forward to a draft spec text to analyze. I'm still not sure if Myles' proposal covers all of the use cases I see. As an author, I want:
|
A related issue is whether specifying fill/stroke for text should override full-color emoji substitutions. Browsers are inconsistent with SVG text; I haven't tested, but I suspect the same is true with the As I've argued elsewhere, extending That painted-vs-monochrome switch would make sense integrated into the emoji-vs-monochrome switch, so the options would be:
A user agent style rule would set The definition of "emoji characters" for |
It will be specified: the rendering should match as if the appropriate variation selector was appended to every relevant character.
You definitely can do this by putting your own fonts inside
That's what this new property does.
That's also what this new property does (unless I'm misunderstanding you).
This is false on macOS. The default there is text-style. |
http://unicodesnowmanforyou.com shows a code point which can accept variation selectors, but doesn't have an accompanying variation selector. You can use it to see what the default is on your system. EDIT: Looks like Windows doesn't have a font which can draw the snowman in emoji style, so this test doesn't seem to work there. It definitely works on macOS and iOS though. The default on macOS is text-style and the default on iOS is emoji-style. I don't know about Linux. |
When I mentioned the "current default", I was referring to the characters that Unicode calls "default emoji presentation characters". The only browser/OS combinations I tried that applied emoji-style to Unicode snowman (U+2603, a "default text presentation character" in the Unicode emoji data), in the absence of a variation selector codepoint, was Mobile Safari 10. Mobile Safari 9 uses text presentation. Given that this is contrary to Unicode recommendations, I think it's safe to call that a bug in that one browser, and not be worried about maintaining compatibility with something that isn't web-compatible anyway. |
This is why the default for this property is |
One person's bug is another person's feature! Sorry for sounding so antagonistic there.
I'm not sure that's currently true everywhere. It didn't used to be true on Chrome on Windows, although I tested & it is true now on Win 10, anyway. Probably related to using the system font as their Emoji font, instead of subbing their own bitmaps. But while testing that, I also confirmed that all three major browsers on Windows 10 currently will use any emoji font you specify in the font stack, even if it's monochrome. So my tentative definition of Which is one more factor to convince me that I'm more concerned about having clear definitions for the other options, so that authors can reliably control the behavior if it is important. An explicit color/emoji option, to search the stack or system fallback fonts for a color glyph before falling back to monochrome, and an explicit monochrome/text option, to do the same search looking for monochrome. (And possibly, a fill/stroke option, to look for a monochrome glyph and then paint it with fill & stroke instead of solid color. But that could be added by the proposed Paint spec, if it is determined to be useful.) |
I've just added a bunch of prose to the css-fonts-4 spec which should give us a baseline place to start discussions. Because this issue is for the basic feature, I'll close this issue and let people open up new issues with the new prose as they see fit. Thanks everyone for helping out making this a reality! |
In Firefox on Windows 10 I see a monochrome snowman, and dev tools tells me it is using Segoe UI Symbol. Same for Chrome and Edge. |
For the record, I've asked the editors of UTR/UTS 51. They believe that CSS should offer 5 states governing characters with the
I believe Twitter's website (and many others) enforces an Note that the list above does not include a possible 6th state which would comply with |
In late March, on www-style, Addison Philips posted a request on behalf of W3C’s I18N WG to be able to control the style of emoji characters via CSS. There were links to the relevant I18N minutes and Unicode minutes as well as the reference document UTR51.
The issue had been brought up in 2014 already, but I cannot find a WG conclusion on it. It has been suggested to be handled by
font-variant-color
(John Dagget),font-variant-emoji
(Xidorn Quan @upsuper), “something more generic” or@font-palette
(Cameron McCormack @heycam) or “a new property” (Amelia Bellamy Royds @AmeliaBR).I agree with some of the concerns that this is not an issue appropriate to be handled by
font-variant-*
, not just because there’s no corresponding Open Type feature. I was about to propose the selection being part oftext-transform
, but I then realized that this would only be reasonable to override or synthesize variation selectors (U+FE0E = VS-15 ‘text’, U+FE0F = VS-16 ‘emoji’). UTR51 wants VSs to take precedence over normal styling, though. I suggest we add both capabilities!Bikeshedding welcome.
The text was updated successfully, but these errors were encountered: