deno.land / x / skia_canvas@0.5.8 / src / font.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import ffi, { cstr, readCstr } from "./ffi.ts";
const { fonts_register_dir, fonts_register_memory, fonts_register_path, fonts_set_alias, setup_font_collection, load_system_fonts, fonts_count, fonts_family,} = ffi;
setup_font_collection();const SYSTEM_FONTS = Deno.env.get("CANVAS_DISABLE_SYSTEM_FONTS") == "1" ? 0 : load_system_fonts();
/** * Manage fonts to be used by Skia. */export class Fonts { /** * At startup we load the system fonts, this property * gives the count of system fonts loaded. * * If you want to disable loading system fonts, set the * `CANVAS_DISABLE_SYSTEM_FONTS` environment variable to `1`. */ static get systemFontCount(): number { return SYSTEM_FONTS; }
/** * Get number of font families registered. */ static get famliliesCount(): number { return fonts_count(); }
/** * Get a list of all available font families. */ static get families(): string[] { const count = fonts_count(); const families = new Array<string>(count); for (let i = 0; i < count; i++) { families[i] = readCstr(fonts_family(i)); } return families; }
/** * Register all fonts in a directory. */ static registerDir(dir: string): number { return fonts_register_dir(cstr(dir)); }
/** Register a font either from file or in memory buffer */ static register(path: string): void; static register(data: Uint8Array, alias?: string): void; static register(path: string | Uint8Array, alias?: string) { if (path instanceof Uint8Array) { fonts_register_memory(path, path.length, alias ? cstr(alias) : null); } else { fonts_register_path(cstr(path)); } }
/** * Set alias for a font family. */ static setAlias(alias: string, family: string) { fonts_set_alias(cstr(alias), cstr(family)); }}
skia_canvas

Version Info

Tagged at
8 months ago