aboutsummaryrefslogtreecommitdiff
path: root/CruUI/graph/graph.cpp
diff options
context:
space:
mode:
authorYuqian Yang <crupest@outlook.com>2018-09-23 16:48:18 +0000
committerYuqian Yang <crupest@outlook.com>2018-09-23 16:48:18 +0000
commit001e1d955132a02a2f7effc841ab9e5ee425eda1 (patch)
tree1bfbdcc2a25316d6e85cc9b4527a1ec15841b502 /CruUI/graph/graph.cpp
parent796ba6e1e816ec87a106f2f7b501e38c99f059e1 (diff)
parent9049f7674e0808cc3676543e0a95330a1657d10e (diff)
downloadcru-001e1d955132a02a2f7effc841ab9e5ee425eda1.tar.gz
cru-001e1d955132a02a2f7effc841ab9e5ee425eda1.tar.bz2
cru-001e1d955132a02a2f7effc841ab9e5ee425eda1.zip
Merge branch 'textboxdev' into 'master'
TextBox develop. See merge request crupest/CruUI!2
Diffstat (limited to 'CruUI/graph/graph.cpp')
-rw-r--r--CruUI/graph/graph.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/CruUI/graph/graph.cpp b/CruUI/graph/graph.cpp
index 94c7029e..30b51413 100644
--- a/CruUI/graph/graph.cpp
+++ b/CruUI/graph/graph.cpp
@@ -216,10 +216,30 @@ namespace cru {
ComPtr<ID2D1SolidColorBrush> CreateSolidBrush(const D2D1_COLOR_F& color)
{
- const auto device_context = graph::GraphManager::GetInstance()->GetD2D1DeviceContext();
+ const auto device_context = GraphManager::GetInstance()->GetD2D1DeviceContext();
ComPtr<ID2D1SolidColorBrush> solid_color_brush;
device_context->CreateSolidColorBrush(color, &solid_color_brush);
return solid_color_brush;
}
+
+ ComPtr<IDWriteTextFormat> CreateDefaultTextFormat()
+ {
+ const auto dwrite_factory = GraphManager::GetInstance()->GetDWriteFactory();
+
+ ComPtr<IDWriteTextFormat> text_format;
+
+ ThrowIfFailed(dwrite_factory->CreateTextFormat(
+ L"等线", nullptr,
+ DWRITE_FONT_WEIGHT_NORMAL,
+ DWRITE_FONT_STYLE_NORMAL,
+ DWRITE_FONT_STRETCH_NORMAL,
+ 24.0, L"zh-cn",
+ &text_format
+ ));
+
+ ThrowIfFailed(text_format->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER));
+ ThrowIfFailed(text_format->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER));
+ return text_format;
+ }
}
}