diff options
author | crupest <crupest@outlook.com> | 2019-04-04 17:12:25 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2019-04-04 17:12:25 +0800 |
commit | a410e2048db6f5ef6fb50e401a59b4b98b979050 (patch) | |
tree | 500680c63b074e8c3eefd756fd6a1d0f41840c1a /src/platform_win/win_text_layout.cpp | |
parent | fcaf471275a67d718887430ee63a53890915c4c7 (diff) | |
download | cru-a410e2048db6f5ef6fb50e401a59b4b98b979050.tar.gz cru-a410e2048db6f5ef6fb50e401a59b4b98b979050.tar.bz2 cru-a410e2048db6f5ef6fb50e401a59b4b98b979050.zip |
...
Diffstat (limited to 'src/platform_win/win_text_layout.cpp')
-rw-r--r-- | src/platform_win/win_text_layout.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/platform_win/win_text_layout.cpp b/src/platform_win/win_text_layout.cpp index 9915b56c..7ae87a80 100644 --- a/src/platform_win/win_text_layout.cpp +++ b/src/platform_win/win_text_layout.cpp @@ -30,6 +30,19 @@ void WinTextLayout::SetText(std::wstring new_text) { max_width_, max_height_, &text_layout_)); } +std::shared_ptr<FontDescriptor> WinTextLayout::GetFont() { + return font_descriptor_; +} + +void WinTextLayout::SetFont(std::shared_ptr<FontDescriptor> font) { + auto f = std::dynamic_pointer_cast<WinFontDescriptor>(font); + assert(f); + f.swap(font_descriptor_); + ThrowIfFailed(graph_manager_->GetDWriteFactory()->CreateTextLayout( + text_.c_str(), text_.size(), font_descriptor_->GetDWriteTextFormat(), + max_width_, max_height_, &text_layout_)); +} + void WinTextLayout::SetMaxWidth(float max_width) { max_width_ = max_width; ThrowIfFailed(text_layout_->SetMaxWidth(max_width_)); |