I want to display an SVG using Bokeh. When I do this inside a Div
, the font-family
is overridden.
For example
from pathlib import Path
from bokeh.models import Div
from bokeh.io import output_file, save
svg = """<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="200" height="200">
<text x="50" y="50" font-family="Courier">hello</text>
</svg>"""
Path("hello.svg").write_text(svg)
div = Div(text=svg, width=200, height=200)
output_file("output.html")
save(div)
I would expect the output.html
to show the SVG text “hello” in Courier - assuming that is available on the system - as is the case for hello.svg
. But output.html
uses another font-family
.
I can fix it by putting the <svg>
inside an <iframe>
, but is there another way?