Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 901
user248884 Avatar asked Mar 12 '17 14:03

user248884


2 Answers

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

like image 50
FlyingAura Avatar answered Oct 06 '22 00:10

FlyingAura


I found a simpler way to do the same thing.

  1. Create a CSS file under _static folder. for ex, _static/css-style.css
  2. Add the name of the CSS file in conf.py
## conf.py

html_css_files = [
    'css/css-style.css',
]

In _static/css-style.css:

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

Reference: https://docs.readthedocs.io/en/stable/guides/adding-custom-css.html

like image 25
Jay Joshi Avatar answered Oct 06 '22 00:10

Jay Joshi