add explanation for special gylph characters

This commit is contained in:
DeaTh-G 2025-02-20 19:41:32 +01:00
parent 9c18a020c6
commit 7ed27be066
2 changed files with 9 additions and 2 deletions

View file

@ -257,7 +257,10 @@ static bool FontBuilder_Build(ImFontAtlas* atlas)
v0 / packer.height, v0 / packer.height,
advance); advance);
} }
// Used as a zero-width helper for automatic line breaks.
// This is useful for languages like Japanese to separate 'words'
// so that they don't get split mid-kana by the automatic splitter.
config.DstFont->AddGlyph( config.DstFont->AddGlyph(
&config, &config,
0x200B, 0x200B,
@ -271,6 +274,10 @@ static bool FontBuilder_Build(ImFontAtlas* atlas)
0.0f, 0.0f,
0.0f); 0.0f);
// A duplicate of the normal width space character.
// Overrides the unicode Four-Per-Em Space character.
// This can be used to add visual spacers that are ignored
// by the automatic line splitting logic.
config.DstFont->AddGlyph( config.DstFont->AddGlyph(
&config, &config,
0x2005, 0x2005,

View file

@ -680,7 +680,7 @@ void DrawRubyAnnotatedText(const ImFont* font, float fontSize, float maxWidth, c
for (auto& line : lines) for (auto& line : lines)
{ {
line = ReAddRubyAnnotations(line, input.second); line = ReAddRubyAnnotations(line, input.second);
if (!line.empty() && line.substr(0, 3) != "「" && leadingSpace) if (!line.empty() && line.substr(0, 3) != "" && leadingSpace)
{ {
line.insert(0, " "); line.insert(0, " ");
} }