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