better math parent font matching
This commit is contained in:
parent
121ab8755c
commit
68f23d3955
@ -178,14 +178,19 @@ py_fillstyle(::Nothing) = nothing
|
|||||||
py_fillstyle(fillstyle::Symbol) = string(fillstyle)
|
py_fillstyle(fillstyle::Symbol) = string(fillstyle)
|
||||||
|
|
||||||
function py_get_matching_math_font(parent_fontfamily)
|
function py_get_matching_math_font(parent_fontfamily)
|
||||||
math_font_family = if parent_fontfamily == "sans-serif"
|
# matplotlib supported math fonts according to
|
||||||
"dejavusans"
|
# https://matplotlib.org/stable/tutorials/text/mathtext.html
|
||||||
elseif parent_fontfamily == "serif"
|
py_math_supported_fonts = Dict{String, String}(
|
||||||
"dejavuserif"
|
"sans-serif" => "dejavusans",
|
||||||
else
|
"serif" => "dejavuserif",
|
||||||
parent_fontfamily
|
"cm" => "cm",
|
||||||
end
|
"stix" => "stix",
|
||||||
return math_font_family
|
"stixsans" => "stixsans"
|
||||||
|
)
|
||||||
|
# Fallback to "dejavusans" or "dejavuserif" in case the parentfont is different
|
||||||
|
# from supported by matplotlib fonts
|
||||||
|
matching_font(font) = occursin("serif", lowercase(font)) ? "dejavuserif" : "dejavusans"
|
||||||
|
return get(py_math_supported_fonts, parent_fontfamily, matching_font(parent_fontfamily))
|
||||||
end
|
end
|
||||||
|
|
||||||
# # untested... return a FontProperties object from a Plots.Font
|
# # untested... return a FontProperties object from a Plots.Font
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user