I have finally added support for text segments with different properties (that is, I can now mix regular, italic, bold, subscript, supersscript, etc.) in the same piece of text. This means that text support in Quartz is now arguably more sophisticated than matplotlib. On the other hand, matplotlib supports relatively sophisticated math typesetting, and Quartz doesn’t (yet?).
For example, the new support for different font types allow the title labels to distinguish between normal text and variable names.
One can even simmulate proper math typesetting for simple cases such as greek letters and subscripts, like in the legend of the following energy plot:
Note that we can represent the “non-math” parts using a sans-serif font while using a “fancy” serifs font for the part that attempts to immitate a math formula.
The code that generates the label text is very friendly:
Text.new(["π", Text.sub(["Δ", Text.tspan("E", style: "italic")])],
Config.get_legend_text_attributes(font: "Linux Libertine")
)
While one could use a markup language for this, generating it with code seems more versatile in the long term, so I’ll probably continue to use code (and to develop some better helpers for math greek letters)
























