Class DWriteFactory
The root factory interface for all DWrite objects.
Inherited Members
Namespace: JeremyAnsel.DirectX.DWrite
Assembly: JeremyAnsel.DirectX.DWrite.dll
Syntax
public sealed class DWriteFactory : IDisposable, IDWriteReleasable
Properties
| Edit this page View SourceHandle
Gets an handle representing the DWrite object interface.
Declaration
public object Handle { get; }
Property Value
Type | Description |
---|---|
object |
Methods
| Edit this page View SourceCreate(DWriteFactoryType)
Creates a DirectWrite factory object that is used for subsequent creation of individual DirectWrite objects.
Declaration
public static DWriteFactory Create(DWriteFactoryType factoryType)
Parameters
Type | Name | Description |
---|---|---|
DWriteFactoryType | factoryType | Identifies whether the factory object will be shared or isolated. |
Returns
Type | Description |
---|---|
DWriteFactory |
Remarks
Obtains DirectWrite factory object that is used for subsequent creation of individual DirectWrite classes. DirectWrite factory contains internal state such as font loader registration and cached font data. In most cases it is recommended to use the shared factory object, because it allows multiple components that use DirectWrite to share internal DirectWrite state and reduce memory usage. However, there are cases when it is desirable to reduce the impact of a component, such as a plug-in from an untrusted source, on the rest of the process by sandboxing and isolating it from the rest of the process components. In such cases, it is recommended to use an isolated factory for the sandboxed component.
CreateCustomRenderingParams(float, float, float, DWritePixelGeometry, DWriteRenderingMode)
Creates a rendering parameters object with the specified properties.
Declaration
public DWriteRenderingParams CreateCustomRenderingParams(float gamma, float enhancedContrast, float clearTypeLevel, DWritePixelGeometry pixelGeometry, DWriteRenderingMode renderingMode)
Parameters
Type | Name | Description |
---|---|---|
float | gamma | The gamma value used for gamma correction, which must be greater than zero and cannot exceed 256. |
float | enhancedContrast | The amount of contrast enhancement, zero or greater. |
float | clearTypeLevel | The degree of ClearType level, from 0.0f (no ClearType) to 1.0f (full ClearType). |
DWritePixelGeometry | pixelGeometry | The geometry of a device pixel. |
DWriteRenderingMode | renderingMode | Method of rendering glyphs. In most cases, this should be DWRITE_RENDERING_MODE_DEFAULT to automatically use an appropriate mode. |
Returns
Type | Description |
---|---|
DWriteRenderingParams |
CreateFontFace(DWriteFontFaceType, DWriteFontFile[], uint, DWriteFontSimulations)
Creates a font face object.
Declaration
public DWriteFontFace CreateFontFace(DWriteFontFaceType fontFaceType, DWriteFontFile[] fontFiles, uint faceIndex, DWriteFontSimulations fontFaceSimulation)
Parameters
Type | Name | Description |
---|---|---|
DWriteFontFaceType | fontFaceType | The file format of the font face. |
DWriteFontFile[] | fontFiles | Font files representing the font face. Since IDWriteFontFace maintains its own references to the input font file objects, it's OK to release them after this call. |
uint | faceIndex | The zero based index of a font face in cases when the font files contain a collection of font faces. If the font files contain a single face, this value should be zero. |
DWriteFontSimulations | fontFaceSimulation | Font face simulation flags for algorithmic emboldening and italicization. |
Returns
Type | Description |
---|---|
DWriteFontFace |
CreateFontFileReference(string, ulong)
CreateFontFileReference creates a font file reference object from a local font file.
Declaration
public DWriteFontFile CreateFontFileReference(string filePath, ulong lastWriteTime)
Parameters
Type | Name | Description |
---|---|---|
string | filePath | Absolute file path. Subsequent operations on the constructed object may fail if the user provided filePath doesn't correspond to a valid file on the disk. |
ulong | lastWriteTime | Last modified time of the input file path. If the parameter is omitted, the function will access the font file to obtain its last write time, so the clients are encouraged to specify this value to avoid extra disk access. Subsequent operations on the constructed object may fail if the user provided lastWriteTime doesn't match the file on the disk. |
Returns
Type | Description |
---|---|
DWriteFontFile |
CreateMonitorRenderingParams(nint)
Creates a rendering parameters object with default settings for the specified monitor.
Declaration
public DWriteRenderingParams CreateMonitorRenderingParams(nint monitor)
Parameters
Type | Name | Description |
---|---|---|
nint | monitor | The monitor to read the default values from. |
Returns
Type | Description |
---|---|
DWriteRenderingParams |
CreateRenderingParams()
Creates a rendering parameters object with default settings for the primary monitor.
Declaration
public DWriteRenderingParams CreateRenderingParams()
Returns
Type | Description |
---|---|
DWriteRenderingParams |
CreateTextFormat(string, DWriteFontCollection, DWriteFontWeight, DWriteFontStyle, DWriteFontStretch, float, string)
Create a text format object used for text layout.
Declaration
public DWriteTextFormat CreateTextFormat(string fontFamilyName, DWriteFontCollection fontCollection, DWriteFontWeight fontWeight, DWriteFontStyle fontStyle, DWriteFontStretch fontStretch, float fontSize, string localeName)
Parameters
Type | Name | Description |
---|---|---|
string | fontFamilyName | Name of the font family |
DWriteFontCollection | fontCollection | Font collection. NULL indicates the system font collection. |
DWriteFontWeight | fontWeight | Font weight |
DWriteFontStyle | fontStyle | Font style |
DWriteFontStretch | fontStretch | Font stretch |
float | fontSize | Logical size of the font in DIP units. A DIP ("device-independent pixel") equals 1/96 inch. |
string | localeName | Locale name |
Returns
Type | Description |
---|---|
DWriteTextFormat |
CreateTextLayout(string, DWriteTextFormat, float, float)
CreateTextLayout takes a string, format, and associated constraints and produces an object representing the fully analyzed and formatted result.
Declaration
public DWriteTextLayout CreateTextLayout(string text, DWriteTextFormat textFormat, float maxWidth, float maxHeight)
Parameters
Type | Name | Description |
---|---|---|
string | text | The string to layout. |
DWriteTextFormat | textFormat | The format to apply to the string. |
float | maxWidth | Width of the layout box. |
float | maxHeight | Height of the layout box. |
Returns
Type | Description |
---|---|
DWriteTextLayout |
CreateTypography()
Create a typography object used in conjunction with text format for text layout.
Declaration
public DWriteTypography CreateTypography()
Returns
Type | Description |
---|---|
DWriteTypography |
Dispose()
Immediately releases the unmanaged resources used by the DWrite object.
Declaration
public void Dispose()
GetSystemFontCollection()
Gets a font collection representing the set of installed fonts.
Declaration
public DWriteFontCollection GetSystemFontCollection()
Returns
Type | Description |
---|---|
DWriteFontCollection |
GetSystemFontCollection(bool)
Gets a font collection representing the set of installed fonts.
Declaration
public DWriteFontCollection GetSystemFontCollection(bool checkForUpdates)
Parameters
Type | Name | Description |
---|---|---|
bool | checkForUpdates | If this parameter is nonzero, the function performs an immediate check for changes to the set of installed fonts. If this parameter is FALSE, the function will still detect changes if the font cache service is running, but there may be some latency. For example, an application might specify TRUE if it has itself just installed a font and wants to be sure the font collection contains that font. |
Returns
Type | Description |
---|---|
DWriteFontCollection |
Release()
Releases the managed reference to the COM DWrite interface.
Declaration
public void Release()
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(DWriteFactory)
Gets a boolean indicating if the handle is not null.
Declaration
public static implicit operator bool(DWriteFactory value)
Parameters
Type | Name | Description |
---|---|---|
DWriteFactory | value | A DWrite object. |
Returns
Type | Description |
---|---|
bool | A boolean |