@@ -1606,21 +1606,23 @@ The <dfn id="at-font-face-rule">''@font-face''</dfn> rule</h3>
1606
1606
1607
1607
<pre class='descdef'>
1608
1608
Name : src
1609
- Value : [ <<url>> [ format( <<string>> # )]? | local(<<font-face-name>>) ] #
1609
+ Value : see prose
1610
1610
For : @font-face
1611
1611
Initial : N/A
1612
1612
</pre>
1613
1613
1614
1614
This descriptor specifies the resource containing font data.
1615
1615
It is required for the ''@font-face'' rule to be valid.
1616
1616
Its value is
1617
- a prioritized,
1617
+ a prioritized,
1618
1618
comma-separated list
1619
1619
of external references
1620
1620
or locally-installed font face names.
1621
1621
When a font is needed
1622
1622
the user agent iterates over the set of references listed,
1623
- using the first one it can successfully activate.
1623
+ using the first one it can successfully parse and activate.
1624
+ Parsing this descriptor is more complicated than parsing other descriptors;
1625
+ see [[#font-face-src-parsing]] for the parsing rules.
1624
1626
Activation of a font involves downloading the file
1625
1627
or reading it from disk,
1626
1628
parsing it,
@@ -1631,6 +1633,46 @@ The <dfn id="at-font-face-rule">''@font-face''</dfn> rule</h3>
1631
1633
are ignored
1632
1634
and the user agent loads the next font in the list.
1633
1635
1636
+ <h4 id="font-face-src-parsing">Parsing the 'src!!descriptor' descriptor</h4>
1637
+
1638
+ The value of the 'src!!descriptor' descriptor is parsed piecewise.
1639
+
1640
+ First, opening and closing parentheses are matched.
1641
+ If these parentheses cannot be matched,
1642
+ the value is a parse error.
1643
+ Matching the parentheses has the effect of
1644
+ partitioning the value into multiple regions,
1645
+ each of which is either
1646
+ inside outermost parentheses
1647
+ or outside outermost parentheses.
1648
+
1649
+ Once the value is partitioned,
1650
+ all the commas outside outermost parentheses
1651
+ are located.
1652
+ The value is then split at these comma locations.
1653
+
1654
+ Each item in the split value is then parsed against this grammar:
1655
+
1656
+ <pre> <<url>> [ format(<<font-format>> [supports <<font-technology>>#] ?)]? | local(<<font-face-name>> )</pre>
1657
+
1658
+ <pre class="prod"><dfn id="font-format-values"><font-format></dfn> = [<<string>> | woff | truetype | opentype | woff2 | embedded-opentype | svg]</pre>
1659
+
1660
+ <pre class="prod"><dfn id="font-technology-values"><font-technology></dfn> = [features | variations | color(<<color-font-technology>> ) | palettes]</pre>
1661
+
1662
+ <pre class="prod"><dfn id="color-font-technology-values"><color-font-technology></dfn> = [COLR | SVG | sbix]</pre>
1663
+
1664
+ If parsing a particular item in the split value results in a parse error,
1665
+ that item is thrown out.
1666
+
1667
+ Issue: Define what "thrown out" means
1668
+
1669
+ If no item in the split value survives, then the descriptor is a parse error.
1670
+
1671
+ These parsing rules allow for graceful fallback of fonts
1672
+ for user agents which don't support a particular font technology.
1673
+
1674
+ <h4 id="font-face-src-loading">Loading an individual item in the 'src!!descriptor' descriptor</h4>
1675
+
1634
1676
As with other URLs in CSS,
1635
1677
the URL can be relative,
1636
1678
in which case
@@ -1664,27 +1706,33 @@ The <dfn id="at-font-face-rule">''@font-face''</dfn> rule</h3>
1664
1706
src: url(fonts.svg#simple); /* load SVG font with id 'simple' */
1665
1707
</pre>
1666
1708
1709
+ <h4 id="font-face-src-formats">Selecting items in the 'src!!descriptor'</h4>
1710
+
1667
1711
External references consist of a URL,
1668
1712
followed by an optional hint
1669
1713
describing the format of the font resource referenced by that URL.
1670
- The format hint contains a comma-separated list of format strings
1671
- that denote well-known font formats.
1672
1714
Conformant user agents
1673
1715
must skip downloading a font resource
1674
- if the format hints indicate only unsupported or unknown font formats.
1675
- If no format hints are supplied,
1716
+ if the format hint indicates an unsupported or unknown font format,
1717
+ or if any of the font technologies are unsupported by the user agent.
1718
+ If no format hint is supplied,
1676
1719
the user agent should download the font resource.
1677
1720
1721
+ <div class="example">
1722
+ For example, the following shows how to load a WOFF font if possible, otherwise use an OpenType font
1678
1723
<pre>
1679
- /* load WOFF font if possible, otherwise use OpenType font */
1680
1724
@font-face {
1681
1725
font-family: bodytext;
1682
1726
src: url(ideal-sans-serif.woff) format("woff"),
1683
1727
url(basic-sans-serif.ttf) format("opentype");
1684
1728
}
1685
1729
</pre>
1730
+ </div>
1686
1731
1687
- Format strings defined by this specification:
1732
+ <h5 id="font-face-src-format-types">''@font-face'' format types</h5>
1733
+
1734
+ Format strings defined by this specification are as follows.
1735
+ The <<font-format>> values are synonyms for the formats below.
1688
1736
1689
1737
<table class="data" id="fontformats">
1690
1738
<thead>
@@ -1717,26 +1765,6 @@ The <dfn id="at-font-face-rule">''@font-face''</dfn> rule</h3>
1717
1765
<th> "svg"
1718
1766
<td> <a href="https://www.w3.org/TR/SVG11/fonts.html">SVG Font</a> (deprecated)
1719
1767
<td> .svg, .svgz
1720
- <tr>
1721
- <th> "woff-variations"
1722
- <td> <a href="https://www.w3.org/TR/WOFF/">WOFF (Web Open Font Format)
1723
- with associated variations support</a>
1724
- <td> .woff
1725
- <tr>
1726
- <th> "truetype-variations"
1727
- <td> <a href="https://www.microsoft.com/typography/otspec/default.htm">TrueType
1728
- with associated variations support</a>
1729
- <td> .ttf
1730
- <tr>
1731
- <th> "opentype-variations"
1732
- <td> <a href="https://www.microsoft.com/typography/otspec/default.htm">OpenType
1733
- with associated variations support</a>
1734
- <td> .ttf, .otf
1735
- <tr>
1736
- <th> "woff2-variations"
1737
- <td> <a href="https://www.w3.org/TR/WOFF2/">WOFF File Format 2.0 (Web Open Font Format)
1738
- with associated variations support</a>
1739
- <td> .woff2
1740
1768
</table>
1741
1769
1742
1770
Given the overlap in common usage between TrueType and OpenType,
@@ -1747,23 +1775,50 @@ The <dfn id="at-font-face-rule">''@font-face''</dfn> rule</h3>
1747
1775
or that it contains OpenType layout information
1748
1776
(see <a href="#platform-props-to-css">Appendix A</a> for more background on this).
1749
1777
1750
- A value of "woff-variations",
1751
- "truetype-variations",
1752
- "opentype-variations", or
1753
- "woff2-variations"
1754
- imply support of the "woff",
1755
- "truetype",
1756
- "opentype", or
1757
- "woff2" formats respectively
1758
- along with additional support
1759
- for font variations.
1760
- Web authors can specify this format
1761
- to indicate that variation support is
1778
+ <h5 id="font-face-src-requirement-types">''@font-face'' requirements</h5>
1779
+
1780
+ The 'features' requirement refers to support for font features,
1781
+ commonly implemented in [[!OPENTYPE]] with the <code> GSUB</code> and the <code> GPOS</code> tables,
1782
+ as well as in [[!AAT]] using the <code> morx</code> table.
1783
+ The section on [[#font-rend-props]] describes properties that interact with these facilities.
1784
+
1785
+ The 'variations' requirement refers to the support of font variations,
1786
+ commonly implemented in [[!OPENTYPE]] with the
1787
+ <code> avar</code> , <code> cvar</code> , <code> fvar</code> , <code> gvar</code> , <code> HVAR</code> , <code> MVAR</code> , <code> STAT</code> , and <code> VVAR</code> tables,
1788
+ as well as in [[!AAT]] using the <code> avar</code> , <code> cvar</code> , <code> fvar</code> , and <code> gvar</code> tables.
1789
+ The section on [[#basic-font-props]] as well as the section on [[#font-variation-props]]
1790
+ describe properties that interact with these facilities.
1791
+
1792
+ The 'color' requirement lists various types of color font file technologies.
1793
+ Each of the arguments to the 'color' function represents a table
1794
+ inside [[!OPENTYPE]] or [[!AAT]] fonts which must be supported
1795
+ to satisfy this requirement.
1796
+
1797
+ The 'palettes' requirement refers to support for font palettes,
1798
+ commonly implemented in the [[!OPENTYPE]] and [[!AAT]]
1799
+ with the <code> CPAL</code> table.
1800
+ The section on [[#color-font-support]] describes properties that interact with these facilities.
1801
+
1802
+ Web authors can specify the 'format' function
1803
+ to indicate that support is
1762
1804
required for correct rendering of a font.
1763
1805
This mechanism can be used for gracefully falling back
1764
1806
to an ancillary font
1765
1807
when variation support is not present.
1766
1808
1809
+ <div class="example">
1810
+ This ''@font-face'' block shows how to use a color font if support is present on the user agent,
1811
+ and falls back to a non-color-font if support is not present.
1812
+ <pre>
1813
+ @font-face {
1814
+ font-family: "Trickster";
1815
+ src: url("trickster-COLR.otf") format(opentype supports color(COLR)), url("trickster-outline.otf") format(opentype);
1816
+ }
1817
+ </pre>
1818
+ </div>
1819
+
1820
+ <h5 id="local-font-fallback">Local font fallback</h5>
1821
+
1767
1822
When authors would prefer to use
1768
1823
a locally available copy of a given font
1769
1824
and download it if it's not,
@@ -1840,20 +1895,22 @@ The <dfn id="at-font-face-rule">''@font-face''</dfn> rule</h3>
1840
1895
User agents that also match other full font names,
1841
1896
e.g. matching the Dutch name when the current system locale is set to Dutch,
1842
1897
are considered non-conformant.
1843
- This is done
1844
- not to prefer English
1898
+
1899
+ Note: This is done,
1900
+ not to prefer English,
1845
1901
but to avoid matching inconsistencies
1846
1902
across font versions and OS localizations,
1847
1903
since font style names (e.g. "Bold")
1848
1904
are frequently localized into many languages
1849
1905
and the set of localizations available
1850
1906
varies widely across platform and font version.
1907
+
1851
1908
User agents that match a concatenation of
1852
1909
family name (nameID = 1) with
1853
1910
style name (nameID = 2)
1854
1911
are considered non-conformant.
1855
1912
1856
- This also allows for referencing faces
1913
+ Note: This also allows for referencing faces
1857
1914
that belong to larger families
1858
1915
that cannot otherwise be referenced.
1859
1916
0 commit comments