OLD | NEW |
| (Empty) |
1 <!-- BEGIN AUTHORED CONTENT --> | |
2 <p>The Font Settings API allows you to manage Chrome's font settings.</p> | |
3 <h2 id="manifest">Manifest</h2> | |
4 <p>The Font Settings API is currently experimental, so you must declare the | |
5 "experimental" permission to use it. For example:</p> | |
6 <pre>{ | |
7 "name": "My Font Settings Extension", | |
8 "description": "Customize your fonts", | |
9 "version": "0.2", | |
10 "permissions": ["experimental"] | |
11 }</pre> | |
12 <h2 id="scripts">Generic Font Families and Scripts</h2> | |
13 <p>Chrome allows for some font settings to depend on certain generic font | |
14 families and language scripts. For example, the font used for sans-serif | |
15 Simplified Chinese may be different than the font used for serif Japanese.</p> | |
16 <p>The generic font families supported by Chrome are based on | |
17 <a href="http://www.w3.org/TR/CSS21/fonts.html#generic-font-families">CSS generi
c font families</a> | |
18 and are listed in the API reference below. When a webpage specifies a generic | |
19 font family, Chrome selects the font based on the corresponding setting. If no | |
20 generic font family is specified, Chrome uses the setting for the "standard" | |
21 generic font family.</p> | |
22 <p>When a webpage specifies a language, Chrome selects the font based on the | |
23 setting for the corresponding language script. If no language is specified, | |
24 Chrome uses the setting for the default, or global, script.</p> | |
25 <p>The supported language scripts are specified by ISO 15924 script code and | |
26 listed in the API reference below. Technically, Chrome settings are not strictly | |
27 per-script but also depend on language. For example, Chrome chooses the font for | |
28 Cyrillic (ISO 15924 script code "Cyrl") when a webpage specifies the Russian | |
29 language, and uses this font not just for Cyrillic script but for everything the | |
30 font covers, such as Latin.</p> | |
31 <h2 id="examples">Examples</h2> | |
32 <p>The following code gets the standard font for Arabic.</p> | |
33 <pre> | |
34 chrome.experimental.fontSettings.getFont( | |
35 { genericFamily: 'standard', script: 'Arab' }, | |
36 function(details) { console.log(details.fontName); } | |
37 ); | |
38 </pre> | |
39 <p>The next snippet sets the sans-serif font for Japanese.</p> | |
40 <pre> | |
41 chrome.experimental.fontSettings.setFont( | |
42 { genericFamily: 'sansserif', script: 'Jpan', fontName: 'MS PGothic' } | |
43 ); | |
44 </pre> | |
45 <p>You can find a sample extension using the Font Settings API in the | |
46 <a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extension
s/docs/examples/api/fontSettings/">examples/api/fontSettings</a> | |
47 directory. For other examples and for help in viewing the source code, see | |
48 <a href="samples.html">Samples</a>.</p> | |
49 <!-- END AUTHORED CONTENT --> | |
OLD | NEW |