diff options
| author | Neil <nyamatongwe@gmail.com> | 2019-03-20 19:18:57 +1100 |
|---|---|---|
| committer | Neil <nyamatongwe@gmail.com> | 2019-03-20 19:18:57 +1100 |
| commit | 31a735c8ec0a4f7c62b162cd1c173bfef76737c5 (patch) | |
| tree | e7a3ad283f5b7c44d79cfbcdb78d8cdf34b68bf2 /win32 | |
| parent | 4ac748ba2238d3abd5227918d8174507d8fa3ec1 (diff) | |
| download | scintilla-mirror-31a735c8ec0a4f7c62b162cd1c173bfef76737c5.tar.gz | |
Backport: Implement WStringFromUTF8 to simplify code that creates wstring objects for
regular expressions and calling the Win32 API.
Backport of changeset 7325:6148329fb2f3, but replaced std::string_view usage
with const char* and size_t components. Also used #ifdef instead of C++17
`if constexpr` at suggestion of Neil.
Diffstat (limited to 'win32')
| -rw-r--r-- | win32/PlatWin.cxx | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index 20fcdbfd4..2c54cd8dd 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -296,12 +296,10 @@ FontID CreateFontFromParameters(const FontParameters &fp) { } else { #if defined(USE_D2D) IDWriteTextFormat *pTextFormat = nullptr; - const int faceSize = 200; - WCHAR wszFace[faceSize]; - UTF16FromUTF8(fp.faceName, strlen(fp.faceName)+1, wszFace, faceSize); + const std::wstring wsFace = WStringFromUTF8(fp.faceName, strlen(fp.faceName) + 1); const FLOAT fHeight = fp.size; const DWRITE_FONT_STYLE style = fp.italic ? DWRITE_FONT_STYLE_ITALIC : DWRITE_FONT_STYLE_NORMAL; - HRESULT hr = pIDWriteFactory->CreateTextFormat(wszFace, nullptr, + HRESULT hr = pIDWriteFactory->CreateTextFormat(wsFace.c_str(), nullptr, static_cast<DWRITE_FONT_WEIGHT>(fp.weight), style, DWRITE_FONT_STRETCH_NORMAL, fHeight, L"en-us", &pTextFormat); |
