[]
        
(Showing Draft Content)

GrapeCity.Documents.DX.DirectWrite.FontFace

Class FontFace

Namespace
GrapeCity.Documents.DX.DirectWrite
Assembly
GcDocs.DX.Windows.dll

IDWriteFontFace

[Guid("5f49804d-7024-4d43-bfa9-d25984f53849")]
public class FontFace : ComObject, IDisposable, IUnknown
Inheritance
object
FontFace
Implements
System.IDisposable
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()

Constructors

FontFace(IntPtr)

Initializes a new instance of the FontFace class.

public FontFace(IntPtr nativePtr)

Parameters

nativePtr System.IntPtr

The native pointer.

Properties

Metrics

GetMetrics

public FontMetrics Metrics { get; }

Property Value

FontMetrics

Methods

Create(Factory, FontFaceType, FontFile[], int, FontSimulations)

Creates an object that represents a font face.

public static FontFace Create(Factory factory, FontFaceType fontFaceType, FontFile[] fontFiles, int faceIndex, FontSimulations fontFaceSimulationFlags)

Parameters

factory Factory

A reference to a DirectWrite factory Factory

fontFaceType FontFaceType

A value that indicates the type of file format of the font face.

fontFiles FontFile[]

A font file object representing the font face. BecauseC1.Win.DX.DirectWrite.FontFace maintains its own references to the input font file objects, you may release them after this call.

faceIndex int

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.

fontFaceSimulationFlags FontSimulations

A value that indicates which, if any, font face simulation flags for algorithmic means of making text bold or italic are applied to the current font face.

Returns

FontFace

Create(Font)

Creates a font face object for the font.

public static FontFace Create(Font font)

Parameters

font Font

the Font to create the FontFace from.

Returns

FontFace

GetDesignGlyphMetrics(short[], bool)

Obtains ideal (resolution-independent) glyph metrics in font design units.

public GlyphMetrics[] GetDesignGlyphMetrics(short[] glyphIndices, bool isSideways)

Parameters

glyphIndices short[]

An array of glyph indices for which to compute metrics. The array must contain at least as many elements as specified by glyphCount.

isSideways bool

Indicates whether the font is being used in a sideways run. This can affect the glyph metrics if the font has oblique simulation because sideways oblique simulation differs from non-sideways oblique simulation

Returns

GlyphMetrics[]

an array of GlyphMetrics structures.

Remarks

Design glyph metrics are used for glyph positioning.

GetDesignGlyphMetrics(short[], int, GlyphMetrics[], Bool)

HRESULT IDWriteFontFace::GetDesignGlyphMetrics([In, Buffer] const unsigned short* glyphIndices,[In] unsigned int glyphCount,[Out, Buffer] DWRITE_GLYPH_METRICS* glyphMetrics,[In] BOOL isSideways)

public void GetDesignGlyphMetrics(short[] glyphIndices, int glyphCount, GlyphMetrics[] glyphMetrics, Bool isSideways)

Parameters

glyphIndices short[]
glyphCount int
glyphMetrics GlyphMetrics[]
isSideways Bool

GetFaceType()

DWRITE_FONT_FACE_TYPE IDWriteFontFace::GetType()

public FontFaceType GetFaceType()

Returns

FontFaceType

GetFiles()

Obtains the font files representing a font face.

public FontFile[] GetFiles()

Returns

FontFile[]

An array that stores references to font files representing the font face. This parameter can be NULL if the user wants only the number of files representing the font face. This API increments reference count of the font file references returned according to COM conventions, and the client should release them when finished.

Remarks

The IDWriteFontFace::GetFiles method should be called twice. The first time you call GetFilesfontFiles should be NULL. When the method returns, numberOfFiles receives the number of font files that represent the font face. Then, call the method a second time, passing the numberOfFiles value that was output the first call, and a non-null buffer of the correct size to store the FontFile references.

GetFiles(ref int, FontFile[])

HRESULT IDWriteFontFace::GetFiles([InOut] unsigned int* numberOfFiles,[Out, Buffer, Optional] IDWriteFontFile** fontFiles)

public void GetFiles(ref int numberOfFiles, FontFile[] fontFiles)

Parameters

numberOfFiles int
fontFiles FontFile[]

GetGdiCompatibleGlyphMetrics(float, float, Matrix3x2?, Bool, short[], int, GlyphMetrics[], Bool)

HRESULT IDWriteFontFace::GetGdiCompatibleGlyphMetrics([In] float emSize,[In] float pixelsPerDip,[In, Optional] const DWRITE_MATRIX* transform,[In] BOOL useGdiNatural,[In, Buffer] const unsigned short* glyphIndices,[In] unsigned int glyphCount,[Out, Buffer] DWRITE_GLYPH_METRICS* glyphMetrics,[In] BOOL isSideways)

public void GetGdiCompatibleGlyphMetrics(float emSize, float pixelsPerDip, Matrix3x2? transform, Bool useGdiNatural, short[] glyphIndices, int glyphCount, GlyphMetrics[] glyphMetrics, Bool isSideways)

Parameters

emSize float
pixelsPerDip float
transform Matrix3x2?
useGdiNatural Bool
glyphIndices short[]
glyphCount int
glyphMetrics GlyphMetrics[]
isSideways Bool

GetGdiCompatibleGlyphMetrics(float, float, Matrix3x2?, bool, short[], bool)

Obtains glyph metrics in font design units with the return values compatible with what GDI would produce.

public GlyphMetrics[] GetGdiCompatibleGlyphMetrics(float fontSize, float pixelsPerDip, Matrix3x2? transform, bool useGdiNatural, short[] glyphIndices, bool isSideways)

Parameters

fontSize float

The ogical size of the font in DIP units.

pixelsPerDip float

The number of physical pixels per DIP.

transform Matrix3x2?

An optional transform applied to the glyphs and their positions. This transform is applied after the scaling specified by the font size and pixelsPerDip.

useGdiNatural bool

When set to FALSE, the metrics are the same as the metrics of GDI aliased text. When set to TRUE, the metrics are the same as the metrics of text measured by GDI using a font created with CLEARTYPE_NATURAL_QUALITY.

glyphIndices short[]

An array of glyph indices for which to compute the metrics.

isSideways bool

A BOOL value that indicates whether the font is being used in a sideways run. This can affect the glyph metrics if the font has oblique simulation because sideways oblique simulation differs from non-sideways oblique simulation.

Returns

GlyphMetrics[]

An array of C1.Win.DX.DirectWrite.GlyphMetrics structures filled by this function. The metrics are in font design units.

GetGdiCompatibleMetrics(float, float, Matrix3x2?)

HRESULT IDWriteFontFace::GetGdiCompatibleMetrics([In] float emSize,[In] float pixelsPerDip,[In, Optional] const DWRITE_MATRIX* transform,[Out] DWRITE_FONT_METRICS* fontFaceMetrics)

public FontMetrics GetGdiCompatibleMetrics(float emSize, float pixelsPerDip, Matrix3x2? transform)

Parameters

emSize float
pixelsPerDip float
transform Matrix3x2?

Returns

FontMetrics

GetGlyphCount()

unsigned short IDWriteFontFace::GetGlyphCount()

public short GetGlyphCount()

Returns

short

GetGlyphIndices(int[], int, short[])

HRESULT IDWriteFontFace::GetGlyphIndices([In, Buffer] const unsigned int* codePoints,[In] unsigned int codePointCount,[Out, Buffer] unsigned short* glyphIndices)

public void GetGlyphIndices(int[] codePoints, int codePointCount, short[] glyphIndices)

Parameters

codePoints int[]
codePointCount int
glyphIndices short[]

GetGlyphIndices(int[])

Returns the nominal mapping of UCS4 Unicode code points to glyph indices as defined by the font 'CMAP' table.

public short[] GetGlyphIndices(int[] codePoints)

Parameters

codePoints int[]

An array of USC4 code points from which to obtain nominal glyph indices. The array must be allocated and be able to contain the number of elements specified by codePointCount.

Returns

short[]

a reference to an array of nominal glyph indices filled by this function.

Remarks

Note that this mapping is primarily provided for line layout engines built on top of the physical font API. Because of OpenType glyph substitution and line layout character substitution, the nominal conversion does not always correspond to how a Unicode string will map to glyph indices when rendering using a particular font face. Also, note that Unicode variant selectors provide for alternate mappings for character to glyph. This call will always return the default variant.

GetGlyphRunOutline(float, short[], float[], GlyphOffset[], bool, bool, ISimplifiedGeometrySink)

Computes the outline of a run of glyphs by calling back to the outline sink interface.

public void GetGlyphRunOutline(float emSize, short[] glyphIndices, float[] glyphAdvances, GlyphOffset[] glyphOffsets, bool isSideways, bool isRightToLeft, ISimplifiedGeometrySink geometrySink)

Parameters

emSize float

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

glyphIndices short[]

An array of glyph indices. The glyphs are in logical order and the advance direction depends on the isRightToLeft parameter. The array must be allocated and be able to contain the number of elements specified by glyphCount.

glyphAdvances float[]

An optional array of glyph advances in DIPs. The advance of a glyph is the amount to advance the position (in the direction of the baseline) after drawing the glyph. glyphAdvances contains the number of elements specified by glyphIndices.Length.

glyphOffsets GlyphOffset[]

An optional array of glyph offsets, each of which specifies the offset along the baseline and offset perpendicular to the baseline of a glyph relative to the current pen position. glyphOffsets contains the number of elements specified by glyphIndices.Length.

isSideways bool

If TRUE, the ascender of the glyph runs alongside the baseline. If FALSE, the glyph ascender runs perpendicular to the baseline. For example, an English alphabet on a vertical baseline would have isSideways set to FALSE. A client can render a vertical run by setting isSideways to TRUE and rotating the resulting geometry 90 degrees to the right using a transform. The isSideways and isRightToLeft parameters cannot both be true.

isRightToLeft bool

The visual order of the glyphs. If this parameter is FALSE, then glyph advances are from left to right. If TRUE, the advance direction is right to left. By default, the advance direction is left to right.

geometrySink ISimplifiedGeometrySink

A reference to the interface that is called back to perform outline drawing operations.

GetGlyphRunOutline(float, IntPtr, IntPtr, IntPtr, int, bool, bool, IGeometrySink)

Computes the outline of a run of glyphs by calling back to the outline sink interface.

public void GetGlyphRunOutline(float emSize, IntPtr ptrGlyphIndices, IntPtr ptrGlyphAdvances, IntPtr ptrGlyphOffsets, int glyphCount, bool isSideways, bool isRightToLeft, IGeometrySink geometrySink)

Parameters

emSize float

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

ptrGlyphIndices System.IntPtr

An array of glyph indices. The glyphs are in logical order and the advance direction depends on the isRightToLeft parameter. The array must be allocated and be able to contain the number of elements specified by glyphCount.

ptrGlyphAdvances System.IntPtr

An optional array of glyph advances in DIPs. The advance of a glyph is the amount to advance the position (in the direction of the baseline) after drawing the glyph. glyphAdvances contains the number of elements specified by glyphIndices.Length.

ptrGlyphOffsets System.IntPtr

An optional array of glyph offsets, each of which specifies the offset along the baseline and offset perpendicular to the baseline of a glyph relative to the current pen position. glyphOffsets contains the number of elements specified by glyphIndices.Length.

glyphCount int

The number of glyphs.

isSideways bool

If TRUE, the ascender of the glyph runs alongside the baseline. If FALSE, the glyph ascender runs perpendicular to the baseline. For example, an English alphabet on a vertical baseline would have isSideways set to FALSE. A client can render a vertical run by setting isSideways to TRUE and rotating the resulting geometry 90 degrees to the right using a transform. The isSideways and isRightToLeft parameters cannot both be true.

isRightToLeft bool

The visual order of the glyphs. If this parameter is FALSE, then glyph advances are from left to right. If TRUE, the advance direction is right to left. By default, the advance direction is left to right.

geometrySink IGeometrySink

A reference to the interface that is called back to perform outline drawing operations.

GetIndex()

unsigned int IDWriteFontFace::GetIndex()

public int GetIndex()

Returns

int

GetMetrics(out FontMetrics)

void IDWriteFontFace::GetMetrics([Out] DWRITE_FONT_METRICS* fontFaceMetrics)

public void GetMetrics(out FontMetrics fontFaceMetrics)

Parameters

fontFaceMetrics FontMetrics

GetRecommendedRenderingMode(float, float, MeasuringMode, RenderingParams)

HRESULT IDWriteFontFace::GetRecommendedRenderingMode([In] float emSize,[In] float pixelsPerDip,[In] DWRITE_MEASURING_MODE measuringMode,[In] IDWriteRenderingParams* renderingParams,[Out] DWRITE_RENDERING_MODE* renderingMode)

public RenderingMode GetRecommendedRenderingMode(float emSize, float pixelsPerDip, MeasuringMode measuringMode, RenderingParams renderingParams)

Parameters

emSize float
pixelsPerDip float
measuringMode MeasuringMode
renderingParams RenderingParams

Returns

RenderingMode

GetSimulations()

DWRITE_FONT_SIMULATIONS IDWriteFontFace::GetSimulations()

public FontSimulations GetSimulations()

Returns

FontSimulations

IsSymbolFont()

BOOL IDWriteFontFace::IsSymbolFont()

public bool IsSymbolFont()

Returns

bool

ReleaseFontTable(IntPtr)

void IDWriteFontFace::ReleaseFontTable([In] void* tableContext)

public void ReleaseFontTable(IntPtr tableContext)

Parameters

tableContext System.IntPtr

TryGetFontTable(int, out DataPointer, out IntPtr)

Finds the specified OpenType font table if it exists and returns a reference to it. The function accesses the underlying font data through the C1.Win.DX.DirectWrite.FontFileStream interface implemented by the font file loader.

public bool TryGetFontTable(int openTypeTableTag, out DataPointer tableData, out IntPtr tableContext)

Parameters

openTypeTableTag int

The four-character tag of a OpenType font table to find. Use the DWRITE_MAKE_OPENTYPE_TAG macro to create it as an UINT32. Unlike GDI, it does not support the special TTCF and null tags to access the whole font.

tableData DataPointer

When this method returns, contains the address of a reference to the base of the table in memory. The reference is valid only as long as the font face used to get the font table still exists; (not any other font face, even if it actually refers to the same physical font).

tableContext System.IntPtr

When this method returns, the address of a reference to the opaque context, which must be freed by calling {{ReleaseFontTable}}. The context actually comes from the lower-level C1.Win.DX.DirectWrite.FontFileStream, which may be implemented by the application or DWrite itself. It is possible for a NULL tableContext to be returned, especially if the implementation performs direct memory mapping on the whole file. Nevertheless, always release it later, and do not use it as a test for function success. The same table can be queried multiple times, but because each returned context can be different, you must release each context separately.

Returns

bool

TRUE if the font table exists; otherwise, FALSE.

Remarks

The context for the same tag may be different for each call, so each one must be held and released separately.

TryGetFontTable(int, IntPtr, out int, out IntPtr)

HRESULT IDWriteFontFace::TryGetFontTable([In] unsigned int openTypeTableTag,[Out, Buffer] const void** tableData,[Out] unsigned int* tableSize,[Out] void** tableContext,[Out] BOOL* exists)

public bool TryGetFontTable(int openTypeTableTag, IntPtr tableData, out int tableSize, out IntPtr tableContext)

Parameters

openTypeTableTag int
tableData System.IntPtr
tableSize int
tableContext System.IntPtr

Returns

bool

Operators

explicit operator FontFace(IntPtr)

Performs an explicit conversion from System.IntPtr to FontFace.

public static explicit operator FontFace(IntPtr nativePointer)

Parameters

nativePointer System.IntPtr

Returns

FontFace