From 9a1627c2ff2251c2f796d82d4772166876232313 Mon Sep 17 00:00:00 2001 From: Neil Date: Tue, 20 Apr 2021 12:09:05 +1000 Subject: If text format creation fails, could be because of bad locale so try "en-us". --- win32/PlatWin.cxx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index 99c92434b..45523ff6e 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -313,6 +313,13 @@ struct FontDirectWrite : public FontWin { static_cast(fp.weight), style, DWRITE_FONT_STRETCH_NORMAL, fHeight, wsLocale.c_str(), &pTextFormat); + if (hr == E_INVALIDARG) { + // Possibly a bad locale name like "/" so try "en-us". + hr = pIDWriteFactory->CreateTextFormat(wsFace.c_str(), nullptr, + static_cast(fp.weight), + style, + DWRITE_FONT_STRETCH_NORMAL, fHeight, L"en-us", &pTextFormat); + } if (SUCCEEDED(hr)) { pTextFormat->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP); -- cgit v1.2.3