ui: Fix ThemeWML [label] text_rgb= being horribly broken

First cause of breakage seems to be that the introduction of color_t
changed the size of the colour components from something longer than 8
bits to 8 bits, resulting in stringstream outputting invalid UTF-8. The
second cause is the dropping of GUI1 markup along with SDL_ttf.
This commit is contained in:
Iris Morelle 2021-03-13 14:58:08 -03:00
parent a0d1896942
commit 45ca791387
2 changed files with 4 additions and 15 deletions

View file

@ -27,6 +27,7 @@
* Make the warning about loading saves from old versions much clearer.
### WML Engine
* Standard Location Filters now support gives_income=yes|no to make it simpler to match villages regardless of owner
* Fixed ThemeWML `[label] font_rgb=` generating text elements with broken UTF-8 sequences.
### Miscellaneous and Bug Fixes
* Added support for 1.14s tag names in `[terrain_defaults]` (issue #5308).
* Replaced legacy SDL_ttf/FriBidi-based font rendering used in old GUI1 code paths with Pango.

View file

@ -1434,19 +1434,8 @@ static void draw_label(CVideo& video, surface target, const theme::label& label)
{
//log_scope("draw label");
const color_t& RGB = label.font_rgb();
std::string c_start="<";
std::string c_sep=",";
std::string c_end=">";
std::stringstream color;
color<< c_start << RGB.r << c_sep << RGB.g << c_sep << RGB.b << c_end;
std::string text = label.text();
if(label.font_rgb_set()) {
color<<text;
text = color.str();
}
const std::string& text = label.text();
const color_t text_color = label.font_rgb_set() ? label.font_rgb() : font::NORMAL_COLOR;
const std::string& icon = label.icon();
SDL_Rect& loc = label.location(video.screen_area());
@ -1464,9 +1453,8 @@ static void draw_label(CVideo& video, surface target, const theme::label& label)
tooltips::add_tooltip(loc,text);
}
} else if(text.empty() == false) {
font::pango_draw_text(&video,loc,label.font_size(),font::NORMAL_COLOR,text,loc.x,loc.y);
font::pango_draw_text(&video, loc, label.font_size(), text_color, text, loc.x, loc.y);
}
}
void display::draw_all_panels()