added const copies of _all_defaults and _axis_defaults to be able to reset fonts to initial values with new resetfontsizes method
This commit is contained in:
parent
e3ce1ab1d1
commit
fdf699bf35
22
src/args.jl
22
src/args.jl
@ -335,6 +335,10 @@ const _all_defaults = KW[
|
||||
_axis_defaults_byletter
|
||||
]
|
||||
|
||||
# to be able to reset things to initial values
|
||||
const _all_initial_defaults = deepcopy(_all_defaults)
|
||||
const _axis_initial_defaults = deepcopy(_axis_defaults)
|
||||
|
||||
const _all_args = sort(collect(union(map(keys, _all_defaults)...)))
|
||||
|
||||
RecipesBase.is_key_supported(k::Symbol) = is_attr_supported(k)
|
||||
@ -519,6 +523,24 @@ function default(d::KW, k::Symbol)
|
||||
get(d, k, default(k))
|
||||
end
|
||||
|
||||
# reset the defaults globally to values at startup
|
||||
|
||||
"""
|
||||
`initial(key)` returns the intial value for that key
|
||||
"""
|
||||
|
||||
function initial(k::Symbol)
|
||||
k = get(_keyAliases, k, k)
|
||||
for defaults in _all_initial_defaults
|
||||
if haskey(defaults, k)
|
||||
return defaults[k]
|
||||
end
|
||||
end
|
||||
if haskey(_axis_initial_defaults, k)
|
||||
return _axis_initial_defaults[k]
|
||||
end
|
||||
k in _suppress_warnings || error("Unknown key: ", k)
|
||||
end
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
@ -304,11 +304,16 @@ function scalefontsizes(factor::Number)
|
||||
end
|
||||
|
||||
function resetfontsize(k::Symbol)
|
||||
i = initial(k)
|
||||
f = default(k)
|
||||
default(k,f)
|
||||
# some fonts don't have an initial value!
|
||||
if i != false
|
||||
f.pointsize = i.pointsize
|
||||
default(k, i)
|
||||
end
|
||||
end
|
||||
|
||||
"Reset all fonts to default size"
|
||||
"Reset all fonts to initial size"
|
||||
function resetfontsizes()
|
||||
for k in (:titlefont, :guidefont, :tickfont, :legendfont)
|
||||
resetfontsize(k)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user