Skip to content

Commit

Permalink
GUI2/Canvas: allow formula values for [text] font_size=
Browse files Browse the repository at this point in the history
(cherry-picked from commit 2b9c7b1)
  • Loading branch information
Vultraz committed Oct 7, 2018
1 parent d726124 commit 3132092
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion data/gui/schema.cfg
Expand Up @@ -419,7 +419,7 @@
[/key]
[key]
name="font_size"
type="unsigned"
type="f_unsigned"
mandatory=true
[/key]
[key]
Expand Down
6 changes: 4 additions & 2 deletions src/gui/core/canvas.cpp
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion src/gui/core/canvas_private.hpp
Expand Up @@ -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<unsigned> font_size_;

/** The style of the text. */
font::pango_text::FONT_STYLE font_style_;
Expand Down

0 comments on commit 3132092

Please sign in to comment.