Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!-- BEGIN AUTHORED CONTENT --> | 1 <!-- BEGIN AUTHORED CONTENT --> |
| 2 | 2 |
| 3 <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 | 4 |
| 5 <h2 id="manifest">Manifest</h2> | 5 <h2 id="manifest">Manifest</h2> |
| 6 <p>The Font Settings API is currently experimental, so you must declare the | 6 <p>The Font Settings API is currently experimental, so you must declare the |
| 7 "experimental" permission to use it. For example:</p> | 7 "experimental" permission to use it. For example:</p> |
| 8 <pre>{ | 8 <pre>{ |
| 9 "name": "My Font Settings Extension", | 9 "name": "My Font Settings Extension", |
| 10 "description": "Customize your fonts", | 10 "description": "Customize your fonts", |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 <a href="http://www.w3.org/TR/CSS21/fonts.html#generic-font-families">CSS generi c font families</a> | 21 <a href="http://www.w3.org/TR/CSS21/fonts.html#generic-font-families">CSS generi c font families</a> |
| 22 and are listed in the API reference below. When a webpage specifies a generic | 22 and are listed in the API reference below. When a webpage specifies a generic |
| 23 font family, Chrome selects the font based on the corresponding setting. If no | 23 font family, Chrome selects the font based on the corresponding setting. If no |
| 24 generic font family is specified, Chrome uses the setting for the "standard" | 24 generic font family is specified, Chrome uses the setting for the "standard" |
| 25 generic font family.</p> | 25 generic font family.</p> |
| 26 | 26 |
| 27 <p>When a webpage specifies a language, Chrome selects the font based on the | 27 <p>When a webpage specifies a language, Chrome selects the font based on the |
| 28 setting for the corresponding language script. If no language is specified, | 28 setting for the corresponding language script. If no language is specified, |
| 29 Chrome uses the setting for the default, or global, script.</p> | 29 Chrome uses the setting for the default, or global, script.</p> |
| 30 | 30 |
| 31 <p>The supported language scripts are based on ISO 15924 script codes and listed | 31 <p>The supported language scripts are specified by ISO 15924 script code and |
| 32 in the API reference below. Technically, Chrome settings are not strictly | 32 listed in the API reference below. Technically, Chrome settings are not strictly |
| 33 per-script but also depend on language. For example, Chrome chooses the font for | 33 per-script but also depend on language. For example, Chrome chooses the font for |
| 34 Hangul (ISO 15924 script code "Hang") when a webpage specifies Korean language, | 34 Cyrillic (ISO 15924 script code "Cyrl") when a webpage specifies the Russian |
| 35 and uses this font not just for Hangul script but for everything the font | 35 language, and uses this font not just for Cyrillic script but for everything the |
| 36 covers, such as Hanja.</p> | 36 font covers, such as Latin.</p> |
| 37 | |
| 38 <p>Although ISO 15924 provides script codes like "Japn" for Japanese and "Kore" | |
| 39 for Korean, these codes are newer than "Hrkt" and "Hang" which Chrome continues | |
| 40 to use for compatibility purposes.</p> | |
| 41 | 37 |
| 42 <h2 id="examples">Examples</h2> | 38 <h2 id="examples">Examples</h2> |
| 43 <p>The following code gets the standard font for Arabic.</p> | 39 <p>The following code gets the standard font for Arabic.</p> |
| 44 <pre> | 40 <pre> |
| 45 chrome.experimental.fontSettings.getFont( | 41 chrome.experimental.fontSettings.getFont( |
| 46 { genericFamily: 'standard', script: 'Arab' }, | 42 { genericFamily: 'standard', script: 'Arab' }, |
| 47 function(details) { console.log(details.fontName); } | 43 function(details) { console.log(details.fontName); } |
| 48 ); | 44 ); |
| 49 </pre> | 45 </pre> |
| 50 | 46 |
| 51 <p>The next snippet sets the sans-serif font for Japanese.</p> | 47 <p>The next snippet sets the sans-serif font for Japanese.</p> |
| 52 <pre> | 48 <pre> |
| 53 chrome.experimental.fontSettings.setFont( | 49 chrome.experimental.fontSettings.setFont( |
| 54 { genericFamily: 'sansserif', script: 'Hrkt', fontName: 'IPAPGothic' } | 50 { genericFamily: 'sansserif', script: 'Jpan', fontName: 'IPAPGothic' } |
|
jungshik at Google
2012/06/14 21:49:47
Perhaps, a more common Japanese font would be bett
falken
2012/06/15 03:58:11
Done.
| |
| 55 ); | 51 ); |
| 56 </pre> | 52 </pre> |
| 57 | 53 |
| 58 <p>You can find a sample extension using the Font Settings API in the | 54 <p>You can find a sample extension using the Font Settings API in the |
| 59 <a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extension s/docs/examples/api/fontSettings/">examples/api/fontSettings</a> | 55 <a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extension s/docs/examples/api/fontSettings/">examples/api/fontSettings</a> |
| 60 directory. For other examples and for help in viewing the source code, see | 56 directory. For other examples and for help in viewing the source code, see |
| 61 <a href="samples.html">Samples</a>.</p> | 57 <a href="samples.html">Samples</a>.</p> |
| 62 | 58 |
| 63 <!-- END AUTHORED CONTENT --> | 59 <!-- END AUTHORED CONTENT --> |
| OLD | NEW |