Table of Contents

Class Factory2

Namespace
SharpDX.DirectWrite
Assembly
SharpDX.Direct2D1.dll
[Guid("0439fc60-ca44-4994-8dee-3a9af7b732ec")]
public class Factory2 : Factory1
Inheritance
Factory2
Derived
Inherited Members

Constructors

Factory2(nint)

public Factory2(nint nativePtr)

Parameters

nativePtr nint

Properties

SystemFontFallback

Creates a font fallback object from the system font fallback list.

public FontFallback SystemFontFallback { get; }

Property Value

FontFallback

Methods

CreateCustomRenderingParams(float, float, float, float, PixelGeometry, RenderingMode, GridFitMode, out RenderingParams2)

Creates a rendering parameters object with the specified properties.

public void CreateCustomRenderingParams(float gamma, float enhancedContrast, float grayscaleEnhancedContrast, float clearTypeLevel, PixelGeometry pixelGeometry, RenderingMode renderingMode, GridFitMode gridFitMode, out RenderingParams2 renderingParams)

Parameters

gamma float

The gamma value used for gamma correction, which must be greater than zero and cannot exceed 256.

enhancedContrast float

The amount of contrast enhancement, zero or greater.

grayscaleEnhancedContrast float

The amount of contrast enhancement, zero or greater.

clearTypeLevel float

The degree of ClearType level, from 0.0f (no ClearType) to 1.0f (full ClearType).

pixelGeometry PixelGeometry

The geometry of a device pixel.

renderingMode RenderingMode

Method of rendering glyphs. In most cases, this should be DWRITE_RENDERING_MODE_DEFAULT to automatically use an appropriate mode.

gridFitMode GridFitMode

How to grid fit glyph outlines. In most cases, this should be DWRITE_GRID_FIT_DEFAULT to automatically choose an appropriate mode.

renderingParams RenderingParams2

Holds the newly created rendering parameters object, or null in case of failure.

CreateFontFallbackBuilder(out FontFallbackBuilder)

Creates a font fallback builder object.

A font fall back builder allows you to create Unicode font fallback mappings and create a font fall back object from those mappings.

public void CreateFontFallbackBuilder(out FontFallbackBuilder fontFallbackBuilder)

Parameters

fontFallbackBuilder FontFallbackBuilder

Contains an address of a reference to the newly created font fallback builder object.

CreateGlyphRunAnalysis(GlyphRun, RawMatrix3x2?, RenderingMode, MeasuringMode, GridFitMode, TextAntialiasMode, float, float, out GlyphRunAnalysis)

Creates a glyph run analysis object, which encapsulates information used to render a glyph run.

public void CreateGlyphRunAnalysis(GlyphRun glyphRun, RawMatrix3x2? transform, RenderingMode renderingMode, MeasuringMode measuringMode, GridFitMode gridFitMode, TextAntialiasMode antialiasMode, float baselineOriginX, float baselineOriginY, out GlyphRunAnalysis glyphRunAnalysis)

Parameters

glyphRun GlyphRun

Structure specifying the properties of the glyph run.

transform RawMatrix3x2?

Optional transform applied to the glyphs and their positions. This transform is applied after the scaling specified by the emSize and pixelsPerDip.

renderingMode RenderingMode

Specifies the rendering mode, which must be one of the raster rendering modes (i.e., not default and not outline).

measuringMode MeasuringMode

Specifies the method to measure glyphs.

gridFitMode GridFitMode

How to grid-fit glyph outlines. This must be non-default.

antialiasMode TextAntialiasMode

Specifies the antialias mode.

baselineOriginX float

Horizontal position of the baseline origin, in DIPs.

baselineOriginY float

Vertical position of the baseline origin, in DIPs.

glyphRunAnalysis GlyphRunAnalysis

Receives a reference to the newly created object.

TranslateColorGlyphRun(float, float, GlyphRun, GlyphRunDescription, MeasuringMode, RawMatrix3x2?, int)

This method is called on a glyph run to translate it in to multiple color glyph runs.

public ColorGlyphRunEnumerator TranslateColorGlyphRun(float baselineOriginX, float baselineOriginY, GlyphRun glyphRun, GlyphRunDescription glyphRunDescription, MeasuringMode measuringMode, RawMatrix3x2? worldToDeviceTransform, int colorPaletteIndex)

Parameters

baselineOriginX float

The horizontal baseline origin of the original glyph run.

baselineOriginY float

The vertical baseline origin of the original glyph run.

glyphRun GlyphRun

Original glyph run containing monochrome glyph IDs.

glyphRunDescription GlyphRunDescription

Optional glyph run description.

measuringMode MeasuringMode

Measuring mode used to compute glyph positions if the run contains color glyphs.

worldToDeviceTransform RawMatrix3x2?

World transform multiplied by any DPI scaling. This is needed to compute glyph positions if the run contains color glyphs and the measuring mode is not DWRITE_MEASURING_MODE_NATURAL. If this parameter is null, and identity transform is assumed.

colorPaletteIndex int

Zero-based index of the color palette to use. Valid indices are less than the number of palettes in the font, as returned by IDWriteFontFace2::GetColorPaletteCount.

Returns

ColorGlyphRunEnumerator

If the original glyph run contains color glyphs, this parameter receives a reference to an ColorGlyphRunEnumerator interface. The client uses the returned interface to get information about glyph runs and associated colors to render instead of the original glyph run. If the original glyph run does not contain color glyphs, this method returns DWRITE_E_NOCOLOR and the output reference is null.

Remarks

If the code calls this method with a glyph run that contains no color information, the method returns DWRITE_E_NOCOLOR to let the application know that it can just draw the original glyph run. If the glyph run contains color information, the function returns an object that can be enumerated through to expose runs and associated colors. The application then calls DrawGlyphRun with each of the returned glyph runs and foreground colors.

TranslateColorGlyphRun(float, float, GlyphRun, GlyphRunDescription, MeasuringMode, RawMatrix3x2?, int, out ColorGlyphRunEnumerator)

This method is called on a glyph run to translate it in to multiple color glyph runs.

public void TranslateColorGlyphRun(float baselineOriginX, float baselineOriginY, GlyphRun glyphRun, GlyphRunDescription glyphRunDescription, MeasuringMode measuringMode, RawMatrix3x2? worldToDeviceTransform, int colorPaletteIndex, out ColorGlyphRunEnumerator colorLayers)

Parameters

baselineOriginX float

The horizontal baseline origin of the original glyph run.

baselineOriginY float

The vertical baseline origin of the original glyph run.

glyphRun GlyphRun

Original glyph run containing monochrome glyph IDs.

glyphRunDescription GlyphRunDescription

Optional glyph run description.

measuringMode MeasuringMode

Measuring mode used to compute glyph positions if the run contains color glyphs.

worldToDeviceTransform RawMatrix3x2?

World transform multiplied by any DPI scaling. This is needed to compute glyph positions if the run contains color glyphs and the measuring mode is not DWRITE_MEASURING_MODE_NATURAL. If this parameter is null, and identity transform is assumed.

colorPaletteIndex int

Zero-based index of the color palette to use. Valid indices are less than the number of palettes in the font, as returned by IDWriteFontFace2::GetColorPaletteCount.

colorLayers ColorGlyphRunEnumerator

If the original glyph run contains color glyphs, this parameter receives a reference to an ColorGlyphRunEnumerator interface. The client uses the returned interface to get information about glyph runs and associated colors to render instead of the original glyph run. If the original glyph run does not contain color glyphs, this method returns DWRITE_E_NOCOLOR and the output reference is null.

Remarks

If the code calls this method with a glyph run that contains no color information, the method returns DWRITE_E_NOCOLOR to let the application know that it can just draw the original glyph run. If the glyph run contains color information, the function returns an object that can be enumerated through to expose runs and associated colors. The application then calls DrawGlyphRun with each of the returned glyph runs and foreground colors.

TryTranslateColorGlyphRun(float, float, GlyphRun, GlyphRunDescription, MeasuringMode, RawMatrix3x2?, int, out ColorGlyphRunEnumerator)

This method is called on a glyph run to translate it in to multiple color glyph runs.

public Result TryTranslateColorGlyphRun(float baselineOriginX, float baselineOriginY, GlyphRun glyphRun, GlyphRunDescription glyphRunDescription, MeasuringMode measuringMode, RawMatrix3x2? worldToDeviceTransform, int colorPaletteIndex, out ColorGlyphRunEnumerator colorLayers)

Parameters

baselineOriginX float

The horizontal baseline origin of the original glyph run.

baselineOriginY float

The vertical baseline origin of the original glyph run.

glyphRun GlyphRun

Original glyph run containing monochrome glyph IDs.

glyphRunDescription GlyphRunDescription

Optional glyph run description.

measuringMode MeasuringMode

Measuring mode used to compute glyph positions if the run contains color glyphs.

worldToDeviceTransform RawMatrix3x2?

World transform multiplied by any DPI scaling. This is needed to compute glyph positions if the run contains color glyphs and the measuring mode is not DWRITE_MEASURING_MODE_NATURAL. If this parameter is null, and identity transform is assumed.

colorPaletteIndex int

Zero-based index of the color palette to use. Valid indices are less than the number of palettes in the font, as returned by IDWriteFontFace2::GetColorPaletteCount.

colorLayers ColorGlyphRunEnumerator

If the original glyph run contains color glyphs, this parameter receives a reference to an ColorGlyphRunEnumerator interface. The client uses the returned interface to get information about glyph runs and associated colors to render instead of the original glyph run. If the original glyph run does not contain color glyphs, this method returns DWRITE_E_NOCOLOR and the output reference is null.

Returns

Result

If this method succeeds, it returns SharpDX.Result.Ok. Otherwise, it returns an SharpDX.Result error code.

Remarks

If the code calls this method with a glyph run that contains no color information, the method returns DWRITE_E_NOCOLOR to let the application know that it can just draw the original glyph run. If the glyph run contains color information, the function returns an object that can be enumerated through to expose runs and associated colors. The application then calls DrawGlyphRun with each of the returned glyph runs and foreground colors.

Operators

explicit operator Factory2(nint)

public static explicit operator Factory2(nint nativePtr)

Parameters

nativePtr nint

Returns

Factory2