ToDirectWriteTextFormat()

View as Markdown

Definition

Converts a SimpleFont object to a SharpDX compatible font which can be used for chart rendering.

For more information please see the educational resource on Using SharpDX for Custom Chart Rendering.

Method Return Value

A DirectWrite.TextFormat object

The returned DirectWrite.TextFormat object should be disposed of immediately when finished drawing text.

Syntax

\<simplefont\>.ToDirectWriteTextFormat()

Examples

1protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
2{
3 // Set text to chart label simple font object
4 SharpDX.DirectWrite.TextFormat textFormat = chartControl.Properties.LabelFont.ToDirectWriteTextFormat();
5
6 // use the textFormat in a RenderTarget.DrawText() or DrawTextLayout() method
7
8 // do not forget to dispose text format when finished
9 textFormat.Dispose();
10}