@@ -30,6 +30,8 @@ To add a custom stylesheet, follow these steps:
3030
3131 When you build your documentation, this stylesheet should now be activated.
3232
33+ .. _css-variables :
34+
3335CSS Theme variables
3436===================
3537
@@ -49,7 +51,7 @@ In order to change a variable, follow these steps:
4951 .. code-block :: none
5052
5153 :root {
52- --font-size-base: 17px;
54+ --pst- font-size-base: 17px;
5355 }
5456
5557 For a complete list of the theme variables that you may override, see the
@@ -65,37 +67,60 @@ For a complete list of the theme variables that you may override, see the
6567Replacing/Removing Fonts
6668========================
6769
68- The theme contains custom web fonts, in several formats, for different purposes:
70+ The theme includes the `FontAwesome 5 Free <https://fontawesome.com/icons?m=free >`__
71+ icon font (the ``.fa, .far, .fas `` styles, which are used for
72+ :ref: `icon links <icon-links >` and admonitions).
73+ This is the only `vendored ` font, and otherwise the theme by default relies on
74+ available system fonts for normal body text and headers.
75+
76+ .. Attention ::
77+
78+ Previously-included fonts like `Lato ` have been removed, preferring
79+ the most common default system fonts of the reader's computer. This provides
80+ both better performance, and better script/glyph coverage than custom fonts,
81+ and is recommended in most cases.
82+
83+ The default body and header fonts can be changed as follows:
84+
85+ - Using :ref: `custom-css `, you can specify which fonts to use for body, header
86+ and monospace text. For example, the following can be added to a custom
87+ css file:
6988
70- - "normal" body text, on ``body ``
71- - page and section headers, on ``.header-style ``
72- - icons, on ``.fa, .far, .fas ``
89+ .. code-block :: none
7390
74- While altering the icon font is presently somewhat involved, the body and header fonts,
75- often paired together, can be replaced (or removed altogether) by:
91+ :root {
92+ --pst-font-family-base: Verdana, var(--pst-font-family-base-system);
93+ --pst-font-family-heading: Cambria, Georgia, Times, var(--pst-font-family-base-system);
94+ --pst-font-family-monospace: Courier, var(--pst-font-family-monospace-system);
95+ }
7696
77- - configuring `template_path <https://www.sphinx-doc.org/en/master/theming.html#templating >`__
78- in your ``conf.py ``
79- - creating a custom ``layout.html `` Jinja2 template which overloads the ``fonts `` block
97+ The ``-system `` variables are available to use as fallback to the default fonts.
8098
81- .. code-block :: html+jinja
99+ - If the font you want to specify in the section above is not generally available
100+ by default, you will additionally need to ensure the font is loaded.
101+ For example, you could download and vendor the font in the ``_static `` directory
102+ of your Sphinx site, and then update the base template to load the font resources:
82103
83- {% extends "pydata_sphinx_theme/layout.html" %}
104+ - Configure the `template_path <https://www.sphinx-doc.org/en/master/theming.html#templating >`__
105+ in your ``conf.py ``
106+ - Create a custom ``layout.html `` Jinja2 template which overloads the ``fonts `` block
107+ (example for loading the Lato font that is included in the ``_static/vendor `` directory):
84108
85- {% block fonts %}
109+ .. code-block :: html+jinja
110+
111+ {% extends "pydata_sphinx_theme/layout.html" %}
112+
113+ {% block fonts %}
86114 <!-- add `style ` or `link ` tags with your CSS `@font-face ` declarations here -->
87- <!-- ... and a `style ` tag with setting `font-family ` in `body ` and `.header-style ` -->
88115 <!-- ... and optionally preload the `woff2 ` for snappier page loads -->
89- <!-- or add a `style ` tag with a font fallback chain with good cross-platform coverage -->
90- <style>
91- body {
92- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
93- }
94- .header-style {
95- font-family: Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;
96- }
97- </style>
98- {% endblock %}
116+ <link rel="stylesheet" href="{{ pathto('_static/vendor/lato_latin-ext/1.44.1/index.css', 1) }}">
117+
118+ {% endblock %}
119+
120+ To reduce the `Flash of Unstyled Content `, you may wish to explore various options for
121+ `preloading content <https://developer.mozilla.org/en-US/docs/Web/HTML/Preloading_content >`__,
122+ specifically the binary font files. This ensure the files will be loaded
123+ before waiting for the CSS to be parsed, but should be used with care.
99124
100125.. _pydata-css-variables : https://github.com/pydata/pydata-sphinx-theme/blob/master/pydata_sphinx_theme/static/css/theme.css
101126.. _css-variable-help : https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties
0 commit comments