> 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.

# SharpDX.DirectWrite.TextFormat

Disclaimer: The **SharpDX SDK Reference** section was compiled from the official **SharpDX Documentation** and was NOT authored by NinjaTrader. The contents of this section are provided as-is and only cover a fraction of what is available from the SharpDX SDK. This page was intended only as a reference guide to help you get started with some of the 2D Graphics concepts used in the NinjaTrader.Custom assembly. Please refer to the official SharpDX Documentation for additional members not covered in this reference. For more seasoned graphic developers, the original MSDN **Direct2D1** and **DirectWrite** unmanaged API documentation can also be helpful for understanding the DirectX/Direct2D run-time environment. For NinjaScript development purposes, we document only essential members in the structure of this page.

## Definition

The `TextFormat` interface describes the font and paragraph properties used to format text, and it describes locale information.

(See also [unmanaged API documentation](https://msdn.microsoft.com/en-us/library/dd316628.aspx))

Notes:

1. These properties cannot be changed after the `TextFormat` object is created. To change these properties, a new `TextFormat` object must be created with the desired properties.
2. The **TextFormat** interface is used to draw text with a single format. To draw text with multiple formats, or to use a custom text renderer, use the [TextLayout](/developer/desktop-sdk/references/sharpdx/sharpdx-directwrite/sharpdx-directwrite-textlayout) interface. **TextLayout** enables the application to change the format for ranges of text within the string.
3. This object may not be thread-safe, and it may carry the state of text format change.
4. To draw simple text with a single format, Direct2D provides the [DrawText()](/developer/desktop-sdk/references/sharpdx/sharpdx-direct2d1/sharpdx-direct2d1-rendertarget/sharpdx-direct2d1-rendertarget-drawtext) method, which draws a string using the format information provided by a **TextFormat** object.

## Syntax

`class TextFormat`

## Constructors

| Constructor                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | Description                                                                              |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------- |
| `new TextFormat(Factory factory, string fontFamilyName, float fontSize)`                                                                                                                                                                                                                                                                                                                                                                                                       | Creates a text format object used for text layout with normal weight, style and stretch. |
| `new TextFormat(Factory factory, string fontFamilyName, [FontWeight](/developer/desktop-sdk/references/sharpdx/sharpdx-directwrite/sharpdx-directwrite-textformat-fontweight) fontWeight, [FontStyle](/developer/desktop-sdk/references/sharpdx/sharpdx-directwrite/sharpdx-directwrite-textformat-fontstyle) fontStyle, float fontSize)`                                                                                                                                      | Creates a text format object used for text layout with normal stretch.                   |
| `new TextFormat(Factory factory, string fontFamilyName, [FontWeight](/developer/desktop-sdk/references/sharpdx/sharpdx-directwrite/sharpdx-directwrite-textformat-fontweight) fontWeight, [FontStyle](/developer/desktop-sdk/references/sharpdx/sharpdx-directwrite/sharpdx-directwrite-textformat-fontstyle) fontStyle, [FontStretch](/developer/desktop-sdk/references/sharpdx/sharpdx-directwrite/sharpdx-directwrite-textformat-fontstretch) fontStretch, float fontSize)` | Creates a text format object used for text layout.                                       |

Tip: For NinjaScript development purposes, when creating a **TextFormat** object you should use the [NinjaTrader.Core.Globals.DirectWriteFactory](/developer/desktop-sdk/references/common/charts/rendering/directwritefactory) property.

## Methods and Properties

| Method/Property                                                                                                                       | Description                                                                                                                                                                                                     |
| ------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Dispose()](/developer/desktop-sdk/references/sharpdx/sharpdx-disposebase/sharpdx-disposebase-dispose)                                | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. (Inherited from [SharpDX.DisposeBase](/developer/desktop-sdk/references/sharpdx/sharpdx-disposebase).) |
| [FlowDirection](/developer/desktop-sdk/references/sharpdx/sharpdx-directwrite/sharpdx-directwrite-textformat-flowdirection)           | Gets or sets the direction that text lines flow.                                                                                                                                                                |
| [FontFamilyName](/developer/desktop-sdk/references/sharpdx/sharpdx-directwrite/sharpdx-directwrite-textformat-fontfamilyname)         | Creates a text format object used for text layout with normal weight, style and stretch.                                                                                                                        |
| [FontSize](/developer/desktop-sdk/references/sharpdx/sharpdx-directwrite/sharpdx-directwrite-textformat-fontsize)                     | Creates a text format object used for text layout with normal stretch.                                                                                                                                          |
| [FontStretch](/developer/desktop-sdk/references/sharpdx/sharpdx-directwrite/sharpdx-directwrite-textformat-fontstretch)               | Creates a text format object used for text layout.                                                                                                                                                              |
| [FontStyle](/developer/desktop-sdk/references/sharpdx/sharpdx-directwrite/sharpdx-directwrite-textformat-fontstyle)                   | Gets the font style of the text.                                                                                                                                                                                |
| [FontWeight](/developer/desktop-sdk/references/sharpdx/sharpdx-directwrite/sharpdx-directwrite-textformat-fontweight)                 | Gets the font weight of the text.                                                                                                                                                                               |
| [IsDisposed](/developer/desktop-sdk/references/sharpdx/sharpdx-disposebase/sharpdx-disposebase-isdisposed)                            | Gets a value indicating whether this instance is disposed. (Inherited from [SharpDX.DisposeBase](/developer/desktop-sdk/references/sharpdx/sharpdx-disposebase).)                                               |
| [ParagraphAlignment](/developer/desktop-sdk/references/sharpdx/sharpdx-directwrite/sharpdx-directwrite-textformat-paragraphalignment) | Gets or sets the alignment option of a paragraph which is relative to the top and bottom edges of a layout box.                                                                                                 |
| [ReadingDirection](/developer/desktop-sdk/references/sharpdx/sharpdx-directwrite/sharpdx-directwrite-textformat-readingdirection)     | Gets or sets the current reading direction for text in a paragraph.                                                                                                                                             |
| [TextAlignment](/developer/desktop-sdk/references/sharpdx/sharpdx-directwrite/sharpdx-directwrite-textformat-textalignment)           | Gets or sets the alignment option of text relative to the layout box's leading and trailing edge.                                                                                                               |
| [WordWrapping](/developer/desktop-sdk/references/sharpdx/sharpdx-directwrite/sharpdx-directwrite-textformat-wordwrapping)             | Gets or sets the word wrapping option.                                                                                                                                                                          |