diff options
author | crupest <crupest@outlook.com> | 2019-04-02 22:20:59 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2019-04-02 22:20:59 +0800 |
commit | d732b99cd1436144d4625382954eb4a1cf832a1f (patch) | |
tree | 7de3464c06b0ebdb613807ac67c7cd3dda2bb4ac /src | |
parent | ec201783e4b4733770648c2f92c3ffb9629bb7f7 (diff) | |
download | cru-d732b99cd1436144d4625382954eb4a1cf832a1f.tar.gz cru-d732b99cd1436144d4625382954eb4a1cf832a1f.tar.bz2 cru-d732b99cd1436144d4625382954eb4a1cf832a1f.zip |
...
Diffstat (limited to 'src')
-rw-r--r-- | src/platform_win/win_font.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/platform_win/win_font.cpp b/src/platform_win/win_font.cpp index ddc42556..e0a309cc 100644 --- a/src/platform_win/win_font.cpp +++ b/src/platform_win/win_font.cpp @@ -1,6 +1,22 @@ #include "cru/platform/win/win_font.hpp" +#include "cru/platform/win/exception.hpp" +#include "cru/platform/win/graph_manager.hpp" + +#include <array> #include <utility> namespace cru::platform::win { +WinFontDescriptor::WinFontDescriptor(GraphManager* graph_manager, + const std::wstring_view& font_family, + float font_size) { + std::array<wchar_t, LOCALE_NAME_MAX_LENGTH> buffer; + if (!::GetUserDefaultLocaleName(buffer.data(), buffer.size())) + throw Win32Error(::GetLastError(), "Failed to get locale."); + + ThrowIfFailed(graph_manager->GetDWriteFactory()->CreateTextFormat( + font_family.data(), nullptr, DWRITE_FONT_WEIGHT_NORMAL, + DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, font_size, + buffer.data(), &text_format_)); +} } // namespace cru::platform::win |