Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Misc: fix typo in comments; align code.
  • Loading branch information
cyx2015s committed Jul 27, 2025
commit f01e4457675b5a32013920573156d7e79b18ff9c
6 changes: 3 additions & 3 deletions imgui_draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5368,7 +5368,7 @@ const char* ImFont::CalcWordWrapPosition(float size, const char* text, const cha
// Chinese punctuations are merged into nearby characters.
// [《短][歌][行》][曹][操:][对][酒][当][歌,][人][生][几][何!][譬][如][朝][露,][去][日][苦][多……]
// English words are separated even if no spaces are inserted.
// [ImGui][是][即][使][模][式][的][界][面][框][架。]
// [ImGui][是][即][][模][式][的][界][面][框][架。]

ImFontBaked* baked = GetFontBaked(size);
const float scale = size / baked->Size;
Expand Down Expand Up @@ -5451,14 +5451,14 @@ const char* ImFont::CalcWordWrapPosition(float size, const char* text, const cha
prev_word_end = word_end;
word_end = next_s;
}
else if (0x3003 <= c && c <= 0xFFFF)
else if (0x3003 <= c && c <= 0xFFFF)
{
line_width += word_width + blank_width;
word_width = blank_width = 0.0f;
inside_word = true;
if ((!last_char_is_init && 0x3003 <= c && c <= 0xFFFF) || !last_char_is_cjk)
prev_word_end = s;
}
}
// CJK characters are not separated by spaces, so we treat them as a single word.
// This is a very simple heuristic, but it works for most cases.
last_char_is_cjk = 0x3003 <= c && c <= 0xFFFF;
Expand Down
4 changes: 2 additions & 2 deletions imgui_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -404,11 +404,11 @@ inline bool ImCharIsBlankW(unsigned int c) { return c == ' ' || c =
// Terminators: Chinese punctuations that should not appear at the start of line.
// Only include characters can be typed within 1 or 2 hits on a standard Chinese keyboard.
// List: ~!)】、:;’”,。》」?
inline bool ImCharIsTermW(unsigned int c) { return c == 0xff5e || c == 0xff01 || c == 0xff09 || c == 0x3011 || c == 0x3001 || c == 0xff1a || c == 0xff1b || c == 0x2019 || c == 0x201d || c == 0xff0c || c == 0x3002 || c == 0x300b || c == 0x300d || c == 0xff1f; }
inline bool ImCharIsTermW(unsigned int c) { return c == 0xff5e || c == 0xff01 || c == 0xff09 || c == 0x3011 || c == 0x3001 || c == 0xff1a || c == 0xff1b || c == 0x2019 || c == 0x201d || c == 0xff0c || c == 0x3002 || c == 0x300b || c == 0x300d || c == 0xff1f; }
// Initializers: Chinese punctuations that should not appear at the end of line.
// Only include characters can be typed within 1 or 2 hits on a standard Chinese keyboard.
// List: (【《「
inline bool ImCharIsInitW(unsigned int c) { return c == 0xff08 || c == 0x3010 || c == 0x300a || c == 0x300c; }
inline bool ImCharIsInitW(unsigned int c) { return c == 0xff08 || c == 0x3010 || c == 0x300a || c == 0x300c; }
inline bool ImCharIsXdigitA(char c) { return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f'); }
IM_MSVC_RUNTIME_CHECKS_RESTORE

Expand Down