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.
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
familystringsourceUnion3descriptorsFontFaceDescriptors
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.
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.)
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.
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.
Features
[Value("features")]
public FontFaceFeatures Features { get; }
Property Value
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
Remarks
Palettes
[Value("palettes")]
public FontFacePalettes Palettes { get; }
Property Value
Status
The status read-only property of the FontFace interface returns an enumerated value indicating the status of the font, one of "unloaded", "loading", "loaded", or "error".
[Value("status")]
public FontFaceLoadStatus Status { get; }
Property Value
- FontFaceLoadStatus
One of
"unloaded","loading","loaded", or"error".
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's
_font-facerule.
Remarks
This property is equivalent to the @font-face/font-stretch descriptor.
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's
_font-facerule.
Remarks
This property is equivalent to the @font-face/font-style descriptor.
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's
_font-facerule.
Remarks
This property is equivalent to the @font-face/unicode-range descriptor.
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.
Variations
[Value("variations")]
public FontFaceVariations Variations { get; }
Property Value
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's
_font-facerule.
Remarks
This property is equivalent to the @font-face/font-weight descriptor.
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
FontFaceobject when the font loads or rejects with aNetworkErrorDOMException 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.