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

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 `TextLayout` interface represents a block of text after it has been fully analyzed and formatted.

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

To draw a formatted string represented by a **TextLayout** object, Direct2D provides the **DrawTextLayout** method.

## Syntax

`class TextLayout`

## Constructors

| Constructor                                                                                                                                                                                            | Description                                                                                                                              |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `new `TextLayout(Factory factory, string text, [TextFormat](/developer/desktop-sdk/references/sharpdx/sharpdx-directwrite/sharpdx-directwrite-textformat) textFormat, float maxWidth, float maxHeight) | Takes a string, text format, and associated constraints, and produces an object that represents the fully analyzed and formatted result. |

Tip: For NinjaScript development purposes, when creating a **TextLayout** 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. (Inherited from [**TextFormat**](/developer/desktop-sdk/references/sharpdx/sharpdx-directwrite/sharpdx-directwrite-textformat).)                                                                |
| [**FontFamilyName**](/developer/desktop-sdk/references/sharpdx/sharpdx-directwrite/sharpdx-directwrite-textformat-fontfamilyname)         | Gets a copy of the font family name. (Inherited from [**TextFormat**](/developer/desktop-sdk/references/sharpdx/sharpdx-directwrite/sharpdx-directwrite-textformat).)                                                                            |
| [**FontSize**](/developer/desktop-sdk/references/sharpdx/sharpdx-directwrite/sharpdx-directwrite-textformat-fontsize)                     | Gets the font size in DIP units. (Inherited from [**TextFormat**](/developer/desktop-sdk/references/sharpdx/sharpdx-directwrite/sharpdx-directwrite-textformat).)                                                                                |
| [**FontStretch**](/developer/desktop-sdk/references/sharpdx/sharpdx-directwrite/sharpdx-directwrite-textformat-fontstretch)               | Gets the font stretch of the text. (Inherited from [**TextFormat**](/developer/desktop-sdk/references/sharpdx/sharpdx-directwrite/sharpdx-directwrite-textformat).)                                                                              |
| [**FontStyle**](/developer/desktop-sdk/references/sharpdx/sharpdx-directwrite/sharpdx-directwrite-textformat-fontstyle)                   | Gets the font style of the text. (Inherited from [**TextFormat**](/developer/desktop-sdk/references/sharpdx/sharpdx-directwrite/sharpdx-directwrite-textformat).)                                                                                |
| [**FontWeight**](/developer/desktop-sdk/references/sharpdx/sharpdx-directwrite/sharpdx-directwrite-textformat-fontweight)                 | Gets the font weight of the text. (Inherited from [**TextFormat**](/developer/desktop-sdk/references/sharpdx/sharpdx-directwrite/sharpdx-directwrite-textformat).)                                                                               |
| [**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).)                                                                            |
| [**MaxHeight**](/developer/desktop-sdk/references/sharpdx/sharpdx-directwrite/sharpdx-directwrite-textlayout-maxheight)                   | Gets or sets the layout maximum height.                                                                                                                                                                                                          |
| [**MaxWidth**](/developer/desktop-sdk/references/sharpdx/sharpdx-directwrite/sharpdx-directwrite-textlayout-maxwidth)                     | Gets or sets the layout maximum width.                                                                                                                                                                                                           |
| [**Metrics**](/developer/desktop-sdk/references/sharpdx/sharpdx-directwrite/sharpdx-directwrite-textlayout-metrics)                       | Contains the metrics associated with text after layout. All coordinates are in device independent pixels (DIPs).                                                                                                                                 |
| [**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. (Inherited from [**TextFormat**](/developer/desktop-sdk/references/sharpdx/sharpdx-directwrite/sharpdx-directwrite-textformat).) |
| [**ReadingDirection**](/developer/desktop-sdk/references/sharpdx/sharpdx-directwrite/sharpdx-directwrite-textformat-readingdirection)     | Gets or sets the current reading direction for text in a paragraph. (Inherited from [**TextFormat**](/developer/desktop-sdk/references/sharpdx/sharpdx-directwrite/sharpdx-directwrite-textformat).)                                             |
| [**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. (Inherited from [**TextFormat**](/developer/desktop-sdk/references/sharpdx/sharpdx-directwrite/sharpdx-directwrite-textformat).)               |
| [**WordWrapping**](/developer/desktop-sdk/references/sharpdx/sharpdx-directwrite/sharpdx-directwrite-textformat-wordwrapping)             | Gets or sets the word wrapping option. (Inherited from [**TextFormat**](/developer/desktop-sdk/references/sharpdx/sharpdx-directwrite/sharpdx-directwrite-textformat).)                                                                          |