From a09fe66e667ed2b91a4c953e74cf6b1abaaa919f Mon Sep 17 00:00:00 2001 From: Neil Date: Wed, 20 Mar 2019 19:18:57 +1100 Subject: Implement WStringFromUTF8 to simplify code that creates wstring objects for regular expressions and calling the Win32 API. --- win32/PlatWin.cxx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'win32') diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index e407bd630..766c91ef9 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] = L""; - UTF16FromUTF8(fp.faceName, wszFace, faceSize); + const std::wstring wsFace = WStringFromUTF8(fp.faceName); 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(fp.weight), style, DWRITE_FONT_STRETCH_NORMAL, fHeight, L"en-us", &pTextFormat); -- cgit v1.2.3