• 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 * @file
18 * @kit ArkUI
19 */
20
21/**
22 * @namespace font
23 * @syscap SystemCapability.ArkUI.ArkUI.Full
24 * @since 9
25 */
26/**
27 * @namespace font
28 * @syscap SystemCapability.ArkUI.ArkUI.Full
29 * @atomicservice
30 * @since 11
31 */
32declare namespace font {
33  /**
34   * @typedef FontOptions
35   * @syscap SystemCapability.ArkUI.ArkUI.Full
36   * @since 9
37   */
38  /**
39   * @typedef FontOptions
40   * @syscap SystemCapability.ArkUI.ArkUI.Full
41   * @atomicservice
42   * @since 11
43   */
44  interface FontOptions {
45
46    /**
47     * The font name to register.
48     *
49     * @type { string }
50     * @syscap SystemCapability.ArkUI.ArkUI.Full
51     * @since 9
52     */
53    /**
54     * The font name to register.
55     *
56     * @type { string | Resource }
57     * @syscap SystemCapability.ArkUI.ArkUI.Full
58     * @since 10
59     */
60    /**
61     * The font name to register.
62     *
63     * @type { string | Resource }
64     * @syscap SystemCapability.ArkUI.ArkUI.Full
65     * @atomicservice
66     * @since 11
67     */
68    familyName: string | Resource;
69
70    /**
71     * The path of the font file.
72     *
73     * @type { string }
74     * @syscap SystemCapability.ArkUI.ArkUI.Full
75     * @since 9
76     */
77    /**
78     * The path of the font file.
79     *
80     * @type { string | Resource }
81     * @syscap SystemCapability.ArkUI.ArkUI.Full
82     * @since 10
83     */
84    /**
85     * The path of the font file.
86     *
87     * @type { string | Resource }
88     * @syscap SystemCapability.ArkUI.ArkUI.Full
89     * @atomicservice
90     * @since 11
91     */
92    familySrc: string | Resource;
93  }
94
95  /**
96   * @typedef FontInfo
97   * @syscap SystemCapability.ArkUI.ArkUI.Full
98   * @since 10
99   */
100  /**
101   * @typedef FontInfo
102   * @syscap SystemCapability.ArkUI.ArkUI.Full
103   * @atomicservice
104   * @since 11
105   */
106  interface FontInfo {
107
108    /**
109     * The path of the font file.
110     *
111     * @type { string }
112     * @syscap SystemCapability.ArkUI.ArkUI.Full
113     * @since 10
114     */
115    /**
116     * The path of the font file.
117     *
118     * @type { string }
119     * @syscap SystemCapability.ArkUI.ArkUI.Full
120     * @atomicservice
121     * @since 11
122     */
123    path: string;
124
125    /**
126     * The name of postscript.
127     *
128     * @type { string }
129     * @syscap SystemCapability.ArkUI.ArkUI.Full
130     * @since 10
131     */
132    /**
133     * The name of postscript.
134     *
135     * @type { string }
136     * @syscap SystemCapability.ArkUI.ArkUI.Full
137     * @atomicservice
138     * @since 11
139     */
140    postScriptName: string;
141
142    /**
143     * The font name.
144     *
145     * @type { string }
146     * @syscap SystemCapability.ArkUI.ArkUI.Full
147     * @since 10
148     */
149    /**
150     * The font name.
151     *
152     * @type { string }
153     * @syscap SystemCapability.ArkUI.ArkUI.Full
154     * @atomicservice
155     * @since 11
156     */
157    fullName: string;
158
159    /**
160     * A set of fonts with a common design.
161     *
162     * @type { string }
163     * @syscap SystemCapability.ArkUI.ArkUI.Full
164     * @since 10
165     */
166    /**
167     * A set of fonts with a common design.
168     *
169     * @type { string }
170     * @syscap SystemCapability.ArkUI.ArkUI.Full
171     * @atomicservice
172     * @since 11
173     */
174    family: string;
175
176    /**
177     * A subset of the font family.
178     *
179     * @type { string }
180     * @syscap SystemCapability.ArkUI.ArkUI.Full
181     * @since 10
182     */
183    /**
184     * A subset of the font family.
185     *
186     * @type { string }
187     * @syscap SystemCapability.ArkUI.ArkUI.Full
188     * @atomicservice
189     * @since 11
190     */
191    subfamily: string;
192
193    /**
194     * The weight of the font.
195     *
196     * @type { number }
197     * @syscap SystemCapability.ArkUI.ArkUI.Full
198     * @since 10
199     */
200    /**
201     * The weight of the font.
202     *
203     * @type { number }
204     * @syscap SystemCapability.ArkUI.ArkUI.Full
205     * @atomicservice
206     * @since 11
207     */
208    weight: number;
209
210    /**
211     * The width of the font style.
212     *
213     * @type { number }
214     * @syscap SystemCapability.ArkUI.ArkUI.Full
215     * @since 10
216     */
217    /**
218     * The width of the font style.
219     *
220     * @type { number }
221     * @syscap SystemCapability.ArkUI.ArkUI.Full
222     * @atomicservice
223     * @since 11
224     */
225    width: number;
226
227    /**
228     * Whether it is italic.
229     *
230     * @type { boolean }
231     * @syscap SystemCapability.ArkUI.ArkUI.Full
232     * @since 10
233     */
234    /**
235     * Whether it is italic.
236     *
237     * @type { boolean }
238     * @syscap SystemCapability.ArkUI.ArkUI.Full
239     * @atomicservice
240     * @since 11
241     */
242    italic: boolean;
243
244    /**
245     * Whether it is compact.
246     *
247     * @type { boolean }
248     * @syscap SystemCapability.ArkUI.ArkUI.Full
249     * @since 10
250     */
251    /**
252     * Whether it is compact.
253     *
254     * @type { boolean }
255     * @syscap SystemCapability.ArkUI.ArkUI.Full
256     * @atomicservice
257     * @since 11
258     */
259    monoSpace: boolean;
260
261    /**
262     * Whether symbol fonts are supported.
263     *
264     * @type { boolean }
265     * @syscap SystemCapability.ArkUI.ArkUI.Full
266     * @since 10
267     */
268    /**
269     * Whether symbol fonts are supported.
270     *
271     * @type { boolean }
272     * @syscap SystemCapability.ArkUI.ArkUI.Full
273     * @atomicservice
274     * @since 11
275     */
276    symbolic: boolean;
277  }
278
279  /**
280   * @typedef UIFontConfig
281   * @syscap SystemCapability.ArkUI.ArkUI.Full
282   * @since 11
283   */
284  interface UIFontConfig {
285    /**
286     * The paths of system font files.
287     * @type { Array<string> }
288     * @syscap SystemCapability.ArkUI.ArkUI.Full
289     * @since 11
290     */
291    fontDir: Array<string>;
292
293    /**
294     * The generic font info.
295     * @type { Array<UIFontGenericInfo> }
296     * @syscap SystemCapability.ArkUI.ArkUI.Full
297     * @since 11
298     */
299    generic: Array<UIFontGenericInfo>;
300
301    /**
302     * The fallback font info.
303     * @type { Array<UIFontFallbackGroupInfo> }
304     * @syscap SystemCapability.ArkUI.ArkUI.Full
305     * @since 11
306     */
307    fallbackGroups: Array<UIFontFallbackGroupInfo>;
308  }
309
310  /**
311   * @typedef UIFontGenericInfo
312   * @syscap SystemCapability.ArkUI.ArkUI.Full
313   * @since 11
314   */
315  interface UIFontGenericInfo {
316    /**
317     * Name of the font set.
318     * @type { string }
319     * @syscap SystemCapability.ArkUI.ArkUI.Full
320     * @since 11
321     */
322    family: string;
323
324    /**
325     * Alias info of the font set.
326     * @type { Array<UIFontAliasInfo> }
327     * @syscap SystemCapability.ArkUI.ArkUI.Full
328     * @since 11
329     */
330    alias: Array<UIFontAliasInfo>;
331
332    /**
333     * Adjust info of the font set.
334     * @type { Array<UIFontAdjustInfo> }
335     * @syscap SystemCapability.ArkUI.ArkUI.Full
336     * @since 11
337     */
338    adjust: Array<UIFontAdjustInfo>;
339  }
340
341  /**
342   * @typedef UIFontAliasInfo
343   * @syscap SystemCapability.ArkUI.ArkUI.Full
344   * @since 11
345   */
346  interface UIFontAliasInfo {
347    /**
348     * Font set name.
349     * @type { string }
350     * @syscap SystemCapability.ArkUI.ArkUI.Full
351     * @since 11
352     */
353    name: string;
354
355    /**
356     * Weight the font set contains only fonts with, if weight = 0,
357     * this font set can contain fonts with any weight.
358     * @type { number }
359     * @syscap SystemCapability.ArkUI.ArkUI.Full
360     * @since 11
361     */
362    weight: number;
363  }
364
365  /**
366   * @typedef UIFontAdjustInfo
367   * @syscap SystemCapability.ArkUI.ArkUI.Full
368   * @since 11
369   */
370  interface UIFontAdjustInfo {
371    /**
372     * Original weight of the font
373     * @type { number }
374     * @syscap SystemCapability.ArkUI.ArkUI.Full
375     * @since 11
376     */
377    weight: number;
378    /**
379     * Font weight displayed in the app
380     * @type { number }
381     * @syscap SystemCapability.ArkUI.ArkUI.Full
382     * @since 11
383     */
384    to: number;
385  }
386
387  /**
388   * @typedef UIFontFallbackGroupInfo
389   * @syscap SystemCapability.ArkUI.ArkUI.Full
390   * @since 11
391   */
392  interface UIFontFallbackGroupInfo {
393    /**
394     * Indicates which font set uses following list for fallback font
395     * if the font set name is "", it means that the following list can be fallback font for all font sets.
396     * @type { string }
397     * @syscap SystemCapability.ArkUI.ArkUI.Full
398     * @since 11
399     */
400    fontSetName: string;
401
402    /**
403     * Fallback font list related.
404     * @type { Array<UIFontFallbackInfo> }
405     * @syscap SystemCapability.ArkUI.ArkUI.Full
406     * @since 11
407     */
408    fallback: Array<UIFontFallbackInfo>;
409  }
410
411  /**
412   * @typedef UIFontFallbackInfo
413   * @syscap SystemCapability.ArkUI.ArkUI.Full
414   * @since 11
415   */
416  interface UIFontFallbackInfo {
417    /**
418     * Language that font set support.
419     * @type { string }
420     * @syscap SystemCapability.ArkUI.ArkUI.Full
421     * @since 11
422     */
423    language: string;
424
425    /**
426     * Font name related.
427     * @type { string }
428     * @syscap SystemCapability.ArkUI.ArkUI.Full
429     * @since 11
430     */
431    family: string;
432  }
433
434  /**
435   * Register a customized font in the FontManager.
436   *
437   * @param { FontOptions } options - FontOptions
438   * @syscap SystemCapability.ArkUI.ArkUI.Full
439   * @since 9
440   */
441  /**
442   * Register a customized font in the FontManager.
443   *
444   * @param { FontOptions } options - FontOptions
445   * @syscap SystemCapability.ArkUI.ArkUI.Full
446   * @atomicservice
447   * @since 11
448   */
449  function registerFont(options: FontOptions): void;
450
451  /**
452   * Gets a list of fonts supported by system.
453   *
454   * @returns { Array<string> } A list of font names
455   * @syscap SystemCapability.ArkUI.ArkUI.Full
456   * @since 10
457   */
458  /**
459   * Gets a list of fonts supported by system.
460   *
461   * @returns { Array<string> } A list of font names
462   * @syscap SystemCapability.ArkUI.ArkUI.Full
463   * @atomicservice
464   * @since 11
465   */
466  function getSystemFontList(): Array<string>;
467
468  /**
469   * Get font details according to the font name.
470   *
471   * @param { string } fontName - font name
472   * @returns { FontInfo } Returns the font info
473   * @syscap SystemCapability.ArkUI.ArkUI.Full
474   * @since 10
475   */
476  /**
477   * Get font details according to the font name.
478   *
479   * @param { string } fontName - font name
480   * @returns { FontInfo } Returns the font info
481   * @syscap SystemCapability.ArkUI.ArkUI.Full
482   * @atomicservice
483   * @since 11
484   */
485  function getFontByName(fontName: string): FontInfo;
486
487  /**
488   * Get font details according to the font name.
489   *
490   * @returns { UIFontConfig } Returns the ui font config
491   * @syscap SystemCapability.ArkUI.ArkUI.Full
492   * @since 11
493   */
494  function getUIFontConfig(): UIFontConfig;
495}
496
497export default font;
498