aboutsummaryrefslogtreecommitdiff
path: root/CruUI/graph
diff options
context:
space:
mode:
Diffstat (limited to 'CruUI/graph')
-rw-r--r--CruUI/graph/graph.cpp22
-rw-r--r--CruUI/graph/graph.h1
2 files changed, 22 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;
+ }
}
}
diff --git a/CruUI/graph/graph.h b/CruUI/graph/graph.h
index 01d95797..0f1d29d1 100644
--- a/CruUI/graph/graph.h
+++ b/CruUI/graph/graph.h
@@ -166,6 +166,7 @@ namespace cru
}
Microsoft::WRL::ComPtr<ID2D1SolidColorBrush> CreateSolidBrush(const D2D1_COLOR_F& color);
+ Microsoft::WRL::ComPtr<IDWriteTextFormat> CreateDefaultTextFormat();
inline void WithTransform(ID2D1DeviceContext* device_context, const D2D1_MATRIX_3X2_F matrix, Function<void(ID2D1DeviceContext*)>&& action)
{