【问题标题】:How do I add a new font .ttf file to use in Bokeh?如何添加新字体 .ttf 文件以在 Bokeh 中使用?
【发布时间】:2017-02-08 02:06:05
【问题描述】:

我想在绘图中使用 Opensans 字体,但我找不到将 .ttf 文件添加到 Bokeh/Python 的方法。 我为 matplotlib 找到了一种方法,在 Bokeh 0.12.2 中是否有类似的方法? How to use a (random) *.otf or *.ttf font in matplotlib?

谢谢!

格特

【问题讨论】:

    标签: python fonts bokeh


    【解决方案1】:

    散景在 HTML 画布上呈现,因此您必须遵循 How can I use custom fonts in an HTML5 Canvas element? 中的指导,将散景图放在自定义模板中,然后包括 CSS,例如:

    @font-face { 字体系列:'MyWebFont'; src: url('myfont.ttf') 格式('truetype'); }

    加载字体并使其可用。有多种方法可以将散景图和文档嵌入到模板中。在不了解更多信息的情况下,我只能将您指向文档:

    https://docs.bokeh.org/en/latest/docs/user_guide/embed.html

    【讨论】:

      猜你喜欢
      • 2020-12-06
      • 1970-01-01
      • 1970-01-01
      • 2011-02-11
      • 2017-06-04
      • 2021-11-19
      • 2012-06-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多