• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @namespace font
18 * @syscap SystemCapability.ArkUI.ArkUI.Full
19 * @since 9
20 */
21declare namespace font {
22  /**
23   * @typedef FontOptions
24   * @syscap SystemCapability.ArkUI.ArkUI.Full
25   * @since 9
26   */
27  interface FontOptions {
28
29    /**
30     * The font name to register.
31     *
32     * @type { string | Resource }
33     * @syscap SystemCapability.ArkUI.ArkUI.Full
34     * @since 9
35     */
36    /**
37     * The font name to register.
38     *
39     * @type { string | Resource }
40     * @syscap SystemCapability.ArkUI.ArkUI.Full
41     * @since 10
42     */
43    familyName: string | Resource;
44
45    /**
46     * The path of the font file.
47     *
48     * @type { string | Resource }
49     * @syscap SystemCapability.ArkUI.ArkUI.Full
50     * @since 9
51     */
52    /**
53     * The path of the font file.
54     *
55     * @type { string | Resource }
56     * @syscap SystemCapability.ArkUI.ArkUI.Full
57     * @since 10
58     */
59    familySrc: string | Resource;
60  }
61
62  /**
63   * @typedef FontInfo
64   * @syscap SystemCapability.ArkUI.ArkUI.Full
65   * @since 10
66   */
67  interface FontInfo {
68
69    /**
70     * The path of the font file.
71     *
72     * @type { string }
73     * @syscap SystemCapability.ArkUI.ArkUI.Full
74     * @since 10
75     */
76    path: string;
77
78    /**
79     * The name of postscript.
80     *
81     * @type { string }
82     * @syscap SystemCapability.ArkUI.ArkUI.Full
83     * @since 10
84     */
85    postScriptName: string;
86
87    /**
88     * The font name.
89     *
90     * @type { string }
91     * @syscap SystemCapability.ArkUI.ArkUI.Full
92     * @since 10
93     */
94    fullName: string;
95
96    /**
97     * A set of fonts with a common design.
98     *
99     * @type { string }
100     * @syscap SystemCapability.ArkUI.ArkUI.Full
101     * @since 10
102     */
103    family: string;
104
105    /**
106     * A subset of the font family.
107     *
108     * @type { string }
109     * @syscap SystemCapability.ArkUI.ArkUI.Full
110     * @since 10
111     */
112    subfamily: string;
113
114    /**
115     * The weight of the font.
116     *
117     * @type { number }
118     * @syscap SystemCapability.ArkUI.ArkUI.Full
119     * @since 10
120     */
121    weight: number;
122
123    /**
124     * The width of the font style.
125     *
126     * @type { number }
127     * @syscap SystemCapability.ArkUI.ArkUI.Full
128     * @since 10
129     */
130    width: number;
131
132    /**
133     * Whether it is italic.
134     *
135     * @type { boolean }
136     * @syscap SystemCapability.ArkUI.ArkUI.Full
137     * @since 10
138     */
139    italic: boolean;
140
141    /**
142     * Whether it is compact.
143     *
144     * @type { boolean }
145     * @syscap SystemCapability.ArkUI.ArkUI.Full
146     * @since 10
147     */
148    monoSpace: boolean;
149
150    /**
151     * Whether symbol fonts are supported.
152     *
153     * @type { boolean }
154     * @syscap SystemCapability.ArkUI.ArkUI.Full
155     * @since 10
156     */
157    symbolic: boolean;
158  }
159
160  /**
161   * Register a customized font in the FontManager.
162   *
163   * @param { FontOptions } options - FontOptions
164   * @syscap SystemCapability.ArkUI.ArkUI.Full
165   * @since 9
166   */
167  function registerFont(options: FontOptions): void;
168
169  /**
170   * Gets a list of fonts supported by system.
171   *
172   * @returns { Array<string> } A list of font names
173   * @syscap SystemCapability.ArkUI.ArkUI.Full
174   * @since 10
175   */
176  function getSystemFontList(): Array<string>;
177
178  /**
179   * Get font details according to the font name.
180   *
181   * @param { string } fontName - font name
182   * @returns { FontInfo } Returns the font info
183   * @syscap SystemCapability.ArkUI.ArkUI.Full
184   * @since 10
185   */
186  function getFontByName(fontName: string): FontInfo;
187}
188
189export default font;
190