OfficeTrueTypeFont
OfficeIMO.Drawing
Small managed reader for sfnt fonts that use TrueType glyf outlines, used for dependency-free text rasterization.
Inheritance
- object
- OfficeTrueTypeFont
Remarks
This type reads font files directly and does not call operating-system graphics or font APIs. It supports the simple glyf/cmap/hmtx path needed by OfficeIMO renderers and falls back cleanly when no suitable platform font file is available.
Usage
Explore 6 API references to this type
This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.
Returned or exposed by 5
Accepted by parameters 1
- Constructor OfficeRasterCanvas.OfficeRasterCanvas
Methods
public double BaselineOffset(double fontSize) #Returns the distance from the top of the face line box to its baseline.
Parameters
- fontSize double
Returns
doublepublic List<List<OfficePoint>> GetTextContours(string text, double x, double y, double fontSize) #Reads flattened fill contours for the supplied text at a top-left baseline box.
Parameters
- text string
- x double
- y double
- fontSize double
Returns
List<List<OfficePoint>>public List<List<OfficePoint>> GetTextContoursBounded(string text, double x, double y, double fontSize, int maximumPointCount, CancellationToken cancellationToken) #Returns contours while enforcing the maximum total point count.
Parameters
- text string
- x double
- y double
- fontSize double
- maximumPointCount int
- cancellationToken System.Threading.CancellationToken
Returns
List<List<OfficePoint>>public double LineHeight(double fontSize) #Returns the line height at the requested font size.
Parameters
- fontSize double
Returns
doublepublic double Measure(string text, double fontSize) #Measures text at the requested font size.
Parameters
- text string
- fontSize double
Returns
doublepublic static OfficeTrueTypeFont? TryLoad(string? path) #Attempts to load a standalone font or the first suitable face in a font collection.
Parameters
- path string?
- Path to a TrueType font file, including an OpenType file that uses TrueType glyf outlines.
Returns
OfficeTrueTypeFont? The loaded font, or null when the path or font data is invalid or inaccessible.public static OfficeTrueTypeFont? TryLoad(string? path, int? collectionIndex) #Attempts to load a specific face from a font collection.
Parameters
- path string?
- Path to a TrueType font file or collection, including OpenType fonts that use TrueType glyf outlines.
- collectionIndex int?
- Zero-based collection face index, or null to select the first suitable face.
Returns
OfficeTrueTypeFont? The loaded font, or null when the path, index, or font data is invalid or inaccessible.public static OfficeTrueTypeFont? TryLoad(string? path, int? collectionIndex, string? faceName) #Attempts to load a font face that matches an optional collection index and face name.
Parameters
- path string?
- Path to a TrueType font file or collection, including OpenType fonts that use TrueType glyf outlines.
- collectionIndex int?
- Zero-based collection face index, or null to search the collection.
- faceName string?
- Preferred family, full, or PostScript face name; null accepts any suitable face.
Returns
OfficeTrueTypeFont? The matching font, or null when the file cannot be read or no matching supported face exists.public static OfficeTrueTypeFont? TryLoad(byte[] data) #Attempts to decode a standalone font or the first suitable face in a font collection.
Parameters
- data byte[]
- Complete TrueType font data, including OpenType data that uses TrueType glyf outlines.
public static OfficeTrueTypeFont? TryLoad(byte[] data, int? collectionIndex) #Attempts to decode a specific face from in-memory font data.
Parameters
- data byte[]
- Complete TrueType font or collection data, including OpenType fonts that use TrueType glyf outlines.
- collectionIndex int?
- Zero-based collection face index, or null to select the first suitable face.
public static OfficeTrueTypeFont? TryLoad(byte[] data, int? collectionIndex, string? faceName) #Attempts to decode a font face matching an optional collection index and face name.
Parameters
- data byte[]
- Complete TrueType font or collection data, including OpenType fonts that use TrueType glyf outlines.
- collectionIndex int?
- Zero-based collection face index, or null to search the collection.
- faceName string?
- Preferred family, full, or PostScript face name; null accepts any suitable face.
Returns
OfficeTrueTypeFont? The matching font, or null when the data is malformed, unsupported, or contains no matching face.public static OfficeTrueTypeFont? TryLoadDefault() #Attempts to load a common platform font without using operating-system font APIs.
public static OfficeTrueTypeFont? TryLoadDefault(out string? resolvedPath) #Attempts to load a common platform font file without using platform font APIs.
Parameters
- resolvedPath string?
Returns
OfficeTrueTypeFont?public static OfficeTrueTypeFont? TryLoadFontFamily(string? fontFamily) #Attempts to load the first resolvable font from a CSS/Office-style font-family fallback list.
Parameters
- fontFamily string?
Returns
OfficeTrueTypeFont?public static OfficeTrueTypeFont? TryLoadFontFamily(string? fontFamily, out string? resolvedPath) #Attempts to load the first resolvable font from a CSS/Office-style font-family fallback list.
Parameters
- fontFamily string?
- resolvedPath string?
Returns
OfficeTrueTypeFont?public static OfficeTrueTypeFont? TryLoadFontFamilyForText(string? families, OfficeFontFaceDescriptor descriptor, string? text, out OfficeFontStyle resolvedStyle) #Resolves an installed family using the same numeric face ordering as document-scoped fonts.
Parameters
- families string?
- descriptor OfficeIMO.Drawing.OfficeFontFaceDescriptor
- text string?
- resolvedStyle OfficeIMO.Drawing.OfficeFontStyle
Returns
OfficeTrueTypeFont?Inherited Methods
Properties
public OfficeMathFontConstants? MathConstants { get; } #Static font math design metrics, when the selected face supplies a valid MATH table.
public string Fingerprint { get; } #Stable provider-defined identity for the decoded program and selected instance. The value must change when rendering-relevant configuration, such as variable-font axes, changes.
public string? DisplayName { get; } #Best-effort display name read from the font name table.
public int? CollectionIndex { get; } #Collection index when the font was loaded from a TrueType collection.
public OfficeFontFaceDescriptor FaceDescriptor { get; } #Face attributes declared by the font's OS/2 and head tables.
public bool IsOpenTypeCff { get; } #Whether the source uses CFF or CFF2 outlines.
public bool ProvidesComplexTextLayout { get; } #Whether measurement and contours already apply complete script shaping and bidirectional layout.