diff --git a/src/Chart.vala b/src/Chart.vala index 0549542..36fb75c 100644 --- a/src/Chart.vala +++ b/src/Chart.vala @@ -201,17 +201,7 @@ namespace CairoChart { public double title_indent = 4; public virtual void show_text(Text text) { - context.select_font_face(text.style.family, - text.style.slant, - text.style.weight); - context.set_font_size(text.style.size); - if (text.style.orientation == Font.Orientation.VERTICAL) { - context.rotate(- Math.PI / 2.0); - context.show_text(text.text); - context.rotate(Math.PI / 2.0); - } else { - context.show_text(text.text); - } + text.show(context); } protected virtual void draw_chart_title () { diff --git a/src/Text.vala b/src/Text.vala index ab07c3c..4938391 100644 --- a/src/Text.vala +++ b/src/Text.vala @@ -52,6 +52,20 @@ namespace CairoChart { return sz; } + public void show (Cairo.Context context) { + context.select_font_face(style.family, + style.slant, + style.weight); + context.set_font_size(style.size); + if (style.orientation == Font.Orientation.VERTICAL) { + context.rotate(- Math.PI / 2.0); + context.show_text(text); + context.rotate(Math.PI / 2.0); + } else { + context.show_text(text); + } + } + public Text (string text = "", Font.Style style = Font.Style(), Color color = Color()) {