diff options
| author | crupest <crupest@outlook.com> | 2020-06-28 00:03:11 +0800 |
|---|---|---|
| committer | crupest <crupest@outlook.com> | 2020-06-28 00:03:11 +0800 |
| commit | 06d1d0442276a05b6caad6e3468f4afb1e8ee5df (patch) | |
| tree | ebd46f0fb7343dc57bf947b7b5fffc139c3ddeac /src/win/graph/direct/font.cpp | |
| parent | e11be6caa9ef9b2b198ca61846e32f469627556e (diff) | |
| download | cru-06d1d0442276a05b6caad6e3468f4afb1e8ee5df.tar.gz cru-06d1d0442276a05b6caad6e3468f4afb1e8ee5df.tar.bz2 cru-06d1d0442276a05b6caad6e3468f4afb1e8ee5df.zip | |
...
Diffstat (limited to 'src/win/graph/direct/font.cpp')
| -rw-r--r-- | src/win/graph/direct/font.cpp | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/src/win/graph/direct/font.cpp b/src/win/graph/direct/font.cpp deleted file mode 100644 index edbbc59d..00000000 --- a/src/win/graph/direct/font.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "cru/win/graph/direct/Font.hpp" - -#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) { - // Get locale - std::array<wchar_t, LOCALE_NAME_MAX_LENGTH> buffer; - if (!::GetUserDefaultLocaleName(buffer.data(), - static_cast<int>(buffer.size()))) - 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, - DWRITE_FONT_STRETCH_NORMAL, font_size, buffer.data(), &text_format_)); - - ThrowIfFailed(text_format_->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_LEADING)); - ThrowIfFailed( - text_format_->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_NEAR)); -} - -float DWriteFont::GetFontSize() { return text_format_->GetFontSize(); } -} // namespace cru::platform::graph::win::direct |
