Skip to content

Commit a7a166f

Browse files
committed
Merge branch 'master' of https://github.com/w3c/csswg-drafts
2 parents 636583e + 7c0171e commit a7a166f

File tree

3 files changed

+297
-5
lines changed

3 files changed

+297
-5
lines changed

Transitions.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@ CSS-2017
1616

1717
### Open
1818

19+
_(none)_
20+
21+
### Closed
22+
1923
Fill-Stroke (aka Paint)
2024
* [wg decision](https://www.w3.org/2017/03/22-css-irc#T16-31-40)
2125
* [transition request](https://lists.w3.org/Archives/Member/chairs/2017JanMar/att-0160/00-part)
2226
* [approval](https://lists.w3.org/Archives/Member/chairs/2017JanMar/0161.html)
2327
* [publication request](https://lists.w3.org/Archives/Team/webreq/2017Apr/0017.html) 11 April 2017
24-
25-
26-
### Closed
28+
* [done](https://www.w3.org/TR/2017/WD-fill-stroke-3-20170413/) 13 April 2017
2729

2830
CSS Rhythm
2931
* [transition request](https://lists.w3.org/Archives/Member/chairs/2017JanMar/0104.html) 28 Feb 2017

css-font-loading/Overview.bs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Previous Version: https://www.w3.org/TR/2014/WD-css-font-loading-3-20140522/
1212
Editor: Tab Atkins Jr., Google, http://xanthir.com/contact/
1313
Former Editor: John Daggett, Mozilla, jdaggett@mozilla.com
1414
Abstract: This CSS module describes events and interfaces used for dynamically loading font resources.
15-
Link Defaults: css-fonts-3 (descriptor) src, dom (interface) Event, typedarray (interface) ArrayBuffer/ArrayBufferView
15+
Link Defaults: css-fonts-3 (descriptor) src, dom (interface) Event
1616
Ignored Terms: EventHandler, InvalidModificationError, WorkerGlobalScope, CanvasProxy, Document, add(), src
1717
</pre>
1818

@@ -202,7 +202,7 @@ The Constructor</h3>
202202

203203
A {{FontFace}} can be constructed either
204204
from a URL pointing to a font face file,
205-
or from an ArrayBuffer (or ArrayBufferView) containing the binary representation of a font face.
205+
or from an {{ArrayBuffer}} (or {{ArrayBufferView}}) containing the binary representation of a font face.
206206

207207
When the <dfn constructor lt='FontFace()' for=FontFace>FontFace</dfn>(
208208
<span dfn-for="FontFace/FontFace(family, source, descriptors)">

css-fonts-4/Overview.bs

Lines changed: 290 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,6 +1048,128 @@ at least as dark as its predecessor. Only values greater than 0 and less than 10
10481048
</pre>
10491049
</div>
10501050

1051+
<h2 id="font-rendering-controls">Font Rendering Controls</h2>
1052+
1053+
<h3 id="font-rendering-controls-introduction">Introduction to Font Rendering Controls</h3>
1054+
1055+
When using downloadable webfonts via ''@font-face'',
1056+
the user agent needs to know what to do while the font is actively loading.
1057+
Most web browsers have adopted some form of timeout:
1058+
1059+
<table class='data'>
1060+
<thead>
1061+
<tr>
1062+
<th>Browser
1063+
<th>Timeout
1064+
<th>Fallback
1065+
<th>Swap
1066+
<tbody>
1067+
<tr>
1068+
<th>Chrome 35+
1069+
<td>3 seconds
1070+
<td>yes
1071+
<td>yes
1072+
<tr>
1073+
<th>Opera
1074+
<td>3 seconds
1075+
<td>yes
1076+
<td>yes
1077+
<tr>
1078+
<th>Firefox
1079+
<td>3 seconds
1080+
<td>yes
1081+
<td>yes
1082+
<tr>
1083+
<th>Internet Explorer
1084+
<td>0 seconds
1085+
<td>yes
1086+
<td>yes
1087+
<tr>
1088+
<th>Safari
1089+
<td>3 seconds
1090+
<td>yes
1091+
<td>yes
1092+
</table>
1093+
1094+
* Chrome and Firefox have a 3 second timeout after which the text is shown with the fallback font.
1095+
Eventually, a swap occurs:
1096+
the text is re-rendered with the intended font once it becomes available.
1097+
* Internet Explorer has a 0 second timeout which results in immediate text rendering:
1098+
if the requested font is not yet available,
1099+
fallback is used,
1100+
and text is rerendered later once the requested font becomes available.
1101+
1102+
While these default behaviors are reasonable,
1103+
they're unfortunately inconsistent across browsers.
1104+
Worse, no single approach is sufficient to cover the range of use-cases
1105+
required by modern user-experience&ndash; and performance&ndash;conscious applications.
1106+
1107+
The Font Loading API [[CSS-FONT-LOADING-3]] allows a developer to override some of the above behaviors,
1108+
but that requires scripting,
1109+
a non-trivial amount of effort,
1110+
and ultimately doesn't provide sufficient hooks to cover <em>all</em> reasonable cases.
1111+
Additionally,
1112+
the developer needs to either inline the loading script into their page
1113+
or load an external library,
1114+
introducing additional network latency before the fonts can be loaded
1115+
and delaying text rendering.
1116+
1117+
Design/performance-conscious web developers have a good sense for the relative importance of a given web font for the intended user experience.
1118+
This specification provides them the ability to control font timeout and rendering behavior.
1119+
Specifically, it lets developers:
1120+
1121+
* Define the font display policy when text is ready to be painted: block, or paint with fallback.
1122+
* Define the font display policy once the desired font is available: rerender text with the new font, or leave it with the fallback.
1123+
* Define custom timeout values for each font.
1124+
* Define custom display and timeout policies per element.
1125+
1126+
<h3 id="font-display-timeline">The Font Display Timeline</h3>
1127+
1128+
At the moment the user agent first attempts to use a given downloaded font face on a page,
1129+
the font face's <dfn export local-lt="timer">font download timer</dfn> is started.
1130+
This timer advances through three periods of time associated with the font face--
1131+
the <a>block period</a>, the <a>swap period</a>, and the <a>failure period</a>--
1132+
which dictate the rendering behavior of any elements using the font face:
1133+
1134+
* The first period is the <dfn export local-lt="block period">font block period</dfn>.
1135+
During this period,
1136+
if the font face is not loaded,
1137+
any element attempting to use it must instead <a>render with an invisible fallback font face</a>.
1138+
If the font face successfully loads during the <a>block period</a>,
1139+
the font face is then used normally.
1140+
* The second period, occuring immediately after the <a>block period</a>,
1141+
is the <dfn export local-lt="swap period">font swap period</dfn>.
1142+
During this period,
1143+
if the font face is not loaded,
1144+
any element attempting to use it must instead <a>render with a fallback font face</a>.
1145+
If the font face successfully loads during the <a>swap period</a>,
1146+
the font face is then used normally.
1147+
* The third period, occuring immediately after the <a>swap period</a>,
1148+
is the <dfn export local-lt="failure period">font failure period</dfn>.
1149+
If the font face is not yet loaded when this period starts,
1150+
it's marked as a failed load,
1151+
causing normal font fallback.
1152+
Otherwise, the font face is used normally.
1153+
1154+
To <dfn export>render with a fallback font face</dfn> for a given element,
1155+
the user agent must find the first font face specified in the element's 'font-family!!property' list
1156+
which is already loaded,
1157+
and use that for rendering text.
1158+
Doing this must not trigger loads of any of the fallback fonts.
1159+
1160+
To <dfn export>render with an invisible fallback font face</dfn> for a given element,
1161+
find a font face as per "<a>render with a fallback font face</a>".
1162+
Create an anonymous font face with the same metrics as the selected font face
1163+
but with all glyphs "invisible" (containing no "ink"),
1164+
and use that for rendering text.
1165+
Doing this must not trigger loads of any of the fallback fonts.
1166+
1167+
Issue: ''fallback'' and ''optional'' can result in some faces in a family being used
1168+
while others are required to fallback,
1169+
giving a "ransom note" look.
1170+
Perhaps require that all fonts in a family have the same behavior (all swapped in, or all fallback)?
1171+
See also the @font-feature-values for controlling the behavior on a font family basis.
1172+
10511173
<h2 id="font-resources">Font Resources</h2>
10521174

10531175
<h3 id="font-face-rule">The <dfn id="at-font-face-rule" style="font-weight: inherit; font-style: inherit"><code>@font-face</code></dfn> rule</h3>
@@ -1510,6 +1632,172 @@ at least as dark as its predecessor. Only values greater than 0 and less than 10
15101632
face within a font family.</p>
15111633
</div>
15121634

1635+
<h3 id="font-display-desc">Controlling Font Display Per Font-Face: the 'font-display' descriptor</h3>
1636+
1637+
The '@font-face/font-display' descriptor for ''@font-face''
1638+
determines how a font face is displayed,
1639+
based on whether and when it is downloaded and ready to use.
1640+
1641+
<pre class='descdef'>
1642+
Name: font-display
1643+
Value: auto | block | swap | fallback | optional
1644+
Initial: auto
1645+
For: @font-face
1646+
</pre>
1647+
1648+
Note: For all of these values,
1649+
user agents may use slightly different durations,
1650+
or more sophisticated behaviors that can't be directly expressed in the 'font-display' syntax,
1651+
in order to provide more useful behavior for their users.
1652+
They may also provide the ability for users to override author-chosen behavior
1653+
with something more desirable;
1654+
for example, forcing all fonts to have a ''0s'' <a>block period</a>.
1655+
1656+
<dl dfn-type="value" dfn-for="@font-face/font-display">
1657+
<dt><dfn>auto</dfn>
1658+
<dd>
1659+
The font display policy is user-agent-defined.
1660+
1661+
Note: Many browsers have a default policy similar to that specified by ''block''.
1662+
1663+
<dt><dfn>block</dfn>
1664+
<dd>
1665+
Gives the font face a short <a>block period</a>
1666+
(''3s'' is recommended in most cases)
1667+
and an infinite <a>swap period</a>.
1668+
1669+
Note: In other words, the browser draws "invisible" text at first if it's not loaded,
1670+
but swaps the font face in as soon as it loads.
1671+
1672+
This value must only be used when rendering text in a particular font is required for the page to be usable.
1673+
It must only be used for small pieces of text.
1674+
1675+
<div class="example">
1676+
For example, badly designed "icon fonts" might associate a "⎙" (print) icon
1677+
with an unrelated character like "C",
1678+
so if the text is displayed with a fallback font instead
1679+
there will be confusing letters scattered around the page
1680+
rather than the desired icon.
1681+
In this case, temporary blank spots are better than using a fallback font.
1682+
1683+
(However, the fallback font is used <em>eventually</em>,
1684+
as having confusing letters scattered around the page
1685+
is better than having links and such never show up at all.)
1686+
</div>
1687+
1688+
<dt><dfn>swap</dfn>
1689+
<dd>
1690+
Gives the font face a ''0s'' <a>block period</a>
1691+
and an infinite <a>swap period</a>.
1692+
1693+
Note: In other words, the browser draws the text immediately with a fallback if the font face isn't loaded,
1694+
but swaps the font face in as soon as it loads.
1695+
1696+
This value should only be used when rendering text in a particular font is very important for the page,
1697+
but rendering in any font will still get a correct message across.
1698+
It should only be used for small pieces of text.
1699+
1700+
<div class='example'>
1701+
For example,
1702+
if a website has a custom font for rendering their logo,
1703+
rendering that logo correctly is fairly important for branding purposes,
1704+
but displaying the logo in any font will at least get the point across without confusion.
1705+
</div>
1706+
1707+
<dt><dfn>fallback</dfn>
1708+
<dd>
1709+
Gives the font face an extremely small <a>block period</a>
1710+
(''100ms'' or less is recommended in most cases)
1711+
and a short <a>swap period</a>
1712+
(''3s'' is recommended in most cases).
1713+
1714+
Note: In other words, the font face is rendered with a fallback at first if it's not loaded,
1715+
but it's swapped in as soon as it loads.
1716+
However, if too much time passes,
1717+
the fallback will be used for the rest of the page's lifetime instead.
1718+
1719+
This value should be used for body text,
1720+
or any other text where the use of the chosen font is useful and desired,
1721+
but it's acceptable for the user to see the text in a fallback font.
1722+
This value is appropriate to use for large pieces of text.
1723+
1724+
<div class="example">
1725+
For example,
1726+
in large pieces of body text,
1727+
it's most important just to get the text rendered quickly,
1728+
so the user can begin to read as quickly as possible.
1729+
Further, once the user has started reading,
1730+
they shouldn't be disturbed by the text suddenly "shifting"
1731+
as a new font is swapped in,
1732+
as that's distracting and annoying to re-find where one was in the text.
1733+
</div>
1734+
1735+
<dt><dfn>optional</dfn>
1736+
<dd>
1737+
Gives the font face an extremely small <a>block period</a>
1738+
(''100ms'' or less is recommended in most cases)
1739+
and a ''0s'' <a>swap period</a>.
1740+
1741+
If the font is not retrieved before the two durations expire,
1742+
the user agent may choose to abort the font download,
1743+
or download it with a very low priority.
1744+
If the user agent believes it would be useful for the user,
1745+
it may avoid even starting the font download,
1746+
and proceed immediately to using a fallback font.
1747+
1748+
Note: In other words, the font is used if it's already downloaded and available,
1749+
but otherwise a fallback is used for the rest of the page's lifetime instead.
1750+
The font might download in the background and be available to future page loads,
1751+
but if the user-agent detects that the user has very limited bandwidth,
1752+
it might choose to simply never download and use the font.
1753+
1754+
This value should be used for body text,
1755+
or any other text where the chosen font is purely a decorative "nice-to-have".
1756+
It should be used anytime it is more important that the web page render quickly on first visit,
1757+
than it is that the user wait a longer time to see everything perfect immediately.
1758+
1759+
<div class='example'>
1760+
For example, body text is perfectly readable in one of the browser default fonts,
1761+
though a downloadable font face may be more attractive
1762+
and mesh with the site's aesthetics better.
1763+
First time visitors to a site generally care far more about the site being quickly usable
1764+
than they do about the finer points of its display,
1765+
and ''optional'' provides a good behavior for them.
1766+
If they return later,
1767+
the desired font faces might have finished downloading,
1768+
giving them the "intended" experience without slowing down
1769+
either their first or subsequent visits.
1770+
1771+
Users on very slow connections might not ever receive the "intended" experience,
1772+
but ''optional'' ensures they can actually <em>use</em> the site,
1773+
rather than quitting and going elsewhere because the site takes too long to load.
1774+
</div>
1775+
</dl>
1776+
1777+
<div class='issue'>
1778+
These names aren't great.
1779+
It would probably be better to use "intent" names
1780+
that immediately capture the intended usage of each.
1781+
Some suggestions:
1782+
1783+
* required / important / preferable / optional
1784+
</div>
1785+
1786+
<h4 id="font-display-font-feature-values">Controlling Font Display Per Font-Family via ''@font-feature-values''</h4>
1787+
The '@font-feature-values/font-display' descriptor for ''@font-feature-values'' determines how a font family is displayed, by setting the "default" font-display value for @font-face rules targeting the same font family.
1788+
When font-display is omitted in an @font-face rule, the user agent uses the font-display value set via the @font-feature-values/font-display for the relevant font-family if one is set, and otherwise defaults to "font-display: auto".
1789+
1790+
This mechanism can be used to set a default display policy for an entire font-family, and enables developers to set a display policy for @font-face rules that are not directly under their control.
1791+
For example, when a font is served by a third-party font foundry, the developer does not control the @font-face rules but is still able to set a default font-display policy for the provided font-family.
1792+
The ability to set a default policy for an entire font-family is also useful to avoid the ransom note effect (i.e. mismatched font faces) because the display policy is then applied to the entire font family.
1793+
1794+
<pre class='descdef'>
1795+
Name: font-display
1796+
Value: auto | block | swap | fallback | optional
1797+
Initial: auto
1798+
For: @font-feature-values
1799+
</pre>
1800+
15131801
<h2 id="font-matching-algorithm">Font Matching Algorithm</h2>
15141802

15151803
The algorithm below describes how fonts are associated with
@@ -2409,3 +2697,5 @@ at least as dark as its predecessor. Only values greater than 0 and less than 10
24092697
Peter Constable for assorted language fixes.
24102698

24112699
Optical sizing <a href="#optical-size-example">image</a> prepared by Nick Sherman.
2700+
2701+
Special thanks to Tab Atkins, Jr. for providing the text for the section on <a href="#font-rendering-controls">Font Rendering Controls</a> as well as the section on the 'font-display' descriptor. Special thanks to Ilya Grigorik and David Kuettel for their help in developing these sections.

0 commit comments

Comments
 (0)