Table of Contents

Class FontFace

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll

The FontFace interface of the CSS Font Loading API represents a single usable font face.

[Value("FontFace")]
public class FontFace
Inheritance
FontFace
Inherited Members

Remarks

This interface defines the source of a font face, either a URL to an external resource or a buffer, and font properties such as style, weight, and so on.
For URL font sources it allows authors to trigger when the remote font is fetched and loaded, and to track loading status.

-_font-face

See also on MDN

Constructors

FontFace()

public FontFace()

FontFace(string, Union3, FontFaceDescriptors)

The FontFace() constructor creates a new FontFace object.

public FontFace(string family, Union3 source, FontFaceDescriptors descriptors = null)

Parameters

family string
source Union3
descriptors FontFaceDescriptors

Remarks

Properties

AscentOverride

The ascentOverride property of the FontFace interface returns and sets the ascent metric for the font, the height above the baseline that CSS uses to lay out line boxes in an inline formatting context.

[Value("ascentOverride")]
public string AscentOverride { get; set; }

Property Value

string

A string. The possible values are normal, indicating that the metric used should be obtained from the font file, or a percentage.This property accepts the same values as the @font-face/ascent-override descriptor.

Remarks

This property is equivalent to the @font-face/ascent-override descriptor of @font-face.

See also on MDN

DescentOverride

The descentOverride property of the FontFace interface returns and sets the value of the {{cssxref("@font-face/descent-override")}} descriptor.
The possible values are normal, indicating that the metric used should be obtained from the font file, or a percentage.

[Value("descentOverride")]
public string DescentOverride { get; set; }

Property Value

string

A string.

Remarks

Display

The display property of the FontFace interface determines how a font face is displayed based on whether and when it is downloaded and ready to use.
This property is equivalent to the CSS font-display descriptor.

[Value("display")]
public string Display { get; set; }

Property Value

string

A string with one of the following values.

Remarks

When this property is used, font loading has a timeline with three periods.
The lengths of the first two periods depend on the value of the property and the user agent.
(See below.)

See also on MDN

Family

The FontFace.family property allows the author to get or set the font family of a FontFace object.

[Value("family")]
public string Family { get; set; }

Property Value

string

A string.

Remarks

The value is used for name matching against a particular font face when styling elements using the font-family property.
Any name may be used, and this overrides any name specified in the underlying font data.

This property is equivalent to the @font-face/font-family descriptor of @font-face.

See also on MDN

FeatureSettings

The featureSettings property of the FontFace interface retrieves or sets infrequently used font features that are not available from a font's variant properties.

[Value("featureSettings")]
public string FeatureSettings { get; set; }

Property Value

string

A string containing a descriptor.

Remarks

This property is equivalent to the font-feature-settings descriptor.

See also on MDN

Features

[Value("features")]
public FontFaceFeatures Features { get; }

Property Value

FontFaceFeatures

LineGapOverride

The lineGapOverride property of the FontFace interface returns and sets the value of the {{cssxref("@font-face/line-gap-override")}} descriptor.
The possible values are normal, indicating that the metric used should be obtained from the font file, or a percentage.

[Value("lineGapOverride")]
public string LineGapOverride { get; set; }

Property Value

string

A string.

Remarks

Loaded

The loaded read-only property of the FontFace interface returns a {{jsxref('Promise')}} that resolves with the current FontFace object when the font specified in the object's constructor is done loading or rejects with a SyntaxError.

[Value("loaded")]
public Task<FontFace> Loaded { get; }

Property Value

Task<FontFace>

A 'Promise' that resolves with the current FontFace object.

Remarks

Palettes

[Value("palettes")]
public FontFacePalettes Palettes { get; }

Property Value

FontFacePalettes

Status

The status read-only property of the FontFace interface returns an enumerated value indicating the status of the font, one of &quot;unloaded&quot;, &quot;loading&quot;, &quot;loaded&quot;, or &quot;error&quot;.

[Value("status")]
public FontFaceLoadStatus Status { get; }

Property Value

FontFaceLoadStatus

One of &quot;unloaded&quot;, &quot;loading&quot;, &quot;loaded&quot;, or &quot;error&quot;.

Remarks

Stretch

The stretch property of the FontFace interface retrieves or sets how the font stretches.

[Value("stretch")]
public string Stretch { get; set; }

Property Value

string

A string containing a descriptor as it would be defined in a style sheet&apos;s _font-face rule.

Remarks

This property is equivalent to the @font-face/font-stretch descriptor.

See also on MDN

Style

The style property of the FontFace interface retrieves or sets the font's style.

[Value("style")]
public string Style { get; set; }

Property Value

string

A string containing the descriptors defined in the style sheet&apos;s _font-face rule.

Remarks

This property is equivalent to the @font-face/font-style descriptor.

See also on MDN

UnicodeRange

The unicodeRange property of the FontFace interface retrieves or sets the range of unicode code points encompassing the font.

[Value("unicodeRange")]
public string UnicodeRange { get; set; }

Property Value

string

A string containing a descriptor as it would appear in a style sheet&apos;s _font-face rule.

Remarks

This property is equivalent to the @font-face/unicode-range descriptor.

See also on MDN

VariationSettings

The variationSettings property of the FontFace interface retrieves or sets low-level OpenType or TrueType font variations.

[Value("variationSettings")]
public string VariationSettings { get; set; }

Property Value

string

A string containing a descriptor.

Remarks

This property is equivalent to the @font-face/font-variation-settings descriptor.

See also on MDN

Variations

[Value("variations")]
public FontFaceVariations Variations { get; }

Property Value

FontFaceVariations

Weight

The weight property of the FontFace interface retrieves or sets the weight of the font.

[Value("weight")]
public string Weight { get; set; }

Property Value

string

A string containing a descriptor as it would be defined in a style sheet&apos;s _font-face rule.

Remarks

This property is equivalent to the @font-face/font-weight descriptor.

See also on MDN

Methods

Load()

The load() method of the FontFace interface requests and loads a font whose source was specified as a URL. It returns a 'Promise' that resolves with the current FontFace object.

[Value("load")]
public Task<FontFace> Load()

Returns

Task<FontFace>

A 'Promise' that resolves with a reference to the current FontFace object when the font loads or rejects with a NetworkError DOMException if the loading process fails.

Remarks

If the source for the font face was specified as binary data, or the font FontFacestatus property of the font face is anything other than unloaded, then this method does nothing.

See also on MDN