如何添加要在Bokeh中使用的新字体.ttf文件?

时间:2016-09-29 16:27:37

标签: python fonts bokeh

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

谢谢!

格特

1 个答案:

答案 0 :(得分:0)

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

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

加载字体并使其可用。有各种方法可以将散点图和文档嵌入模板中。不知道更多,我只能指出你的文档:

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