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