[]
IDWriteFontFace
[Guid("5f49804d-7024-4d43-bfa9-d25984f53849")]
public class FontFace : ComObject, IDisposable, IUnknown
Initializes a new instance of the FontFace class.
public FontFace(IntPtr nativePtr)
nativePtr
System.IntPtrThe native pointer.
GetMetrics
public FontMetrics Metrics { get; }
Creates an object that represents a font face.
public static FontFace Create(Factory factory, FontFaceType fontFaceType, FontFile[] fontFiles, int faceIndex, FontSimulations fontFaceSimulationFlags)
factory
FactoryA reference to a DirectWrite factory Factory
fontFaceType
FontFaceTypeA 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
intThe 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
FontSimulationsA 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.
Creates a font face object for the font.
public static FontFace Create(Font font)
Obtains ideal (resolution-independent) glyph metrics in font design units.
public GlyphMetrics[] GetDesignGlyphMetrics(short[] glyphIndices, bool isSideways)
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
boolIndicates 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
an array of GlyphMetrics structures.
Design glyph metrics are used for glyph positioning.
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)
glyphIndices
short[]glyphCount
intglyphMetrics
GlyphMetrics[]isSideways
BoolDWRITE_FONT_FACE_TYPE IDWriteFontFace::GetType()
public FontFaceType GetFaceType()
Obtains the font files representing a font face.
public FontFile[] GetFiles()
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.
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.
HRESULT IDWriteFontFace::GetFiles([InOut] unsigned int* numberOfFiles,[Out, Buffer, Optional] IDWriteFontFile** fontFiles)
public void GetFiles(ref int numberOfFiles, FontFile[] fontFiles)
numberOfFiles
intfontFiles
FontFile[]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)
emSize
floatpixelsPerDip
floattransform
Matrix3x2?useGdiNatural
BoolglyphIndices
short[]glyphCount
intglyphMetrics
GlyphMetrics[]isSideways
BoolObtains 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)
fontSize
floatThe ogical size of the font in DIP units.
pixelsPerDip
floatThe 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
boolWhen 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
boolA 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.
An array of C1.Win.DX.DirectWrite.GlyphMetrics structures filled by this function. The metrics are in font design units.
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)
emSize
floatpixelsPerDip
floattransform
Matrix3x2?unsigned short IDWriteFontFace::GetGlyphCount()
public short GetGlyphCount()
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)
codePoints
int[]codePointCount
intglyphIndices
short[]Returns the nominal mapping of UCS4 Unicode code points to glyph indices as defined by the font 'CMAP' table.
public short[] GetGlyphIndices(int[] codePoints)
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.
a reference to an array of nominal glyph indices filled by this function.
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.
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)
emSize
floatThe 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
boolIf 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
boolThe 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
ISimplifiedGeometrySinkA reference to the interface that is called back to perform outline drawing operations.
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)
emSize
floatThe logical size of the font in DIP units. A DIP ("device-independent pixel") equals 1/96 inch.
ptrGlyphIndices
System.IntPtrAn 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.IntPtrAn 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.IntPtrAn 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
intThe number of glyphs.
isSideways
boolIf 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
boolThe 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
IGeometrySinkA reference to the interface that is called back to perform outline drawing operations.
unsigned int IDWriteFontFace::GetIndex()
public int GetIndex()
void IDWriteFontFace::GetMetrics([Out] DWRITE_FONT_METRICS* fontFaceMetrics)
public void GetMetrics(out FontMetrics fontFaceMetrics)
fontFaceMetrics
FontMetricsHRESULT 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)
emSize
floatpixelsPerDip
floatmeasuringMode
MeasuringModerenderingParams
RenderingParamsDWRITE_FONT_SIMULATIONS IDWriteFontFace::GetSimulations()
public FontSimulations GetSimulations()
BOOL IDWriteFontFace::IsSymbolFont()
public bool IsSymbolFont()
void IDWriteFontFace::ReleaseFontTable([In] void* tableContext)
public void ReleaseFontTable(IntPtr tableContext)
tableContext
System.IntPtrFinds 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)
openTypeTableTag
intThe 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
DataPointerWhen 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.IntPtrWhen 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.
TRUE if the font table exists; otherwise, FALSE.
The context for the same tag may be different for each call, so each one must be held and released separately.
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)
openTypeTableTag
inttableData
System.IntPtrtableSize
inttableContext
System.IntPtrPerforms an explicit conversion from System.IntPtr to FontFace.
public static explicit operator FontFace(IntPtr nativePointer)
nativePointer
System.IntPtr