diff options
author | Neil <nyamatongwe@gmail.com> | 2020-07-17 21:53:27 +1000 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2020-07-17 21:53:27 +1000 |
commit | b4460b84a287b57257488a6a227eec5c47130de4 (patch) | |
tree | aff7bd1eaeb0c7abdbf297808f62d72a722cdc73 /win32/PlatWin.cxx | |
parent | 7e11c5a4fbe6ad02c0b8e7464eef9c37b594b98c (diff) | |
download | scintilla-mirror-b4460b84a287b57257488a6a227eec5c47130de4.tar.gz |
Tidied up code using wstring, which will often avoid allocating, and fixing
variable names.
Diffstat (limited to 'win32/PlatWin.cxx')
-rw-r--r-- | win32/PlatWin.cxx | 18 |
1 files 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<FormatAndMetrics *>(screenLine->FontOfPosition(bytePosition)->GetID()); const unsigned int fontFamilyNameSize = pfm->pTextFormat->GetFontFamilyNameLength(); - std::vector<WCHAR> 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<WCHAR> 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); |