【问题标题】:Change default font in sphinx documentation更改 sphinx 文档中的默认字体
【发布时间】:2017-08-02 13:52:27
【问题描述】:

我想更改 sphinx 文档中的默认字体。我正在使用 sphinx_bootstrap_theme 'journal'

我该怎么做?

【问题讨论】:

    标签: python-sphinx restructuredtext


    【解决方案1】:

    创建您自己的“_templates”目录和“layout.html”文件(假设您从“源”目录构建):

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

    配置你的“conf.py”:

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

    覆盖文件“source/_templates/layout.html”:

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

    _static/my-styles.css:

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

    This link 应该更有用

    【讨论】:

      【解决方案2】:

      我找到了一种更简单的方法来做同样的事情。

      1. 在 _static 文件夹下创建一个 CSS 文件。例如,_static/css-style.css
      2. 在 conf.py 中添加 CSS 文件的名称
      ## conf.py
      
      html_css_files = [
          'css/css-style.css',
      ]
      

      在 _static/css-style.css 中:

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

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

      【讨论】:

        猜你喜欢
        • 2016-09-10
        • 1970-01-01
        • 2018-01-17
        • 2016-04-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-06-08
        相关资源
        最近更新 更多