Table of Contents

Class TextFormat

Namespace
SharpDX.DirectWrite
Assembly
SharpDX.Direct2D1.dll
[Guid("9c906818-31d7-4fd3-a151-7c5e225db55a")]
public class TextFormat : ComObject
Inheritance
TextFormat
Derived

Constructors

TextFormat(Factory, string, FontCollection, FontWeight, FontStyle, FontStretch, float)

Creates a text format object used for text layout.

public TextFormat(Factory factory, string fontFamilyName, FontCollection fontCollection, FontWeight fontWeight, FontStyle fontStyle, FontStretch fontStretch, float fontSize)

Parameters

factory Factory

an instance of Factory

fontFamilyName string

An array of characters that contains the name of the font family

fontCollection FontCollection

A pointer to a font collection object. When this is NULL, indicates the system font collection.

fontWeight FontWeight

A value that indicates the font weight for the text object created by this method.

fontStyle FontStyle

A value that indicates the font style for the text object created by this method.

fontStretch FontStretch

A value that indicates the font stretch for the text object created by this method.

fontSize float

The logical size of the font in DIP ("device-independent pixel") units. A DIP equals 1/96 inch.

TextFormat(Factory, string, FontCollection, FontWeight, FontStyle, FontStretch, float, string)

Creates a text format object used for text layout.

public TextFormat(Factory factory, string fontFamilyName, FontCollection fontCollection, FontWeight fontWeight, FontStyle fontStyle, FontStretch fontStretch, float fontSize, string localeName)

Parameters

factory Factory

an instance of Factory

fontFamilyName string

An array of characters that contains the name of the font family

fontCollection FontCollection

A pointer to a font collection object. When this is NULL, indicates the system font collection.

fontWeight FontWeight

A value that indicates the font weight for the text object created by this method.

fontStyle FontStyle

A value that indicates the font style for the text object created by this method.

fontStretch FontStretch

A value that indicates the font stretch for the text object created by this method.

fontSize float

The logical size of the font in DIP ("device-independent pixel") units. A DIP equals 1/96 inch.

localeName string

An array of characters that contains the locale name.

TextFormat(Factory, string, FontWeight, FontStyle, FontStretch, float)

Creates a text format object used for text layout.

public TextFormat(Factory factory, string fontFamilyName, FontWeight fontWeight, FontStyle fontStyle, FontStretch fontStretch, float fontSize)

Parameters

factory Factory

an instance of Factory

fontFamilyName string

An array of characters that contains the name of the font family

fontWeight FontWeight

A value that indicates the font weight for the text object created by this method.

fontStyle FontStyle

A value that indicates the font style for the text object created by this method.

fontStretch FontStretch

A value that indicates the font stretch for the text object created by this method.

fontSize float

The logical size of the font in DIP ("device-independent pixel") units. A DIP equals 1/96 inch.

TextFormat(Factory, string, FontWeight, FontStyle, float)

Creates a text format object used for text layout with normal stretch.

public TextFormat(Factory factory, string fontFamilyName, FontWeight fontWeight, FontStyle fontStyle, float fontSize)

Parameters

factory Factory

an instance of Factory

fontFamilyName string

An array of characters that contains the name of the font family

fontWeight FontWeight

A value that indicates the font weight for the text object created by this method.

fontStyle FontStyle

A value that indicates the font style for the text object created by this method.

fontSize float

The logical size of the font in DIP ("device-independent pixel") units. A DIP equals 1/96 inch.

TextFormat(Factory, string, float)

Creates a text format object used for text layout with normal weight, style and stretch.

public TextFormat(Factory factory, string fontFamilyName, float fontSize)

Parameters

factory Factory

an instance of Factory

fontFamilyName string

An array of characters that contains the name of the font family

fontSize float

The logical size of the font in DIP ("device-independent pixel") units. A DIP equals 1/96 inch.

TextFormat(nint)

public TextFormat(nint nativePtr)

Parameters

nativePtr nint

Properties

FlowDirection

Gets or sets the direction that text lines flow.

public FlowDirection FlowDirection { get; set; }

Property Value

FlowDirection

FontCollection

Gets the current font collection.

public FontCollection FontCollection { get; }

Property Value

FontCollection

FontFamilyName

Gets a copy of the font family name.

public string FontFamilyName { get; }

Property Value

string

the current font family name.

FontSize

Gets the font size in DIP unites.

public float FontSize { get; }

Property Value

float

FontStretch

Gets the font stretch of the text.

public FontStretch FontStretch { get; }

Property Value

FontStretch

FontStyle

Gets the font style of the text.

public FontStyle FontStyle { get; }

Property Value

FontStyle

FontWeight

Gets the font weight of the text.

public FontWeight FontWeight { get; }

Property Value

FontWeight

IncrementalTabStop

Gets or sets the incremental tab stop position.

public float IncrementalTabStop { get; set; }

Property Value

float

LocaleName

Gets a copy of the locale name.

public string LocaleName { get; }

Property Value

string

the current locale name.

ParagraphAlignment

Gets or sets the alignment option of a paragraph which is relative to the top and bottom edges of a layout box.

public ParagraphAlignment ParagraphAlignment { get; set; }

Property Value

ParagraphAlignment

ReadingDirection

Gets or sets the current reading direction for text in a paragraph.

public ReadingDirection ReadingDirection { get; set; }

Property Value

ReadingDirection

TextAlignment

Gets or sets the alignment option of text relative to the layout box's leading and trailing edge.

public TextAlignment TextAlignment { get; set; }

Property Value

TextAlignment

WordWrapping

Gets or sets the word wrapping option.

public WordWrapping WordWrapping { get; set; }

Property Value

WordWrapping

Methods

GetLineSpacing(out LineSpacingMethod, out float, out float)

Gets the line spacing adjustment set for a multiline text paragraph.

public void GetLineSpacing(out LineSpacingMethod lineSpacingMethod, out float lineSpacing, out float baseline)

Parameters

lineSpacingMethod LineSpacingMethod

A value that indicates how line height is determined.

lineSpacing float

When this method returns, contains the line height, or distance between one baseline to another.

baseline float

When this method returns, contains the distance from top of line to baseline. A reasonable ratio to lineSpacing is 80 percent.

GetTrimming(out Trimming, out InlineObject)

Gets the trimming options for text that overflows the layout box.

public void GetTrimming(out Trimming trimmingOptions, out InlineObject trimmingSign)

Parameters

trimmingOptions Trimming

When this method returns, it contains a reference to a Trimming structure that holds the text trimming options for the overflowing text.

trimmingSign InlineObject

When this method returns, contains an address of a reference to a trimming omission sign. This parameter may be null.

SetLineSpacing(LineSpacingMethod, float, float)

Sets the line spacing.

public void SetLineSpacing(LineSpacingMethod lineSpacingMethod, float lineSpacing, float baseline)

Parameters

lineSpacingMethod LineSpacingMethod

Specifies how line height is being determined; see LineSpacingMethod for more information.

lineSpacing float

The line height, or distance between one baseline to another.

baseline float

The distance from top of line to baseline. A reasonable ratio to lineSpacing is 80 percent.

Remarks

For the default method, spacing depends solely on the content. For uniform spacing, the specified line height overrides the content.

SetTrimming(Trimming, InlineObject)

Sets trimming options for text overflowing the layout width.

public void SetTrimming(Trimming trimmingOptions, InlineObject trimmingSign)

Parameters

trimmingOptions Trimming

Text trimming options.

trimmingSign InlineObject

Application-defined omission sign. This parameter may be null. See InlineObject for more information.

Operators

explicit operator TextFormat(nint)

public static explicit operator TextFormat(nint nativePtr)

Parameters

nativePtr nint

Returns

TextFormat