From bab66e8542c9f6ccfe7d19dda8e44fd7b4d7bb83 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 10 Dec 2017 14:05:49 -0800 Subject: [PATCH] Windows: Fix UI text measurements with &. These APIs don't take into account &&, which caused Homebrew && Demos to be too wide. --- ext/native/gfx_es2/draw_text_win.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/native/gfx_es2/draw_text_win.cpp b/ext/native/gfx_es2/draw_text_win.cpp index 491e906625..0476bd564e 100644 --- a/ext/native/gfx_es2/draw_text_win.cpp +++ b/ext/native/gfx_es2/draw_text_win.cpp @@ -132,7 +132,7 @@ void TextDrawerWin32::MeasureString(const char *str, size_t len, float *w, float } SIZE size; - std::wstring wstr = ConvertUTF8ToWString(ReplaceAll(std::string(str, len), "\n", "\r\n")); + std::wstring wstr = ConvertUTF8ToWString(ReplaceAll(ReplaceAll(std::string(str, len), "\n", "\r\n"), "&&", "&")); GetTextExtentPoint32(ctx_->hDC, wstr.c_str(), (int)wstr.size(), &size); entry = new TextMeasureEntry(); @@ -171,7 +171,7 @@ void TextDrawerWin32::MeasureStringRect(const char *str, size_t len, const Bound entry = iter->second.get(); } else { SIZE size; - std::wstring wstr = ConvertUTF8ToWString(lines[i].length() == 0 ? " " : lines[i]); + std::wstring wstr = ConvertUTF8ToWString(lines[i].length() == 0 ? " " : ReplaceAll(lines[i], "&&", "&")); GetTextExtentPoint32(ctx_->hDC, wstr.c_str(), (int)wstr.size(), &size); entry = new TextMeasureEntry();