What is the standard font used by Vegalite.jl?

What is the standard font used for text in Vegalite.jl?


This seemed like the right forum to ask. If wrong, can a moderator move it to the right one? Thanks.

@davidanthoff

1 Like

Yes, thanks. I suppose that is wise.

I think it’s helvetica neue according to this random commit https://github.com/vega/vega-lite/commit/c5cc50cb281114f5db845b174ca0a6983b13ae6f

1 Like

Looks like a good guess, but can we be sure of it based on this?

I have no idea :slight_smile: But I asked on the vega-lite slack, if I get a response I’ll post it here.

2 Likes

Alright, I heard back. In the browser, it will be the browser’s sans serif font. If you save as an SVG, then it will use the sans serif font that the SVG viewer has as a default. If you export to PDF, PNG or one of those formats, Cairo is presumably using the OS default sans serif font.

2 Likes

Ok, got more info: the default font is defined here.

1 Like

Thanks.

So, basically, it will use the viewer’s font and fonts are not embedded; or, if PDF or rasterized, it will embed or rasterize the OS’s sans-serif.

Is there a way to embed a chosen font in an SVG?

The function that produces the SVG is this. I don’t see an option to embed a font there, but it strikes me as a quite reasonable idea in general… Maybe open an issue on the vega repository https://github.com/vega/vega?

1 Like

Yes, perhaps I will.

Is it possible to set fontSize and fontWeight properties for axis labels?

I managed to figure it out. Here is an example. First prepare a dataframe df with the data in columns x and y and z.

using VegaLite
df |>
@vlplot(:rect,
y={“x:o”, title = “Y axis”, axis = {titleFont = “Arial”, titleFontSize = 16}},
x={“y:o”, title = “X axis”, axis = {titleFont = “Arial”, titleFontSize = 16, titleFontWeight = “normal”}},
color=:z)