This plugin exposes the following API to easily allow new themes to manage the plugin behavior.
All API functions are called using the prefix gitbook.fontsettings., for instance gitbook.fontsettings.enlargeFontSize().
Font manipulation
gitbook.fontsettings.enlargeFontSize()
Increases the font size of the document by one. Max value is 4.
gitbook.fontsettings.reduceFontSize()
Decreases the font size of the document by one. Min value is 1.
Font families
Each font family should be described as:
var fontFamily = { config: 'sans', // name of the font family in book.json for your theme text: 'Sans', // display name of the font family in menu id: 0 // the id appended to the CSS class for this font-family};
The text property will be used to display the font-family name in the fontsettings dropdown menu.
The config property allows you to let the users of your theme choose a default font family in their book.json. You will have to handle setting the chosen font family in your theme's frontend JavaScript.
This will recreate the fontsettings menu to reflect the changes.
gitbook.fontsettings.setTheme()
Takes a color theme config key as an argument and updates the color theme used for this book.
This will basically apply the CSS class with the corresponding theme id: .color-theme-<id>, or remove the applied CSS class if the selected theme id is 0.