Search code examples
python-sphinxrestructuredtext

Change default font in sphinx documentation


I want to change the default font in sphinx documentation. I'm using the sphinx_bootstrap_theme 'journal'

How do I do this?


Solution

  • Create your own "_templates" directory and "layout.html" file (assuming you build from a "source" directory):

    $ mkdir source/_templates
    $ touch source/_templates/layout.html
    

    Configure your "conf.py":

    templates_path = ['_templates']
    html_static_path = ['_static']
    

    Override file "source/_templates/layout.html":

    {# Import the theme's layout. #}
    {% extends "!layout.html" %}
    
    {# Custom CSS overrides #}
    {% set bootswatch_css_custom = ['_static/my-styles.css'] %}
    

    In _static/my-styles.css:

    body{
        font-family:"Arial", Helvetica, sans-serif;
    }
    

    This link should further be useful