Open cgahr opened 2 weeks ago
Coloring text does not work. Consider the following code:
import matplotlib as mpl import matplotlib.pyplot as plt import mpl_typst.as_default # noqa: F401 fig, ax = plt.subplots(1, 1) colors = ["C0", "C1", "C2"] linestyles = ["-", ":", "-."] legend = ax.legend( [ mpl.lines.Line2D([], [], ls=ls, color=color) for ls, color in zip(linestyles, colors, strict=True) ], ["text0", "text1", "text2"], loc="center", ncol=3, borderaxespad=0.5, ) for text, color in zip(legend.get_texts(), colors, strict=True): text.set_color(color) fig.savefig("test.typ")
The result should be: In the created typst file, however, the text is black and not colored.
I think somewhere in the draw_text function, we must call gc.get_rgb() to get the color and adjust draw-text to take a fill argument so that we can do
draw_text
gc.get_rgb()
draw-text
fill
text(..., fill: color, content)
in prologue.typ.
prologue.typ
Coloring text does not work. Consider the following code:
The result should be: In the created typst file, however, the text is black and not colored.