Fix rendering UTF-8 text
This commit is contained in:
@@ -1130,7 +1130,7 @@ void print_buf () {
|
||||
line_style.applyTo(text, get_ui_scale());
|
||||
// A spacing factor of 1.0 within multiline messages doesn't actually line up with other single buffer lines
|
||||
text.setLineSpacing(0.85);
|
||||
text.setString(message);
|
||||
text.setString(sf::String::fromUtf8(message.begin(), message.end()));
|
||||
text.setPosition(moveTo);
|
||||
draw_scale_aware_text(text_area_gworld(), text);
|
||||
}
|
||||
|
@@ -125,7 +125,7 @@ break_info_t calculate_line_wrapping(rectangle dest_rect, std::string str, TextS
|
||||
short str_len = str.length();
|
||||
unsigned short last_line_break = 0,last_word_break = 0;
|
||||
|
||||
str_to_draw.setString(str);
|
||||
str_to_draw.setString(sf::String::fromUtf8(str.begin(), str.end()));
|
||||
|
||||
// Even if the text is only one line, break_info is required for calculating word boundaries.
|
||||
// So we can't skip the rest of this.
|
||||
@@ -263,7 +263,7 @@ static void win_draw_string(sf::RenderTarget& dest_window,rectangle dest_rect,st
|
||||
for(auto it : substitutions){
|
||||
boost::replace_all(str, it.first, it.second);
|
||||
}
|
||||
str_to_draw.setString(str);
|
||||
str_to_draw.setString(sf::String::fromUtf8(str.begin(), str.end()));
|
||||
short total_width = str_to_draw.getLocalBounds().width;
|
||||
|
||||
options.style.applyTo(str_to_draw, get_ui_scale());
|
||||
@@ -337,7 +337,7 @@ static void win_draw_string(sf::RenderTarget& dest_window,rectangle dest_rect,st
|
||||
}
|
||||
|
||||
for(auto& snippet : options.snippets) {
|
||||
str_to_draw.setString(snippet.text);
|
||||
str_to_draw.setString(sf::String::fromUtf8(snippet.text.begin(), snippet.text.end()));
|
||||
str_to_draw.setPosition(snippet.at);
|
||||
if(snippet.hilited) {
|
||||
rectangle bounds = str_to_draw.getGlobalBounds();
|
||||
@@ -409,7 +409,7 @@ size_t string_length(std::string str, const TextStyle& style, short* height){
|
||||
|
||||
sf::Text text;
|
||||
style.applyTo(text);
|
||||
text.setString(str);
|
||||
text.setString(sf::String::fromUtf8(str.begin(), str.end()));
|
||||
total_width = text.getLocalBounds().width;
|
||||
if(strings_to_cache.count(str)){
|
||||
location measurement;
|
||||
|
Reference in New Issue
Block a user