2
0
mirror of https://github.com/wolfpld/tracy synced 2026-01-19 04:52:09 +00:00

Replace narrow no-break space with no-break space in markdown text.

Nemotron 3 Nano outputs these spaces in the text. The currently used font
(or is it ImGui?) is not able to render this, and draws replacement character
instead.
This commit is contained in:
Bartosz Taudul
2026-01-05 13:35:51 +01:00
parent 1851743c9d
commit 711771bc27

View File

@@ -1,5 +1,6 @@
#include <assert.h>
#include <algorithm>
#include <string>
#include "TracyPrint.hpp"
#include "TracyImGui.hpp"
@@ -131,7 +132,18 @@ bool PrintTextWrapped( const char* text, const char* end )
{
bool hovered = false;
// Replace narrow no-break space with no-break space
if( !end ) end = text + strlen( text );
std::string buf( text, end );
auto found = buf.find( "\xe2\x80\xaf" );
while( found != std::string::npos )
{
buf.replace( found, 3, "\xc2\xa0" );
found = buf.find( "\xe2\x80\xaf", found );
}
text = buf.c_str();
end = text + buf.size();
auto firstWord = text;
while( firstWord < end && *firstWord != ' ' && *firstWord != '\n' ) firstWord++;