Add support for SFML utf8 strings
Some checks failed
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:linux32 flags:32 name:Linux GCC 32 os:ubuntu-latest]) (push) Has been cancelled
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:linux64 flags:64 name:Linux GCC x64 os:ubuntu-latest]) (push) Has been cancelled
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:linuxarm32 flags:arm32 name:Linux GCC ARM 32 os:ubuntu-latest]) (push) Has been cancelled
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:linuxarm64 flags:arm64 name:Linux GCC ARM 64 os:ubuntu-latest]) (push) Has been cancelled
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:macos name:macOS Apple Silicon os:macos-14]) (push) Has been cancelled
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:win32 flags:-A Win32 name:Windows VS2022 Win32 os:windows-2022]) (push) Has been cancelled
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:win64 flags:-A x64 name:Windows VS2022 x64 os:windows-2022]) (push) Has been cancelled
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:winarm64 flags:-A ARM64 name:Windows VS2022 ARM os:windows-2022]) (push) Has been cancelled
CD / Create Pi Mono Setup (push) Has been cancelled
CD / Publishing (push) Has been cancelled

This commit is contained in:
Lorenzooone
2025-04-17 21:40:35 +02:00
parent 403355ce13
commit 33660b3ef7
4 changed files with 18 additions and 8 deletions

View File

@@ -153,9 +153,13 @@ void TextRectangle::reset_data(TextData &data) {
data.pos_y = 0;
}
static sf::String convert_to_utf8(const std::string &str) {
return sf::String::fromUtf8(str.begin(), str.end());
}
void TextRectangle::setTextWithLineWrapping(int x_limit) {
if(x_limit == 0) {
this->actual_text.setString(this->loaded_data.printed_text);
this->actual_text.setString(convert_to_utf8(this->loaded_data.printed_text));
return;
}
bool is_done = false;
@@ -173,7 +177,7 @@ void TextRectangle::setTextWithLineWrapping(int x_limit) {
}
for(size_t i = pos; i < space_pos; i++)
curr_text += this->loaded_data.printed_text[i];
this->actual_text.setString(curr_text);
this->actual_text.setString(convert_to_utf8(curr_text));
sf::FloatRect globalBounds = this->actual_text.getGlobalBounds();
int bounds_width = (int)(globalBounds.size.x + (globalBounds.position.x * 2));
if(line_started && (bounds_width > x_limit)) {
@@ -185,7 +189,7 @@ void TextRectangle::setTextWithLineWrapping(int x_limit) {
line_started = true;
new_text = curr_text;
}
this->actual_text.setString(new_text);
this->actual_text.setString(convert_to_utf8(new_text));
}
void TextRectangle::setRealSize(int width, int height, bool check_previous) {