Skip to content

Commit

Permalink
TextBox: Fix cannot get string length on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
xfangfang committed Apr 30, 2023
1 parent 8285099 commit dd6ca7c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions wiliwili/source/view/text_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ RichTextData richTextBreakLines(NVGcontext* ctx, float x, float y,
std::string currentText =
text.substr(row->start - stringStart, row->end - row->start);
auto firstLine =
std::wstring_convert<std::codecvt_utf8<wchar_t>>().from_bytes(
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>>().from_bytes(
currentText);
if (firstLine.length() == 1 && row->width / 2 + sx > breakRowWidth) {
// 只有一个字符且宽度超出了范围
Expand Down Expand Up @@ -175,7 +175,8 @@ float TextBox::cutRichTextLines(float width) {
&lx, &ly);
lx += t->r_margin;
if (rows.empty()) {
// todo:一般是一堆空格,暂时忽视
// 应该不会出现这种情况
brls::Logger::error("TextBox: got empty line: {}", t->text);
} else if (rows.size() == 1) {
tempData.emplace_back(rows[0]);
} else {
Expand Down

0 comments on commit dd6ca7c

Please sign in to comment.