From 31320923bfca7e1a2c64109a7fc97cb7420d265c Mon Sep 17 00:00:00 2001 From: Charles Dang Date: Mon, 26 Mar 2018 12:03:46 +1100 Subject: [PATCH] GUI2/Canvas: allow formula values for [text] font_size= (cherry-picked from commit 2b9c7b1abd7f881953552dac49d68f2aa5cf2525) --- data/gui/schema.cfg | 2 +- src/gui/core/canvas.cpp | 6 ++++-- src/gui/core/canvas_private.hpp | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/data/gui/schema.cfg b/data/gui/schema.cfg index 79cb3529cff5..4f513ce152c9 100644 --- a/data/gui/schema.cfg +++ b/data/gui/schema.cfg @@ -419,7 +419,7 @@ [/key] [key] name="font_size" - type="unsigned" + type="f_unsigned" mandatory=true [/key] [key] diff --git a/src/gui/core/canvas.cpp b/src/gui/core/canvas.cpp index cc2132a88878..f82461d3beee 100644 --- a/src/gui/core/canvas.cpp +++ b/src/gui/core/canvas.cpp @@ -1254,7 +1254,9 @@ text_shape::text_shape(const config& cfg) , characters_per_line_(cfg["text_characters_per_line"]) , maximum_height_(cfg["maximum_height"], -1) { - VALIDATE(font_size_, _("Text has a font size of 0.")); + if(!font_size_.has_formula()) { + VALIDATE(font_size_(), _("Text has a font size of 0.")); + } const std::string& debug = (cfg["debug"]); if(!debug.empty()) { @@ -1286,7 +1288,7 @@ void text_shape::draw(surface& canvas, .set_text(text, text_markup_(variables)); text_renderer.set_family_class(font_family_) - .set_font_size(font_size_) + .set_font_size(font_size_(variables)) .set_font_style(font_style_) .set_alignment(text_alignment_(variables)) .set_foreground_color(color_(variables)) diff --git a/src/gui/core/canvas_private.hpp b/src/gui/core/canvas_private.hpp index 9d88ca886697..9042341b113e 100644 --- a/src/gui/core/canvas_private.hpp +++ b/src/gui/core/canvas_private.hpp @@ -266,7 +266,7 @@ class text_shape : public canvas::shape { font::family_class font_family_; /** The font size of the text. */ - unsigned font_size_; + typed_formula font_size_; /** The style of the text. */ font::pango_text::FONT_STYLE font_style_;