From a410e2048db6f5ef6fb50e401a59b4b98b979050 Mon Sep 17 00:00:00 2001 From: crupest Date: Thu, 4 Apr 2019 17:12:25 +0800 Subject: ... --- src/platform_win/win_text_layout.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/platform_win/win_text_layout.cpp') 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 WinTextLayout::GetFont() { + return font_descriptor_; +} + +void WinTextLayout::SetFont(std::shared_ptr font) { + auto f = std::dynamic_pointer_cast(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_)); -- cgit v1.2.3