Skip to content

Commit

Permalink
fix scaling factor for svgs
Browse files Browse the repository at this point in the history
  • Loading branch information
jkrumbiegel committed Jun 15, 2024
1 parent ae26973 commit c9c04c7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CairoMakie/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
10 changes: 7 additions & 3 deletions CairoMakie/src/screen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c9c04c7

Please sign in to comment.