Improve handling invalid markup.
The code tried to render the markup before but since that doesn't fit on the canvas it showed an wml_exception. Now handle it in the text code itself. After the stringfreeze is gone there can be a better warning.
This commit is contained in:
parent
8d0414c818
commit
6a257e093e
3 changed files with 10 additions and 5 deletions
|
@ -1,6 +1,8 @@
|
|||
Version 1.7.7+svn:
|
||||
* Language and i18n:
|
||||
* Updated translations:
|
||||
* User interface:
|
||||
* Instead of "crashing" upon invalid markup try to show the raw text
|
||||
|
||||
Version 1.7.7:
|
||||
* AI:
|
||||
|
|
|
@ -884,11 +884,7 @@ 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));
|
||||
|
||||
text_renderer.set_font_size(font_size_).
|
||||
set_font_style(font_style_).
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include "text.hpp"
|
||||
|
||||
#include "gettext.hpp"
|
||||
#include "gui/widgets/helper.hpp"
|
||||
#include "gui/auxiliary/log.hpp"
|
||||
#include "font.hpp"
|
||||
|
@ -264,6 +265,12 @@ bool ttext::set_text(const std::string& text, const bool markedup)
|
|||
if(!pango_parse_markup(text.c_str(), text.size()
|
||||
, 0, NULL, NULL, NULL, NULL)) {
|
||||
|
||||
ERR_GUI_L << "ttext::" << __func__
|
||||
<< " text '" << text
|
||||
<< "' has broken markup, set to normal text.\n";
|
||||
/** @todo Enable after 1.8. */
|
||||
// set_text(_("The text contains invalid markup: ") + text, false);
|
||||
set_text(text, false);
|
||||
return false;
|
||||
}
|
||||
pango_layout_set_markup(layout_, text.c_str(), text.size());
|
||||
|
|
Loading…
Add table
Reference in a new issue