Skip to content

Commit b7049bc

Browse files
committed
[css-conditional-4] add color font example and warning counter-example
1 parent c18b272 commit b7049bc

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

css-conditional-4/Overview.bs

+57
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,62 @@ An ''@else'' rule that is not part of a <a>conditional rule chain</a> is invalid
240240
the example would get <em>significantly</em> worse.
241241
</div>
242242

243+
<div class="example">
244+
In this example, three different color font technologies
245+
are tested, in order of preference,
246+
plus a monochrome fallback.
247+
The most capable, COLRv1, supports both gradients and font variations;
248+
the next best choice, SVG, supports gradients
249+
while the least capable, COLRv0, supports flat color fill only.
250+
251+
The fallback has no test condition,
252+
so will always be chosen unless one of the earlier conditions succeeds.
253+
254+
<pre class="lang-css">
255+
@if font-technology(color-COLRv1) and font-technology(variations) {
256+
@font-face { font-family: icons; src: url(icons-gradient-var.woff2); }
257+
}
258+
@else font-technology(color-SVG) {
259+
@font-face { font-family: icons; src: url(icons-gradient.woff2); }
260+
}
261+
@else font-technology(color-COLRv0) {
262+
@font-face { font-family: icons; src: url(icons-flat.woff2); }
263+
}
264+
@else {
265+
@font-face { font-family: icons; src: url(icons-fallback.woff2); }
266+
}
267+
</pre>
268+
269+
Notice that in this example,
270+
the variable color font is only downloaded
271+
if COLRv1 is supported
272+
and font variations are also supported.
273+
274+
Notice too that only one of the available options will be downloaded;
275+
this would not be the case without @if and @else,
276+
as the next example shows.
277+
</div>
278+
279+
<div class="example">
280+
In this example,
281+
although it appears that the fallback will not be used
282+
if COLRv1 is supported,
283+
in fact both fonts will be downloaded,
284+
which wastes bandwidth if it is not used.
285+
286+
The fallback might still be used for some characters;
287+
for example, if the color font supports only Latin,
288+
while the fallback supports Latin and Greek.
289+
290+
<pre class="lang-css">
291+
@font-face { font-family: icons; src: url(icons-fallback.woff2);
292+
@supports font-technology(color-COLRv1) {
293+
@font-face { font-family: icons; src: url(icons-gradient-var.woff2); }
294+
}
295+
</pre>
296+
297+
</div>
298+
243299
<h2 class=no-num id="priv">Privacy Considerations</h2>
244300

245301
No Privacy issues have been raised against this document
@@ -260,6 +316,7 @@ The @if and @else rules are based on a proposal by Tab Atkins.
260316
</h3>
261317

262318
<ul>
319+
<li>Added some examples</li>
263320
<li>Added @if and @else per CSSWG resolution</li>
264321
<li>Extended @supports feature to express font capabilities</li>
265322
<li>Added two co-editors per CSSWG resolution</li>

0 commit comments

Comments
 (0)