• 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  /**
285   * @typedef UIFontConfig
286   * @syscap SystemCapability.ArkUI.ArkUI.Full
287   * @atomicservice
288   * @since 12
289   */
290  interface UIFontConfig {
291    /**
292     * The paths of system font files.
293     * @type { Array<string> }
294     * @syscap SystemCapability.ArkUI.ArkUI.Full
295     * @since 11
296     */
297    /**
298     * The paths of system font files.
299     * @type { Array<string> }
300     * @syscap SystemCapability.ArkUI.ArkUI.Full
301     * @atomicservice
302     * @since 12
303     */
304    fontDir: Array<string>;
305
306    /**
307     * The generic font info.
308     * @type { Array<UIFontGenericInfo> }
309     * @syscap SystemCapability.ArkUI.ArkUI.Full
310     * @since 11
311     */
312    /**
313     * The generic font info.
314     * @type { Array<UIFontGenericInfo> }
315     * @syscap SystemCapability.ArkUI.ArkUI.Full
316     * @atomicservice
317     * @since 12
318     */
319    generic: Array<UIFontGenericInfo>;
320
321    /**
322     * The fallback font info.
323     * @type { Array<UIFontFallbackGroupInfo> }
324     * @syscap SystemCapability.ArkUI.ArkUI.Full
325     * @since 11
326     */
327    /**
328     * The fallback font info.
329     * @type { Array<UIFontFallbackGroupInfo> }
330     * @syscap SystemCapability.ArkUI.ArkUI.Full
331     * @atomicservice
332     * @since 12
333     */
334    fallbackGroups: Array<UIFontFallbackGroupInfo>;
335  }
336
337  /**
338   * @typedef UIFontGenericInfo
339   * @syscap SystemCapability.ArkUI.ArkUI.Full
340   * @since 11
341   */
342  /**
343   * @typedef UIFontGenericInfo
344   * @syscap SystemCapability.ArkUI.ArkUI.Full
345   * @atomicservice
346   * @since 12
347   */
348  interface UIFontGenericInfo {
349    /**
350     * Name of the font set.
351     * @type { string }
352     * @syscap SystemCapability.ArkUI.ArkUI.Full
353     * @since 11
354     */
355    /**
356     * Name of the font set.
357     * @type { string }
358     * @syscap SystemCapability.ArkUI.ArkUI.Full
359     * @atomicservice
360     * @since 12
361     */
362    family: string;
363
364    /**
365     * Alias info of the font set.
366     * @type { Array<UIFontAliasInfo> }
367     * @syscap SystemCapability.ArkUI.ArkUI.Full
368     * @since 11
369     */
370    /**
371     * Alias info of the font set.
372     * @type { Array<UIFontAliasInfo> }
373     * @syscap SystemCapability.ArkUI.ArkUI.Full
374     * @atomicservice
375     * @since 12
376     */
377    alias: Array<UIFontAliasInfo>;
378
379    /**
380     * Adjust info of the font set.
381     * @type { Array<UIFontAdjustInfo> }
382     * @syscap SystemCapability.ArkUI.ArkUI.Full
383     * @since 11
384     */
385    /**
386     * Adjust info of the font set.
387     * @type { Array<UIFontAdjustInfo> }
388     * @syscap SystemCapability.ArkUI.ArkUI.Full
389     * @atomicservice
390     * @since 12
391     */
392    adjust: Array<UIFontAdjustInfo>;
393  }
394
395  /**
396   * @typedef UIFontAliasInfo
397   * @syscap SystemCapability.ArkUI.ArkUI.Full
398   * @since 11
399   */
400  /**
401   * @typedef UIFontAliasInfo
402   * @syscap SystemCapability.ArkUI.ArkUI.Full
403   * @atomicservice
404   * @since 12
405   */
406  interface UIFontAliasInfo {
407    /**
408     * Font set name.
409     * @type { string }
410     * @syscap SystemCapability.ArkUI.ArkUI.Full
411     * @since 11
412     */
413    /**
414     * Font set name.
415     * @type { string }
416     * @syscap SystemCapability.ArkUI.ArkUI.Full
417     * @atomicservice
418     * @since 12
419     */
420    name: string;
421
422    /**
423     * Weight the font set contains only fonts with, if weight = 0,
424     * this font set can contain fonts with any weight.
425     * @type { number }
426     * @syscap SystemCapability.ArkUI.ArkUI.Full
427     * @since 11
428     */
429    /**
430     * Weight the font set contains only fonts with, if weight = 0,
431     * this font set can contain fonts with any weight.
432     * @type { number }
433     * @syscap SystemCapability.ArkUI.ArkUI.Full
434     * @atomicservice
435     * @since 12
436     */
437    weight: number;
438  }
439
440  /**
441   * @typedef UIFontAdjustInfo
442   * @syscap SystemCapability.ArkUI.ArkUI.Full
443   * @since 11
444   */
445  /**
446   * @typedef UIFontAdjustInfo
447   * @syscap SystemCapability.ArkUI.ArkUI.Full
448   * @atomicservice
449   * @since 12
450   */
451  interface UIFontAdjustInfo {
452    /**
453     * Original weight of the font
454     * @type { number }
455     * @syscap SystemCapability.ArkUI.ArkUI.Full
456     * @since 11
457     */
458    /**
459     * Original weight of the font
460     * @type { number }
461     * @syscap SystemCapability.ArkUI.ArkUI.Full
462     * @atomicservice
463     * @since 12
464     */
465    weight: number;
466    /**
467     * Font weight displayed in the app
468     * @type { number }
469     * @syscap SystemCapability.ArkUI.ArkUI.Full
470     * @since 11
471     */
472    /**
473     * Font weight displayed in the app
474     * @type { number }
475     * @syscap SystemCapability.ArkUI.ArkUI.Full
476     * @atomicservice
477     * @since 12
478     */
479    to: number;
480  }
481
482  /**
483   * @typedef UIFontFallbackGroupInfo
484   * @syscap SystemCapability.ArkUI.ArkUI.Full
485   * @since 11
486   */
487  /**
488   * @typedef UIFontFallbackGroupInfo
489   * @syscap SystemCapability.ArkUI.ArkUI.Full
490   * @atomicservice
491   * @since 12
492   */
493  interface UIFontFallbackGroupInfo {
494    /**
495     * Indicates which font set uses following list for fallback font
496     * if the font set name is "", it means that the following list can be fallback font for all font sets.
497     * @type { string }
498     * @syscap SystemCapability.ArkUI.ArkUI.Full
499     * @since 11
500     */
501    /**
502     * Indicates which font set uses following list for fallback font
503     * if the font set name is "", it means that the following list can be fallback font for all font sets.
504     * @type { string }
505     * @syscap SystemCapability.ArkUI.ArkUI.Full
506     * @atomicservice
507     * @since 12
508     */
509    fontSetName: string;
510
511    /**
512     * Fallback font list related.
513     * @type { Array<UIFontFallbackInfo> }
514     * @syscap SystemCapability.ArkUI.ArkUI.Full
515     * @since 11
516     */
517    /**
518     * Fallback font list related.
519     * @type { Array<UIFontFallbackInfo> }
520     * @syscap SystemCapability.ArkUI.ArkUI.Full
521     * @atomicservice
522     * @since 12
523     */
524    fallback: Array<UIFontFallbackInfo>;
525  }
526
527  /**
528   * @typedef UIFontFallbackInfo
529   * @syscap SystemCapability.ArkUI.ArkUI.Full
530   * @since 11
531   */
532  /**
533   * @typedef UIFontFallbackInfo
534   * @syscap SystemCapability.ArkUI.ArkUI.Full
535   * @atomicservice
536   * @since 12
537   */
538  interface UIFontFallbackInfo {
539    /**
540     * Language that font set support.
541     * @type { string }
542     * @syscap SystemCapability.ArkUI.ArkUI.Full
543     * @since 11
544     */
545    /**
546     * Language that font set support.
547     * @type { string }
548     * @syscap SystemCapability.ArkUI.ArkUI.Full
549     * @atomicservice
550     * @since 12
551     */
552    language: string;
553
554    /**
555     * Font name related.
556     * @type { string }
557     * @syscap SystemCapability.ArkUI.ArkUI.Full
558     * @since 11
559     */
560    /**
561     * Font name related.
562     * @type { string }
563     * @syscap SystemCapability.ArkUI.ArkUI.Full
564     * @atomicservice
565     * @since 12
566     */
567    family: string;
568  }
569
570  /**
571   * Register a customized font in the FontManager.
572   *
573   * @param { FontOptions } options - FontOptions
574   * @syscap SystemCapability.ArkUI.ArkUI.Full
575   * @since 9
576   */
577  /**
578   * Register a customized font in the FontManager.
579   *
580   * @param { FontOptions } options - FontOptions
581   * @syscap SystemCapability.ArkUI.ArkUI.Full
582   * @atomicservice
583   * @since 11
584   */
585  function registerFont(options: FontOptions): void;
586
587  /**
588   * Gets a list of fonts supported by system.
589   *
590   * @returns { Array<string> } A list of font names
591   * @syscap SystemCapability.ArkUI.ArkUI.Full
592   * @since 10
593   */
594  /**
595   * Gets a list of fonts supported by system.
596   *
597   * @returns { Array<string> } A list of font names
598   * @syscap SystemCapability.ArkUI.ArkUI.Full
599   * @atomicservice
600   * @since 11
601   */
602  function getSystemFontList(): Array<string>;
603
604  /**
605   * Get font details according to the font name.
606   *
607   * @param { string } fontName - font name
608   * @returns { FontInfo } Returns the font info
609   * @syscap SystemCapability.ArkUI.ArkUI.Full
610   * @since 10
611   */
612  /**
613   * Get font details according to the font name.
614   *
615   * @param { string } fontName - font name
616   * @returns { FontInfo } Returns the font info
617   * @syscap SystemCapability.ArkUI.ArkUI.Full
618   * @atomicservice
619   * @since 11
620   */
621  function getFontByName(fontName: string): FontInfo;
622
623  /**
624   * Get font details according to the font name.
625   *
626   * @returns { UIFontConfig } Returns the ui font config
627   * @syscap SystemCapability.ArkUI.ArkUI.Full
628   * @since 11
629   */
630  /**
631   * Get font details according to the font name.
632   *
633   * @returns { UIFontConfig } Returns the ui font config
634   * @syscap SystemCapability.ArkUI.ArkUI.Full
635   * @atomicservice
636   * @since 12
637   */
638  function getUIFontConfig(): UIFontConfig;
639}
640
641export default font;
642