@@ -4408,11 +4408,21 @@ static void ImFontBaked_BuildGrowIndex(ImFontBaked* baked, int new_size)
4408
4408
baked->IndexLookup .resize (new_size, IM_FONTGLYPH_INDEX_UNUSED);
4409
4409
}
4410
4410
4411
- static void ImFontAtlas_FontHookRemapCodepoint (ImFontAtlas* atlas, ImFont* font, ImWchar* c)
4411
+ static ImWchar ImFontAtlas_FontHookRemapCodepoint (ImFontAtlas* atlas, ImFont* font, ImWchar c)
4412
4412
{
4413
4413
IM_UNUSED (atlas);
4414
4414
if (font->RemapPairs .Data .Size != 0 )
4415
- *c = (ImWchar)font->RemapPairs .GetInt ((ImGuiID)*c, (int )*c);
4415
+ {
4416
+ const ImWchar remap_c = (ImWchar)font->RemapPairs .GetInt ((ImGuiID)c, 0 );
4417
+ if (remap_c != 0 )
4418
+ return remap_c;
4419
+ }
4420
+
4421
+ // Handle non-breaking spaces. The non-breaking space isn't handled by ImCharIsBlankW(),
4422
+ // so word wrapping should behave correctly if we remap it to a regular space here.
4423
+ // MacOS likes to use NNBSP in formatting, so need to handle that here. Strictly speaking,
4424
+ // it should be narrower, but it doesn't exist in our fonts so shrug.
4425
+ return (c == 0x00A0 || c == 0x202F ) ? ImWchar (' ' ) : c; // NBSP/NNBSP
4416
4426
}
4417
4427
4418
4428
static ImFontGlyph* ImFontBaked_BuildLoadGlyph (ImFontBaked* baked, ImWchar codepoint)
@@ -4429,7 +4439,7 @@ static ImFontGlyph* ImFontBaked_BuildLoadGlyph(ImFontBaked* baked, ImWchar codep
4429
4439
4430
4440
// User remapping hooks
4431
4441
ImWchar src_codepoint = codepoint;
4432
- ImFontAtlas_FontHookRemapCodepoint (atlas, font, & codepoint);
4442
+ codepoint = ImFontAtlas_FontHookRemapCodepoint (atlas, font, codepoint);
4433
4443
4434
4444
// char utf8_buf[5];
4435
4445
// IMGUI_DEBUG_LOG("[font] BuildLoadGlyph U+%04X (%s)\n", (unsigned int)codepoint, ImTextCharToUtf8(utf8_buf, (unsigned int)codepoint));
@@ -5195,7 +5205,7 @@ bool ImFontBaked::IsGlyphLoaded(ImWchar c)
5195
5205
bool ImFont::IsGlyphInFont (ImWchar c)
5196
5206
{
5197
5207
ImFontAtlas* atlas = ContainerAtlas;
5198
- ImFontAtlas_FontHookRemapCodepoint (atlas, this , & c);
5208
+ c = ImFontAtlas_FontHookRemapCodepoint (atlas, this , c);
5199
5209
for (ImFontConfig* src : Sources)
5200
5210
{
5201
5211
const ImFontLoader* loader = src->FontLoader ? src->FontLoader : atlas->FontLoader ;
0 commit comments