From c9c04c7023cae679da269f0f3fed345914e5fceb Mon Sep 17 00:00:00 2001 From: Julius Krumbiegel Date: Sat, 15 Jun 2024 19:00:26 +0200 Subject: [PATCH] fix scaling factor for svgs --- CairoMakie/Project.toml | 2 ++ CairoMakie/src/screen.jl | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CairoMakie/Project.toml b/CairoMakie/Project.toml index 3e4495fd8b5..aca69ddd2d3 100644 --- a/CairoMakie/Project.toml +++ b/CairoMakie/Project.toml @@ -6,6 +6,7 @@ version = "0.12.2" [deps] CRC32c = "8bf52ea8-c179-5cab-976a-9e18b702a9bc" Cairo = "159f3aea-2a34-519c-b102-8c37f9878175" +Cairo_jll = "83423d85-b0ee-5818-9007-b63ccbeb887a" Colors = "5ae59095-9a9b-59fe-a467-6f913c188581" FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" FreeType = "b38be410-82b0-50bf-ab77-7b57e271db43" @@ -17,6 +18,7 @@ PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a" [compat] CRC32c = "1.0, 1.6" Cairo = "1.0.4" +Cairo_jll = "1.18.0" Colors = "0.10, 0.11, 0.12" FileIO = "1.1" FreeType = "3, 4.0" diff --git a/CairoMakie/src/screen.jl b/CairoMakie/src/screen.jl index af5b7042a26..d9d23959c6d 100644 --- a/CairoMakie/src/screen.jl +++ b/CairoMakie/src/screen.jl @@ -112,13 +112,17 @@ struct ScreenConfig end end +css_px_per_unit(pt_per_unit) = pt_per_unit / 0.75 + function device_scaling_factor(rendertype, sc::ScreenConfig) - isv = is_vector_backend(convert(RenderType, rendertype)) - return isv ? sc.pt_per_unit : sc.px_per_unit + rt = convert(RenderType, rendertype) + isv = is_vector_backend(rt) + # from version 1.18 on, Cairo saves SVGs without the pt unit specified, so they are actually in CSS px now + return rt === SVG ? css_px_per_unit(sc.pt_per_unit) : isv ? sc.pt_per_unit : sc.px_per_unit end function device_scaling_factor(surface::Cairo.CairoSurface, sc::ScreenConfig) - return is_vector_backend(surface) ? sc.pt_per_unit : sc.px_per_unit + return device_scaling_factor(get_render_type(surface), sc) end const LAST_INLINE = Ref{Union{Makie.Automatic,Bool}}(Makie.automatic)