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