Class DWriteTextFormat
The format of text used for text layout.
Inherited Members
Namespace: JeremyAnsel.DirectX.DWrite
Assembly: JeremyAnsel.DirectX.DWrite.dll
Syntax
public sealed class DWriteTextFormat : IDisposable, IDWriteReleasable
Remarks
This object may not be thread-safe and it may carry the state of text format change.
Properties
| Edit this page View SourceFlowDirection
Gets or sets paragraph flow direction.
Declaration
public DWriteFlowDirection FlowDirection { get; set; }
Property Value
| Type | Description |
|---|---|
| DWriteFlowDirection |
Remarks
The flow direction must be perpendicular to the reading direction. Setting both to a vertical direction or both to horizontal yields DWRITE_E_FLOWDIRECTIONCONFLICTS when calling GetMetrics or Draw.
FontSize
Gets the font em height.
Declaration
public float FontSize { get; }
Property Value
| Type | Description |
|---|---|
| float |
FontStretch
Gets the font stretch.
Declaration
public DWriteFontStretch FontStretch { get; }
Property Value
| Type | Description |
|---|---|
| DWriteFontStretch |
FontStyle
Gets the font style.
Declaration
public DWriteFontStyle FontStyle { get; }
Property Value
| Type | Description |
|---|---|
| DWriteFontStyle |
FontWeight
Gets the font weight.
Declaration
public DWriteFontWeight FontWeight { get; }
Property Value
| Type | Description |
|---|---|
| DWriteFontWeight |
Handle
Gets an handle representing the DWrite object interface.
Declaration
public object Handle { get; }
Property Value
| Type | Description |
|---|---|
| object |
IncrementalTabStop
Gets or sets the incremental tab stop position.
Declaration
public float IncrementalTabStop { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
ParagraphAlignment
Gets or sets the alignment option of paragraph relative to layout box's top and bottom edge.
Declaration
public DWriteParagraphAlignment ParagraphAlignment { get; set; }
Property Value
| Type | Description |
|---|---|
| DWriteParagraphAlignment |
ReadingDirection
Gets or sets the paragraph reading direction.
Declaration
public DWriteReadingDirection ReadingDirection { get; set; }
Property Value
| Type | Description |
|---|---|
| DWriteReadingDirection |
Remarks
The flow direction must be perpendicular to the reading direction. Setting both to a vertical direction or both to horizontal yields DWRITE_E_FLOWDIRECTIONCONFLICTS when calling GetMetrics or Draw.
TextAlignment
Gets or sets the alignment option of text relative to layout box's leading and trailing edge.
Declaration
public DWriteTextAlignment TextAlignment { get; set; }
Property Value
| Type | Description |
|---|---|
| DWriteTextAlignment |
WordWrapping
Gets or sets the word wrapping option.
Declaration
public DWriteWordWrapping WordWrapping { get; set; }
Property Value
| Type | Description |
|---|---|
| DWriteWordWrapping |
Methods
| Edit this page View SourceDispose()
Immediately releases the unmanaged resources used by the DWrite object.
Declaration
public void Dispose()
GetFontCollection()
Get the font collection.
Declaration
public DWriteFontCollection? GetFontCollection()
Returns
| Type | Description |
|---|---|
| DWriteFontCollection |
GetFontFamilyName()
Get a copy of the font family name.
Declaration
public string GetFontFamilyName()
Returns
| Type | Description |
|---|---|
| string |
GetLineSpaceing(out DWriteLineSpacingMethod, out float, out float)
Get line spacing.
Declaration
public void GetLineSpaceing(out DWriteLineSpacingMethod lineSpacingMethod, out float lineSpacing, out float baseline)
Parameters
| Type | Name | Description |
|---|---|---|
| DWriteLineSpacingMethod | lineSpacingMethod | How line height is determined. |
| float | lineSpacing | The line height, or rather distance between one baseline to another. |
| float | baseline | Distance from top of line to baseline. |
GetLocaleName()
Get a copy of the locale name.
Declaration
public string GetLocaleName()
Returns
| Type | Description |
|---|---|
| string |
GetTrimming()
Get trimming options for text overflowing the layout width.
Declaration
public DWriteTrimming GetTrimming()
Returns
| Type | Description |
|---|---|
| DWriteTrimming |
Release()
Releases the managed reference to the COM DWrite interface.
Declaration
public void Release()
SetLineSpacing(DWriteLineSpacingMethod, float, float)
Set line spacing.
Declaration
public void SetLineSpacing(DWriteLineSpacingMethod lineSpacingMethod, float lineSpacing, float baseline)
Parameters
| Type | Name | Description |
|---|---|---|
| DWriteLineSpacingMethod | lineSpacingMethod | How to determine line height. |
| float | lineSpacing | The line height, or rather distance between one baseline to another. |
| float | baseline | Distance from top of line to baseline. A reasonable ratio to lineSpacing is 80%. |
Remarks
For the default method, spacing depends solely on the content. For uniform spacing, the given line height will override the content.
SetTrimming(DWriteTrimming)
Set trimming options for any trailing text exceeding the layout width or for any far text exceeding the layout height.
Declaration
public void SetTrimming(DWriteTrimming trimmingOptions)
Parameters
| Type | Name | Description |
|---|---|---|
| DWriteTrimming | trimmingOptions | Text trimming options. |
ToBoolean()
Gets a boolean indicating if the handle is not null.
Declaration
public bool ToBoolean()
Returns
| Type | Description |
|---|---|
| bool | A boolean |
Operators
| Edit this page View Sourceimplicit operator bool(DWriteTextFormat?)
Gets a boolean indicating if the handle is not null.
Declaration
public static implicit operator bool(DWriteTextFormat? value)
Parameters
| Type | Name | Description |
|---|---|---|
| DWriteTextFormat | value | A DWrite object. |
Returns
| Type | Description |
|---|---|
| bool | A boolean |