> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.ninjatrader.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.ninjatrader.com/_mcp/server.

# ToDirectWriteTextFormat()

## 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](/developer/desktop-sdk/guides/educational-resources/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

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