|
|
| 第36行: |
第36行: |
|
| |
|
| * [[/字体格式|字体格式]] | | * [[/字体格式|字体格式]] |
| === 格式示例 ===
| |
| <blockquote>
| |
| <syntaxhighlight lang="css">
| |
| @font-face {
| |
| font-family: <font-name>;
| |
| src: <local/url> <format>,[…];
| |
| font-weight: <font-weight>;
| |
| font-style: <font-style>;
| |
| font-stretch: <font-stretch>;
| |
| unicode-range:<unicode-range>;
| |
| }
| |
| </syntaxhighlight></blockquote>
| |
|
| |
| 示例如下:
| |
|
| |
| <syntaxhighlight lang="css">
| |
| @font-face {
| |
| font-family: 'Awesome Font';
| |
| font-style: normal;
| |
| font-weight: 400;
| |
| src: local('Awesome Font'),
| |
| url('/fonts/awesome.woff2') format('woff2'),
| |
| url('/fonts/awesome.woff') format('woff'),
| |
| url('/fonts/awesome.ttf') format('ttf'),
| |
| url('/fonts/awesome.eot') format('eot');
| |
| }
| |
| </syntaxhighlight>
| |
|
| |
| === [http://www.w3.org/TR/css3-fonts/#descdef-unicode-range Unicode-range] ===
| |
|
| |
| 可以将一个大的字体设置成小的子集(例如拉丁,希腊和斯拉夫字母等),并且只是加载这个子集来渲染页面上的字体。使用unicide range 子集并将文件分成字体不同样式的变体可以迅速和高效的下载用户“只需要”下载的子集和变体的字体。
| |
|
| |
| 指定一个逗号隔开的数据集合, 数据可以是下面三种形式中的任何一种:
| |
|
| |
| * Single codepoint (e.g. U+416)
| |
| * Interval range (e.g. U+400-4ff): indicates the start and end codepoints of a range
| |
| * Wildcard range (e.g. U+4??): ‘?’ characters indicate any hexadecimal digit
| |
|
| |
| <syntaxhighlight lang="css">
| |
| @font-face {
| |
| font-family: 'Awesome Font';
| |
| font-style: normal;
| |
| font-weight: 400;
| |
| src: local('Awesome Font'),
| |
| url('/fonts/awesome-l.woff2') format('woff2'),
| |
| url('/fonts/awesome-l.woff') format('woff'),
| |
| url('/fonts/awesome-l.ttf') format('ttf'),
| |
| url('/fonts/awesome-l.eot') format('eot');
| |
| unicode-range: U+000-5FF; /* Latin glyphs */
| |
| }</syntaxhighlight>
| |
|
| |
| === [https://www.w3.org/TR/WOFF2/ WOFF2] ===
| |
| {| class="wikitable"
| |
| |-
| |
| | IE 浏览器 || ||
| |
| |-
| |
| | 其他浏览器 || ||
| |
| |}
| |
| === WOFF ===
| |
| {| class="wikitable"
| |
| |-
| |
| | IE 浏览器 || 旧的浏览器不支持 ||
| |
| |-
| |
| | 其他浏览器 || 旧的浏览器不支持 ||
| |
| |}
| |
| === EOT ===
| |
| {| class="wikitable"
| |
| |-
| |
| | IE 浏览器 || 支持 || IE (版本<9)使用 EOT 变体
| |
| |-
| |
| | 其他浏览器 || 不支持 ||
| |
| |}
| |
| === TTF/OTF ===
| |
| {| class="wikitable"
| |
| |-
| |
| | IE 浏览器 || 部分支持 ||
| |
| |-
| |
| | 其他浏览器 || ||
| |
| |-
| |
| | 安卓 || 支持 || 安卓(版本<4.4)使用 TTF 变体
| |
| |}
| |
| === SVG ===
| |
| === 兼容 ===
| |
| https://caniuse.com/
| |
|
| |
|
| == 字体压缩 == | | == 字体压缩 == |