From b4460b84a287b57257488a6a227eec5c47130de4 Mon Sep 17 00:00:00 2001 From: Neil Date: Fri, 17 Jul 2020 21:53:27 +1000 Subject: Tidied up code using wstring, which will often avoid allocating, and fixing variable names. --- win32/PlatWin.cxx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index a4bda5432..38e19c6ac 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -1833,21 +1833,21 @@ void ScreenLineLayout::FillTextLayoutFormats(const IScreenLine *screenLine, IDWr static_cast(screenLine->FontOfPosition(bytePosition)->GetID()); const unsigned int fontFamilyNameSize = pfm->pTextFormat->GetFontFamilyNameLength(); - std::vector fontFamilyName(fontFamilyNameSize + 1); - - pfm->pTextFormat->GetFontFamilyName(fontFamilyName.data(), fontFamilyNameSize + 1); - textLayout->SetFontFamilyName(fontFamilyName.data(), textRange); + std::wstring fontFamilyName(fontFamilyNameSize, 0); + const HRESULT hrFamily = pfm->pTextFormat->GetFontFamilyName(fontFamilyName.data(), fontFamilyNameSize + 1); + if (SUCCEEDED(hrFamily)) { + textLayout->SetFontFamilyName(fontFamilyName.c_str(), textRange); + } textLayout->SetFontSize(pfm->pTextFormat->GetFontSize(), textRange); textLayout->SetFontWeight(pfm->pTextFormat->GetFontWeight(), textRange); textLayout->SetFontStyle(pfm->pTextFormat->GetFontStyle(), textRange); - const unsigned int localNameSize = pfm->pTextFormat->GetLocaleNameLength(); - std::vector localName(localNameSize + 1); - - const HRESULT hrLocale = pfm->pTextFormat->GetLocaleName(localName.data(), localNameSize + 1); + const unsigned int localeNameSize = pfm->pTextFormat->GetLocaleNameLength(); + std::wstring localeName(localeNameSize, 0); + const HRESULT hrLocale = pfm->pTextFormat->GetLocaleName(localeName.data(), localeNameSize + 1); if (SUCCEEDED(hrLocale)) { - textLayout->SetLocaleName(localName.data(), textRange); + textLayout->SetLocaleName(localeName.c_str(), textRange); } textLayout->SetFontStretch(pfm->pTextFormat->GetFontStretch(), textRange); -- cgit v1.2.3