From 2e0d02552f97cad9c13438298e22b2e34ec0dd6c Mon Sep 17 00:00:00 2001 From: Thomas Breloff Date: Mon, 9 Jan 2017 11:42:53 -0500 Subject: [PATCH] started fonts --- src/args.jl | 20 ++++++++++++++++++++ src/backends.jl | 6 +++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/args.jl b/src/args.jl index 119dd125..ddf982e9 100644 --- a/src/args.jl +++ b/src/args.jl @@ -259,6 +259,15 @@ const _subplot_defaults = KW( :bottom_margin => :match, :subplot_index => -1, :colorbar_title => "", + :fontfamily => "Helvetica", + :fontsize => 10, + :fontcolor => :match, # matches foreground_color + :titlefontfamily => :match, + :titlefontsize => :match, + :titlefontcolor => :match, + :legendfontfamily => :match, + :legendfontsize => :match, + :legendfontcolor => :match, ) const _axis_defaults = KW( @@ -278,6 +287,12 @@ const _axis_defaults = KW( :discrete_values => [], :formatter => :auto, :mirror => false, + :tickfontfamily => :match, + :tickfontsize => :match, + :tickfontcolor => :match, + :guidefontfamily => :match, + :guidefontsize => :match, + :guidefontcolor => :match, ) const _suppress_warnings = Set{Symbol}([ @@ -942,8 +957,13 @@ const _match_map2 = KW( :foreground_color_border => :foreground_color_subplot, :foreground_color_guide => :foreground_color_subplot, :foreground_color_text => :foreground_color_subplot, + :fontcolor => :foreground_color_subplot, ) +for prefix in (:title,:legend,:guide,:tick), postfix in (:family,:size,:color) + _match_map2[Symbol(prefix,:font,postfix)] = Symbol(:font,postfix) +end + # properly retrieve from plt.attr, passing `:match` to the correct key function Base.getindex(plt::Plot, k::Symbol) v = plt.attr[k] diff --git a/src/backends.jl b/src/backends.jl index 16fcad2c..50fa4f1c 100644 --- a/src/backends.jl +++ b/src/backends.jl @@ -48,8 +48,8 @@ _series_updated(plt::Plot, series::Series) = nothing _before_layout_calcs(plt::Plot) = nothing -title_padding(sp::Subplot) = sp[:title] == "" ? 0mm : sp[:titlefont].pointsize * pt -guide_padding(axis::Axis) = axis[:guide] == "" ? 0mm : axis[:guidefont].pointsize * pt +title_padding(sp::Subplot) = sp[:title] == "" ? 0mm : sp[:titlefontsize] * pt +guide_padding(axis::Axis) = axis[:guide] == "" ? 0mm : axis[:guidefontsize] * pt "Returns the (width,height) of a text label." function text_size(lablen::Int, sz::Number, rot::Number = 0) @@ -90,7 +90,7 @@ function tick_padding(axis::Axis) # hgt # get the height of the rotated label - text_size(longest_label, axis[:tickfont].pointsize, rot)[2] + text_size(longest_label, axis[:tickfontsize], rot)[2] end end