diff --git a/src/Chart.vala b/src/Chart.vala index ad31db2..2b4b25b 100644 --- a/src/Chart.vala +++ b/src/Chart.vala @@ -342,10 +342,10 @@ namespace CairoChart { ctx.stroke (); } protected virtual void draw_title () { - var title_height = title.height + title.vspacing * 2; + var title_height = title.height + title.font.vspacing * 2; evarea.y0 += title_height; color = title.color; - ctx.move_to (area.width/2 - title.width/2, title.height + title.vspacing); + ctx.move_to (area.width/2 - title.width/2, title.height + title.font.vspacing); title.show(); } protected virtual void draw_haxes () { diff --git a/src/Cursor.vala b/src/Cursor.vala index 845a038..e8ae92b 100644 --- a/src/Cursor.vala +++ b/src/Cursor.vala @@ -296,7 +296,7 @@ namespace CairoChart { break; case Axis.Position.HIGH: var title_height = chart.title.height + (chart.legend.position == Legend.Position.TOP ? - chart.title.vspacing * 2 : chart.title.vspacing); + chart.title.font.vspacing * 2 : chart.title.font.vspacing); print_y = chart.area.y0 + title_height + s.axis_x.font_spacing + (chart.legend.position == Legend.Position.TOP ? chart.legend.height : 0); switch (s.axis_x.dtype) { diff --git a/src/Font.vala b/src/Font.vala index 2328aba..d9065ae 100644 --- a/src/Font.vala +++ b/src/Font.vala @@ -31,6 +31,29 @@ namespace CairoChart { */ public virtual Gtk.Orientation orient { get; set; } + /** + * Vertical spacing. + */ + public double vspacing = 4; + + /** + * Horizontal spacing. + */ + public double hspacing = 4; + + /** + * Both vertical & horizontal spacing (set only). + */ + public virtual double spacing { + protected get { + return 0; + } + set { + vspacing = hspacing = value; + } + default = 4; + } + /** * Constructs a new ``Font``. * @param family a font family name, encoded in UTF-8. @@ -43,7 +66,9 @@ namespace CairoChart { double size = 10, Cairo.FontSlant slant = Cairo.FontSlant.NORMAL, Cairo.FontWeight weight = Cairo.FontWeight.NORMAL, - Gtk.Orientation orient = Gtk.Orientation.HORIZONTAL + Gtk.Orientation orient = Gtk.Orientation.HORIZONTAL, + double vspacing = 4, + double hspacing = 4 ) { this.family = family; this.size = size; @@ -56,7 +81,10 @@ namespace CairoChart { * Gets a copy of the ``Font``. */ public virtual Font copy () { - return new Font(family, size, slant, weight, orient); + var f = new Font(family, size, slant, weight, orient); + f.vspacing = vspacing; + f.hspacing = hspacing; + return f; } } } diff --git a/src/Legend.vala b/src/Legend.vala index 9987934..3fc52be 100644 --- a/src/Legend.vala +++ b/src/Legend.vala @@ -54,7 +54,7 @@ namespace CairoChart { case Position.TOP: x0 = (chart.area.width - width) / 2; var title_height = chart.title.height + (chart.legend.position == Legend.Position.TOP ? - chart.title.vspacing * 2 : chart.title.vspacing); + chart.title.font.vspacing * 2 : chart.title.font.vspacing); y0 = title_height; break; diff --git a/src/Text.vala b/src/Text.vala index c7683de..75245e4 100644 --- a/src/Text.vala +++ b/src/Text.vala @@ -44,29 +44,6 @@ namespace CairoChart { */ public Color color = Color(); - /** - * Vertical spacing. - */ - public double vspacing = 4; - - /** - * Horizontal spacing. - */ - public double hspacing = 4; - - /** - * Both vertical & horizontal spacing (set only). - */ - public virtual double spacing { - protected get { - return 0; - } - set { - vspacing = hspacing = value; - } - default = 4; - } - /** * Cairo ``Text`` extents. */ @@ -158,8 +135,6 @@ namespace CairoChart { text.font = this.font; text._ext = this._ext; text.color = this.color; - text.hspacing = this.hspacing; - text.vspacing = this.vspacing; return text; } }