The Font Settings API allows you to manage Chrome's font settings.
The Font Settings API is currently experimental, so you must declare the "experimental" permission to use it. For example:
{ "name": "My Font Settings Extension", "description": "Customize your fonts", "version": "0.2", "permissions": ["experimental"] }
Chrome allows for some font settings to depend on certain generic font families and language scripts. For example, the font used for sans-serif Simplified Chinese may be different than the font used for serif Japanese.
The generic font families supported by Chrome are based on CSS generic font families and are listed in the API reference below. When a webpage specifies a generic font family, Chrome selects the font based on the corresponding setting. If no generic font family is specified, Chrome uses the setting for the "standard" generic font family.
When a webpage specifies a language, Chrome selects the font based on the setting for the corresponding language script. If no language is specified, Chrome uses the setting for the default, or global, script.
The supported language scripts are based on ISO 15924 script codes and listed in the API reference below. Technically, Chrome settings are not strictly per-script but also depend on language. For example, Chrome chooses the font for Hangul (ISO 15924 script code "Hang") when a webpage specifies Korean language, and uses this font not just for Hangul script but for everything the font covers, such as Hanja.
Although ISO 15924 provides script codes like "Japn" for Japanese and "Kore" for Korean, these codes are newer than "Hrkt" and "Hang" which Chrome continues to use for compatibility purposes.
The following code gets the standard font for Arabic.
chrome.experimental.fontSettings.getFontName( { genericFamily: 'standard', script: 'Arab' }, function(details) { console.log(details.fontName); } );
The next snippet sets the sans-serif font for Japanese.
chrome.experimental.fontSettings.setFontName( { genericFamily: 'sansserif', script: 'Hrkt', fontName: 'IPAPGothic' } );
You can find a sample extension using the Font Settings API in the examples/api/fontSettings directory. For other examples and for help in viewing the source code, see Samples.