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