aboutsummaryrefslogtreecommitdiff
path: root/src/win/graph/direct/Font.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-07-05 23:06:02 +0800
committercrupest <crupest@outlook.com>2020-07-05 23:06:02 +0800
commit5c805e494425a88da1813902b1ad8a1ab351e30d (patch)
treebe3cfd96dcac19db3e256d610d48b5083c489a6c /src/win/graph/direct/Font.cpp
parentbbec59718bf8a824583869126762013112f8e568 (diff)
downloadcru-5c805e494425a88da1813902b1ad8a1ab351e30d.tar.gz
cru-5c805e494425a88da1813902b1ad8a1ab351e30d.tar.bz2
cru-5c805e494425a88da1813902b1ad8a1ab351e30d.zip
...
Diffstat (limited to 'src/win/graph/direct/Font.cpp')
-rw-r--r--src/win/graph/direct/Font.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/win/graph/direct/Font.cpp b/src/win/graph/direct/Font.cpp
index edbbc59d..34de5b71 100644
--- a/src/win/graph/direct/Font.cpp
+++ b/src/win/graph/direct/Font.cpp
@@ -2,15 +2,14 @@
#include "cru/win/graph/direct/Exception.hpp"
#include "cru/win/graph/direct/Factory.hpp"
-#include "cru/win/String.hpp"
#include <array>
#include <utility>
namespace cru::platform::graph::win::direct {
-DWriteFont::DWriteFont(DirectGraphFactory* factory,
- const std::string_view& font_family, float font_size)
- : DirectGraphResource(factory) {
+DWriteFont::DWriteFont(DirectGraphFactory* factory, std::u16string font_family,
+ float font_size)
+ : DirectGraphResource(factory), font_family_(std::move(font_family)) {
// Get locale
std::array<wchar_t, LOCALE_NAME_MAX_LENGTH> buffer;
if (!::GetUserDefaultLocaleName(buffer.data(),
@@ -18,10 +17,9 @@ DWriteFont::DWriteFont(DirectGraphFactory* factory,
throw platform::win::Win32Error(
::GetLastError(), "Failed to get locale when create dwrite font.");
- const std::wstring&& wff = cru::platform::win::ToUtf16String(font_family);
-
ThrowIfFailed(factory->GetDWriteFactory()->CreateTextFormat(
- wff.data(), nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL,
+ reinterpret_cast<const wchar_t*>(font_family_.c_str()), nullptr,
+ DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL,
DWRITE_FONT_STRETCH_NORMAL, font_size, buffer.data(), &text_format_));
ThrowIfFailed(text_format_->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_LEADING));