Creating themes with custom fonts
These examples show how to set the font for text and labels in all built-in charts using the custom theme JSON properties. By setting these JSON properties, you can:
- Use both custom fonts and standard fonts.
- Set the font for the top level of the theme.
- Set the font for all lower levels of the theme.
The fontFamily property is under development. Do not rely on it. It may change or be removed in future versions.
Defining the font
You can specify the font of your choice for text and labels by defining the fontFamily property in the main JSON file for the theme.
Adding custom fonts using CSS
Custom fonts can be added to visualizations with the help of CSS. In this example, we create a CSS file named my_theme.css to define the custom fonts.
Here is an example of the main JSON file that references the CSS file.
The contents of the theme folder for this example would look something like this:
- Alegreya-Black.ttf
- my_theme.css
- my_theme.json
- my_theme.qext
- YatraOne-Regular.ttf