Adjusting scales for size automatically in GLMakie

I have my own custom theme for figures used in publication, and usually I set all the default sizes (e.g. fontsize, linewidth, etc) assuming the figure has a specific figure width since that is usually the fixed by the journals. In CairoMakie I usually have something like this

using CairoMakie; CairoMakie.activate!()

fig_size = (6.5, 4.0)   # figure size in inch

set_theme!()
update_theme!(
        fontsize = 9,
        figure_padding = (10f0,10f0,20f0,30f0)

        Lines = (
            linewidth = 1.5,
        )
    )

x1 = range(0, 1, 101)
y1 = sin.(2*pi*x1)

size_pt = 72 .* fig_size

fig = Figure(resolution=size_pt)

ax1 = Axis(fig[1,1], xlabel="x label", ylabel="y label")
lines!(ax1, x, y)
scatter!(ax1, x2, y2, markersize=10*scale)

Label(fig.layout[1,:,Top()], "this is the title", fontsize=12, tellwidth=false,
    tellheight=false, padding=scale.*(0f0,0f0,20f0,0f0))

save("fig_cairo.pdf", fig, pt_per_unit=1)   # save figure as vector graphics
save("fig_cairo.png", fig, px_per_unit=4)   # save figure as bitmap with size 1872 x 1152 px

If I want to save the figure as a bitmap instead (e.g. as .png or .jpg), then I can set px_per_unit, and the figure looks like same in terms of the relative size of different parts regradless of the value of px_per_unit.

Now suppose I want to use GLMakie for certain 3D plots or to make animations, and I need to provide the figure size in pixels from the beginning, and all the sizes in my custom theme no longer works for different figure size. For example, suppose I want to export the figure with pixel size 1872 x 1152, if I keep the fontsize as 9, then it will appear too small in the generated figure. Instead, I need something like this

using GLMakie; GLMakie.activate!()

resolution_w_px = 1872   # desire width in pixel
scale = resolution_w_px/(72*fig_size[1])   # scale = 4 for this example

update_theme!(
        fontsize = 9*scale,
        figure_padding = (10f0,10f0,20f0,30f0) .* scale

        Lines = (
            linewidth = 1.5*scale,
        )
    )

Basically I find that I need to multiply every defined quantity related to fontsize, linewidth or padding space by scale. But in addition to the finite number of self-defined values in my custom theme, there are also many other settings which I keep at the default values (e.g. xgridwidth, xminorgridwidth, xticklabelpad, etc). Is there a way to automatically apply this scale to all the default values of various settings?

No, what you need is a px_per_unit setting for GLMakie, luckily this should happen relatively soon via this PR. Could you try it out and report if it works for your purpose? We’re still testing it