Skip to content

Commit

Permalink
ui: Fix ThemeWML [label] text_rgb= being horribly broken
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
irydacea committed Mar 13, 2021
1 parent a0d1896 commit 45ca791
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
1 change: 1 addition & 0 deletions changelog.md
Expand Up @@ -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.14’s tag names in `[terrain_defaults]` (issue #5308).
* Replaced legacy SDL_ttf/FriBidi-based font rendering used in old GUI1 code paths with Pango.
Expand Down
18 changes: 3 additions & 15 deletions src/display.cpp
Expand Up @@ -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());

Expand All @@ -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()
Expand Down

0 comments on commit 45ca791

Please sign in to comment.