Class DWriteTextFormat
The format of text used for text layout.
Implements
Inherited Members
Namespace: JeremyAnsel.DirectX.DWrite
Assembly: JeremyAnsel.DirectX.DWrite.dll
Syntax
[SecurityCritical]
public class DWriteTextFormat : DXComObject, IDisposable
Remarks
This object may not be thread-safe and it may carry the state of text format change.
Constructors
| Edit this page View SourceDWriteTextFormat(nint)
Initializes a new instance of the DWriteTextFormat class.
Declaration
public DWriteTextFormat(nint comPtr)
Parameters
| Type | Name | Description |
|---|---|---|
| nint | comPtr |
Fields
| Edit this page View SourceDWriteTextFormatGuid
The interface GUID.
Declaration
public static readonly Guid DWriteTextFormatGuid
Field Value
| Type | Description |
|---|---|
| Guid |
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 |
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 SourceGetFontCollection()
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 |
GetFontFamilyName(Span<char>)
Get a copy of the font family name.
Declaration
public void GetFontFamilyName(Span<char> name)
Parameters
| Type | Name | Description |
|---|---|---|
| Span<char> | name | The name. |
GetFontFamilyNameLength()
Get the length of the font family name, in characters, not including the terminating NULL character.
Declaration
public uint GetFontFamilyNameLength()
Returns
| Type | Description |
|---|---|
| uint |
GetLineSpacing(out DWriteLineSpacingMethod, out float, out float)
Get line spacing.
Declaration
public void GetLineSpacing(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 |
GetLocaleName(Span<char>)
Get a copy of the locale name.
Declaration
public void GetLocaleName(Span<char> str)
Parameters
| Type | Name | Description |
|---|---|---|
| Span<char> | str | The string. |
GetLocaleNameLength()
Get the length of the locale name, in characters, not including the terminating NULL character.
Declaration
public uint GetLocaleNameLength()
Returns
| Type | Description |
|---|---|
| uint |
GetTrimming()
Get trimming options for text overflowing the layout width.
Declaration
public DWriteTrimming GetTrimming()
Returns
| Type | Description |
|---|---|
| DWriteTrimming |
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(in 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(in DWriteTrimming trimmingOptions)
Parameters
| Type | Name | Description |
|---|---|---|
| DWriteTrimming | trimmingOptions | Text trimming options. |