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 <pre>{ |
| 9 "name": "My Font Settings Extension", |
| 10 "description": "Customize your fonts", |
| 11 "version": "0.2", |
| 12 "permissions": ["experimental"] |
| 13 }</pre> |
| 14 |
| 15 <h2 id="scripts">Generic Font Families and Scripts</h2> |
| 16 <p>Chrome allows for some font settings to depend on certain generic font |
| 17 families and language scripts. For example, the font used for sans-serif |
| 18 Simplified Chinese may be different than the font used for serif Japanese.</p> |
| 19 |
| 20 <p>The generic font families supported by Chrome are based on |
| 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 |
| 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" |
| 25 generic font family.</p> |
| 26 |
| 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, |
| 29 Chrome uses the setting for the default, or global, script.</p> |
| 30 |
| 31 <p>The supported language scripts are based on ISO 15924 script codes and listed |
| 32 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 |
| 34 Hangul (ISO 15924 script code "Hang") when a webpage specifies Korean language, |
| 35 and uses this font not just for Hangul script but for everything the font |
| 36 covers, such as Hanja.</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 |
| 42 <h2 id="examples">Examples</h2> |
| 43 <p>The following code gets the standard font for Arabic.</p> |
| 44 <pre> |
| 45 chrome.experimental.fontSettings.getFontName( |
| 46 { genericFamily: 'standard', script: 'Arab' }, |
| 47 function(details) { console.log(details.fontName); } |
| 48 ); |
| 49 </pre> |
| 50 |
| 51 <p>The next snippet sets the sans-serif font for Japanese.</p> |
| 52 <pre> |
| 53 chrome.experimental.fontSettings.setFontName( |
| 54 { genericFamily: 'sansserif', script: 'Hrkt', fontName: 'IPAPGothic' } |
| 55 ); |
| 56 </pre> |
| 57 |
| 58 <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> |
| 60 directory. For other examples and for help in viewing the source code, see |
| 61 <a href="samples.html">Samples</a>.</p> |
| 62 |
| 63 <!-- END AUTHORED CONTENT --> |
OLD | NEW |