Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/

API Reference

Class

OfficeTrueTypeFont

Namespace OfficeIMO.Drawing
Assembly OfficeIMO.Core
Implements
IOfficeBoundedFontProgram IOfficeFontProgram IOfficeFontBaselineMetrics IOfficeVariableFontProgram IOfficeColorFontProgram IOfficeMathFontProgram IOfficeMathGlyphProgram
Modifiers sealed

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.

Accepted by parameters 1

Methods

public Double BaselineOffset(Double fontSize) #
Returns: Double

Returns the distance from the top of the face line box to its baseline.

Parameters

fontSize System.Double requiredposition: 0
public List<List<OfficePoint>> GetTextContours(String text, Double x, Double y, Double fontSize) #
Returns: List<List<OfficePoint>>

Reads flattened fill contours for the supplied text at a top-left baseline box.

Parameters

text System.String requiredposition: 0
x System.Double requiredposition: 1
y System.Double requiredposition: 2
fontSize System.Double requiredposition: 3
public List<List<OfficePoint>> GetTextContoursBounded(String text, Double x, Double y, Double fontSize, Int32 maximumPointCount, CancellationToken cancellationToken) #
Returns: List<List<OfficePoint>>

Returns contours while enforcing the maximum total point count.

Parameters

text System.String requiredposition: 0
x System.Double requiredposition: 1
y System.Double requiredposition: 2
fontSize System.Double requiredposition: 3
maximumPointCount System.Int32 requiredposition: 4
cancellationToken System.Threading.CancellationToken requiredposition: 5
public Double LineHeight(Double fontSize) #
Returns: Double

Returns the line height at the requested font size.

Parameters

fontSize System.Double requiredposition: 0
public Double Measure(String text, Double fontSize) #
Returns: Double

Measures text at the requested font size.

Parameters

text System.String requiredposition: 0
fontSize System.Double requiredposition: 1
TryLoad 6 overloads
public static OfficeTrueTypeFont? TryLoad(String? path) #
Returns: OfficeTrueTypeFont?

Attempts to load a standalone font or the first suitable face in a font collection.

Parameters

path System.String? requiredposition: 0
Path to a TrueType font file, including an OpenType file that uses TrueType glyf outlines.

Returns

The loaded font, or null when the path or font data is invalid or inaccessible.

public static OfficeTrueTypeFont? TryLoad(String? path, Int32? collectionIndex) #
Returns: OfficeTrueTypeFont?

Attempts to load a specific face from a font collection.

Parameters

path System.String? requiredposition: 0
Path to a TrueType font file or collection, including OpenType fonts that use TrueType glyf outlines.
collectionIndex System.Int32? requiredposition: 1
Zero-based collection face index, or null to select the first suitable face.

Returns

The loaded font, or null when the path, index, or font data is invalid or inaccessible.

public static OfficeTrueTypeFont? TryLoad(String? path, Int32? collectionIndex, String? faceName) #
Returns: OfficeTrueTypeFont?

Attempts to load a font face that matches an optional collection index and face name.

Parameters

path System.String? requiredposition: 0
Path to a TrueType font file or collection, including OpenType fonts that use TrueType glyf outlines.
collectionIndex System.Int32? requiredposition: 1
Zero-based collection face index, or null to search the collection.
faceName System.String? requiredposition: 2
Preferred family, full, or PostScript face name; null accepts any suitable face.

Returns

The matching font, or null when the file cannot be read or no matching supported face exists.

public static OfficeTrueTypeFont? TryLoad(Byte[] data) #
Returns: OfficeTrueTypeFont?

Attempts to decode a standalone font or the first suitable face in a font collection.

Parameters

data System.Byte[] requiredposition: 0
Complete TrueType font data, including OpenType data that uses TrueType glyf outlines.

Returns

The decoded font, or null when the data is unsupported or malformed.

public static OfficeTrueTypeFont? TryLoad(Byte[] data, Int32? collectionIndex) #
Returns: OfficeTrueTypeFont?

Attempts to decode a specific face from in-memory font data.

Parameters

data System.Byte[] requiredposition: 0
Complete TrueType font or collection data, including OpenType fonts that use TrueType glyf outlines.
collectionIndex System.Int32? requiredposition: 1
Zero-based collection face index, or null to select the first suitable face.

Returns

The decoded font, or null when the data or requested index is invalid.

public static OfficeTrueTypeFont? TryLoad(Byte[] data, Int32? collectionIndex, String? faceName) #
Returns: OfficeTrueTypeFont?

Attempts to decode a font face matching an optional collection index and face name.

Parameters

data System.Byte[] requiredposition: 0
Complete TrueType font or collection data, including OpenType fonts that use TrueType glyf outlines.
collectionIndex System.Int32? requiredposition: 1
Zero-based collection face index, or null to search the collection.
faceName System.String? requiredposition: 2
Preferred family, full, or PostScript face name; null accepts any suitable face.

Returns

The matching font, or null when the data is malformed, unsupported, or contains no matching face.

TryLoadDefault 2 overloads
public static OfficeTrueTypeFont? TryLoadDefault() #
Returns: OfficeTrueTypeFont?

Attempts to load a common platform font without using operating-system font APIs.

Returns

The first suitable font found, or null when none can be loaded.

public static OfficeTrueTypeFont? TryLoadDefault(out String? resolvedPath) #
Returns: OfficeTrueTypeFont?

Attempts to load a common platform font file without using platform font APIs.

Parameters

resolvedPath System.String? requiredposition: 0
TryLoadFontFamily 2 overloads
public static OfficeTrueTypeFont? TryLoadFontFamily(String? fontFamily) #
Returns: OfficeTrueTypeFont?

Attempts to load the first resolvable font from a CSS/Office-style font-family fallback list.

Parameters

fontFamily System.String? requiredposition: 0
public static OfficeTrueTypeFont? TryLoadFontFamily(String? fontFamily, out String? resolvedPath) #
Returns: OfficeTrueTypeFont?

Attempts to load the first resolvable font from a CSS/Office-style font-family fallback list.

Parameters

fontFamily System.String? requiredposition: 0
resolvedPath System.String? requiredposition: 1
public static OfficeTrueTypeFont? TryLoadFontFamilyForText(String? families, OfficeFontFaceDescriptor descriptor, String? text, out OfficeFontStyle resolvedStyle) #
Returns: OfficeTrueTypeFont?

Resolves an installed family using the same numeric face ordering as document-scoped fonts.

Parameters

families System.String? requiredposition: 0
descriptor OfficeIMO.Drawing.OfficeFontFaceDescriptor requiredposition: 1
text System.String? requiredposition: 2
resolvedStyle OfficeIMO.Drawing.OfficeFontStyle requiredposition: 3

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 Int32? 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 Boolean IsOpenTypeCff { get; } #

Whether the source uses CFF or CFF2 outlines.

public Boolean ProvidesComplexTextLayout { get; } #

Whether measurement and contours already apply complete script shaping and bidirectional layout.