GUI2/Canvas: allow formula values for [text] font_size=

(cherry-picked from commit 2b9c7b1abd)
This commit is contained in:
Charles Dang 2018-03-26 12:03:46 +11:00
parent d72612443f
commit 31320923bf
3 changed files with 6 additions and 4 deletions

View file

@ -419,7 +419,7 @@
[/key]
[key]
name="font_size"
type="unsigned"
type="f_unsigned"
mandatory=true
[/key]
[key]

View file

@ -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))

View file

@ -266,7 +266,7 @@ private:
font::family_class font_family_;
/** The font size of the text. */
unsigned font_size_;
typed_formula<unsigned> font_size_;
/** The style of the text. */
font::pango_text::FONT_STYLE font_style_;