mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-03 11:31:20 +00:00
parent
4aa48a95d3
commit
6dc6ebd51d
@ -36,6 +36,7 @@ Version 1.7.2+svn:
|
||||
leader is on a keep. (bug #13856 and #13855)
|
||||
* wmllint updated to accomodate new drake names. Gladiator changes must
|
||||
still be done by hand.
|
||||
* No longer "crash" upon invalid pango markup
|
||||
|
||||
Version 1.7.2:
|
||||
* Campaigns:
|
||||
|
@ -884,9 +884,13 @@ void ttext::draw(surface& canvas,
|
||||
}
|
||||
|
||||
static font::ttext text_renderer;
|
||||
if(!text_renderer.set_text(text, text_markup_(variables))) {
|
||||
ERR_GUI_D << "Text: Invalid markup in '"
|
||||
<< text << "' rendered as is.\n";
|
||||
text_renderer.set_text(text, false);
|
||||
}
|
||||
|
||||
text_renderer.set_text(text, text_markup_(variables)).
|
||||
set_font_size(font_size_).
|
||||
text_renderer.set_font_size(font_size_).
|
||||
set_font_style(font_style_).
|
||||
set_foreground_colour(colour_).
|
||||
set_maximum_width(maximum_width_(variables)).
|
||||
@ -898,7 +902,7 @@ void ttext::draw(surface& canvas,
|
||||
|
||||
surface surf = text_renderer.render();
|
||||
if(surf->w == 0) {
|
||||
DBG_GUI_D << "Text: Rendering '" <<
|
||||
DBG_GUI_D << "Text: Rendering '" <<
|
||||
text << "' resulted in an empty canvas, leave.\n";
|
||||
return;
|
||||
}
|
||||
|
@ -268,8 +268,13 @@ void part_ui::render_title_box()
|
||||
titlebox_max_h = base_rect_.h - 2*titlebox_padding;
|
||||
|
||||
font::ttext t;
|
||||
t.set_text(titletxt, true)
|
||||
.set_font_style(font::ttext::STYLE_NORMAL)
|
||||
if(!t.set_text(titletxt, true)) {
|
||||
ERR_NG << "Text: Invalid markup in '"
|
||||
<< titletxt << "' rendered as is.\n";
|
||||
t.set_text(titletxt, false);
|
||||
}
|
||||
|
||||
t.set_font_style(font::ttext::STYLE_NORMAL)
|
||||
.set_font_size(titlebox_font_size)
|
||||
.set_foreground_colour(titlebox_font_color)
|
||||
.set_maximum_width(titlebox_max_w)
|
||||
@ -373,8 +378,12 @@ void part_ui::render_story_box()
|
||||
bool skip = false, last_key = true;
|
||||
|
||||
font::ttext t;
|
||||
t.set_text(p_.text(), true)
|
||||
.set_font_style(font::ttext::STYLE_NORMAL)
|
||||
if(!t.set_text(p_.text(), true)) {
|
||||
ERR_NG << "Text: Invalid markup in '"
|
||||
<< p_.text() << "' rendered as is.\n";
|
||||
t.set_text(p_.text(), false);
|
||||
}
|
||||
t.set_font_style(font::ttext::STYLE_NORMAL)
|
||||
.set_foreground_colour(storybox_font_color)
|
||||
.set_maximum_width(max_width)
|
||||
.set_maximum_height(max_height);
|
||||
|
@ -254,12 +254,17 @@ gui2::tpoint ttext::get_column_line(const gui2::tpoint& position) const
|
||||
}
|
||||
}
|
||||
|
||||
ttext& ttext::set_text(const std::string& text, const bool markedup)
|
||||
bool ttext::set_text(const std::string& text, const bool markedup)
|
||||
{
|
||||
if(markedup != markedup_text_ || text != text_) {
|
||||
assert(layout_);
|
||||
|
||||
if(markedup) {
|
||||
if(!pango_parse_markup(text.c_str(), text.size()
|
||||
, 0, NULL, NULL, NULL, NULL)) {
|
||||
|
||||
return false;
|
||||
}
|
||||
pango_layout_set_markup(layout_, text.c_str(), text.size());
|
||||
} else {
|
||||
/*
|
||||
@ -277,7 +282,7 @@ ttext& ttext::set_text(const std::string& text, const bool markedup)
|
||||
surface_dirty_ = true;
|
||||
}
|
||||
|
||||
return *this;
|
||||
return true;
|
||||
}
|
||||
|
||||
ttext& ttext::set_font_size(const unsigned font_size)
|
||||
|
15
src/text.hpp
15
src/text.hpp
@ -148,9 +148,22 @@ public:
|
||||
*/
|
||||
size_t get_length() const { return length_; }
|
||||
|
||||
/**
|
||||
* Sets the text to render.
|
||||
*
|
||||
* @param text The text to render.
|
||||
* @param markedup Should the text be rendered with pango
|
||||
* markup. If the markup is invalid it's
|
||||
* rendered as text without markup.
|
||||
*
|
||||
* @returns The status, if rendered as markup and the
|
||||
* markup contains errors, false is returned
|
||||
* else true.
|
||||
*/
|
||||
bool set_text(const std::string& text, const bool markedup);
|
||||
|
||||
/***** ***** ***** ***** Setters / getters ***** ***** ***** *****/
|
||||
|
||||
ttext& set_text(const std::string& text, const bool markedup);
|
||||
const std::string& text() const { return text_; }
|
||||
|
||||
ttext& set_font_size(const unsigned font_size);
|
||||
|
Loading…
x
Reference in New Issue
Block a user