Interface: FontFace
Defined in: types/desktop-engine.d.ts:5229
A font of the content's own, as on the web (API 9). Once it's loaded and in DesktopEngine.fonts, a 2D canvas draws with it wherever its font names the family, before an installed font of that name. A content's fonts are its own: other content and other apps don't see them.
const face = new FontFace('Pixel', 'url(fonts/pixel.woff2)');
DesktopEngine.fonts.add(face);
await face.load();
context.font = '24px Pixel, monospace';The source is a CSS src list: url() of a file of the package (a path as require takes it) or of a defile:// file, a blob: URL (URL.createObjectURL) or a data: URL; local() of an installed font by its full or PostScript name. The first that loads is used; one whose format() names none of truetype, opentype, woff, woff2 and collection is skipped. Or the font's bytes, an ArrayBuffer, a typed array or a DataView, copied when it's made. Fonts aren't loaded from http(s) URLs: fetch() the file (with the "network" permission) and give the bytes. TrueType, OpenType, WOFF and WOFF2 files and collections (.ttc, their first font) of at most 64 MB.
Unlike in browsers, a face draws only once it's loaded: using its family in font doesn't start loading it. A canvas whose font names the family draws with it as soon as it loads, without setting font again. A face from bytes loads after the current task too (its status is "loading" until then). Characters the font lacks are drawn with a system font. An upright face is slanted for italic text; a lighter face isn't made bold.
Properties
ascentOverride
ascentOverride: string;Defined in: types/desktop-engine.d.ts:5240
descentOverride
descentOverride: string;Defined in: types/desktop-engine.d.ts:5241
display
display: string;Defined in: types/desktop-engine.d.ts:5239
family
family: string;Defined in: types/desktop-engine.d.ts:5231
The family name canvases use, without the quotes of a CSS string. Setting it throws a "SyntaxError" DOMException for an empty one
featureSettings
featureSettings: string;Defined in: types/desktop-engine.d.ts:5237
lineGapOverride
lineGapOverride: string;Defined in: types/desktop-engine.d.ts:5242
loaded
readonly loaded: Promise<FontFace>;Defined in: types/desktop-engine.d.ts:5250
Resolves with the face once it's loaded. Rejects with a "SyntaxError" DOMException when the family, a descriptor or the source isn't valid, or the bytes aren't a font; with a "NetworkError" one when no source loads (a file that isn't there, isn't a font, or an http(s) URL). A face that fails isn't reported as an unhandled rejection
status
readonly status: FontFaceLoadStatus;Defined in: types/desktop-engine.d.ts:5244
"unloaded" until load(), "loading", then "loaded" or "error"
stretch
stretch: string;Defined in: types/desktop-engine.d.ts:5235
style
style: string;Defined in: types/desktop-engine.d.ts:5233
Setting a value that isn't valid throws a "SyntaxError" DOMException, here and for the other descriptors
unicodeRange
unicodeRange: string;Defined in: types/desktop-engine.d.ts:5236
variationSettings
variationSettings: string;Defined in: types/desktop-engine.d.ts:5238
weight
weight: string;Defined in: types/desktop-engine.d.ts:5234
Methods
load()
load(): Promise<FontFace>;Defined in: types/desktop-engine.d.ts:5252
Starts loading a face made from a src list, once; returns loaded
Returns
Promise<FontFace>
