Search code examples
pythonfont-facebokeh

Simultaneous bold and italic text in bokeh


How can I specify that I want text (say an axis title) to be both bold and italic in bokeh?

This is bold: text_font_style = 'bold'

This is italic: text_font_style = 'italic'

How do I do both simultaneously? I assume this is possible because of this response on the issue tracker

Some things I have tried without success include:

text_font_style = 'bolditalic'
text_font_style = 'bold+italic'
text_font_style = ('bold', 'italic')
text_font_style = set('bold', 'italic')

# together (in a last ditch effort):
text_font_style = 'bold'
text_font_style = 'italic'

Solution

  • As of Bokeh 0.13 this does not appear to be possible. The FontStyle enum is currently defined as:

    FontStyle = enumeration("normal", "italic", "bold")
    

    Which means that a Bokeh text_font_style property will only accept any one on those, i.e. you can only have bold or italic, but not both. I would describe this as a simple oversight that no one has noticed until now. I think fixing this would be as simple as adding new values for the combinations, e.g. "italic bold", to the enum value (and fixing up some some related tests), so I would encourage you to submit a new feature request issue on GitHub.