• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022-2024 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 */
32/**
33 * @namespace font
34 * @syscap SystemCapability.ArkUI.ArkUI.Full
35 * @crossplatform
36 * @atomicservice
37 * @since 12
38 */
39declare namespace font {
40  /**
41   * @typedef FontOptions
42   * @syscap SystemCapability.ArkUI.ArkUI.Full
43   * @since 9
44   */
45  /**
46   * @typedef FontOptions
47   * @syscap SystemCapability.ArkUI.ArkUI.Full
48   * @atomicservice
49   * @since 11
50   */
51  /**
52   * @typedef FontOptions
53   * @syscap SystemCapability.ArkUI.ArkUI.Full
54   * @crossplatform
55   * @atomicservice
56   * @since 12
57   */
58  interface FontOptions {
59
60    /**
61     * The font name to register.
62     *
63     * @type { string }
64     * @syscap SystemCapability.ArkUI.ArkUI.Full
65     * @since 9
66     */
67    /**
68     * The font name to register.
69     *
70     * @type { string | Resource }
71     * @syscap SystemCapability.ArkUI.ArkUI.Full
72     * @since 10
73     */
74    /**
75     * The font name to register.
76     *
77     * @type { string | Resource }
78     * @syscap SystemCapability.ArkUI.ArkUI.Full
79     * @atomicservice
80     * @since 11
81     */
82    /**
83     * The font name to register.
84     *
85     * @type { string | Resource }
86     * @syscap SystemCapability.ArkUI.ArkUI.Full
87     * @crossplatform
88     * @atomicservice
89     * @since 12
90     */
91    familyName: string | Resource;
92
93    /**
94     * The path of the font file.
95     *
96     * @type { string }
97     * @syscap SystemCapability.ArkUI.ArkUI.Full
98     * @since 9
99     */
100    /**
101     * The path of the font file.
102     *
103     * @type { string | Resource }
104     * @syscap SystemCapability.ArkUI.ArkUI.Full
105     * @since 10
106     */
107    /**
108     * The path of the font file.
109     *
110     * @type { string | Resource }
111     * @syscap SystemCapability.ArkUI.ArkUI.Full
112     * @atomicservice
113     * @since 11
114     */
115    /**
116     * The path of the font file.
117     *
118     * @type { string | Resource }
119     * @syscap SystemCapability.ArkUI.ArkUI.Full
120     * @crossplatform
121     * @atomicservice
122     * @since 12
123     */
124    familySrc: string | Resource;
125  }
126
127  /**
128   * @typedef FontInfo
129   * @syscap SystemCapability.ArkUI.ArkUI.Full
130   * @since 10
131   */
132  /**
133   * @typedef FontInfo
134   * @syscap SystemCapability.ArkUI.ArkUI.Full
135   * @atomicservice
136   * @since 11
137   */
138  /**
139   * @typedef FontInfo
140   * @syscap SystemCapability.ArkUI.ArkUI.Full
141   * @crossplatform
142   * @atomicservice
143   * @since 12
144   */
145  interface FontInfo {
146
147    /**
148     * The path of the font file.
149     *
150     * @type { string }
151     * @syscap SystemCapability.ArkUI.ArkUI.Full
152     * @since 10
153     */
154    /**
155     * The path of the font file.
156     *
157     * @type { string }
158     * @syscap SystemCapability.ArkUI.ArkUI.Full
159     * @atomicservice
160     * @since 11
161     */
162    /**
163     * The path of the font file.
164     *
165     * @type { string }
166     * @syscap SystemCapability.ArkUI.ArkUI.Full
167     * @crossplatform
168     * @atomicservice
169     * @since 12
170     */
171    path: string;
172
173    /**
174     * The name of postscript.
175     *
176     * @type { string }
177     * @syscap SystemCapability.ArkUI.ArkUI.Full
178     * @since 10
179     */
180    /**
181     * The name of postscript.
182     *
183     * @type { string }
184     * @syscap SystemCapability.ArkUI.ArkUI.Full
185     * @atomicservice
186     * @since 11
187     */
188    /**
189     * The name of postscript.
190     *
191     * @type { string }
192     * @syscap SystemCapability.ArkUI.ArkUI.Full
193     * @crossplatform
194     * @atomicservice
195     * @since 12
196     */
197    postScriptName: string;
198
199    /**
200     * The font name.
201     *
202     * @type { string }
203     * @syscap SystemCapability.ArkUI.ArkUI.Full
204     * @since 10
205     */
206    /**
207     * The font name.
208     *
209     * @type { string }
210     * @syscap SystemCapability.ArkUI.ArkUI.Full
211     * @atomicservice
212     * @since 11
213     */
214    /**
215     * The font name.
216     *
217     * @type { string }
218     * @syscap SystemCapability.ArkUI.ArkUI.Full
219     * @crossplatform
220     * @atomicservice
221     * @since 12
222     */
223    fullName: string;
224
225    /**
226     * A set of fonts with a common design.
227     *
228     * @type { string }
229     * @syscap SystemCapability.ArkUI.ArkUI.Full
230     * @since 10
231     */
232    /**
233     * A set of fonts with a common design.
234     *
235     * @type { string }
236     * @syscap SystemCapability.ArkUI.ArkUI.Full
237     * @atomicservice
238     * @since 11
239     */
240    /**
241     * A set of fonts with a common design.
242     *
243     * @type { string }
244     * @syscap SystemCapability.ArkUI.ArkUI.Full
245     * @crossplatform
246     * @atomicservice
247     * @since 12
248     */
249    family: string;
250
251    /**
252     * A subset of the font family.
253     *
254     * @type { string }
255     * @syscap SystemCapability.ArkUI.ArkUI.Full
256     * @since 10
257     */
258    /**
259     * A subset of the font family.
260     *
261     * @type { string }
262     * @syscap SystemCapability.ArkUI.ArkUI.Full
263     * @atomicservice
264     * @since 11
265     */
266    /**
267     * A subset of the font family.
268     *
269     * @type { string }
270     * @syscap SystemCapability.ArkUI.ArkUI.Full
271     * @crossplatform
272     * @atomicservice
273     * @since 12
274     */
275    subfamily: string;
276
277    /**
278     * The weight of the font.
279     *
280     * @type { number }
281     * @syscap SystemCapability.ArkUI.ArkUI.Full
282     * @since 10
283     */
284    /**
285     * The weight of the font.
286     *
287     * @type { number }
288     * @syscap SystemCapability.ArkUI.ArkUI.Full
289     * @atomicservice
290     * @since 11
291     */
292    /**
293     * The weight of the font.
294     *
295     * @type { number }
296     * @syscap SystemCapability.ArkUI.ArkUI.Full
297     * @crossplatform
298     * @atomicservice
299     * @since 12
300     */
301    weight: number;
302
303    /**
304     * The width of the font style.
305     *
306     * @type { number }
307     * @syscap SystemCapability.ArkUI.ArkUI.Full
308     * @since 10
309     */
310    /**
311     * The width of the font style.
312     *
313     * @type { number }
314     * @syscap SystemCapability.ArkUI.ArkUI.Full
315     * @atomicservice
316     * @since 11
317     */
318    /**
319     * The width of the font style.
320     *
321     * @type { number }
322     * @syscap SystemCapability.ArkUI.ArkUI.Full
323     * @crossplatform
324     * @atomicservice
325     * @since 12
326     */
327    width: number;
328
329    /**
330     * Whether it is italic.
331     *
332     * @type { boolean }
333     * @syscap SystemCapability.ArkUI.ArkUI.Full
334     * @since 10
335     */
336    /**
337     * Whether it is italic.
338     *
339     * @type { boolean }
340     * @syscap SystemCapability.ArkUI.ArkUI.Full
341     * @atomicservice
342     * @since 11
343     */
344    /**
345     * Whether it is italic.
346     *
347     * @type { boolean }
348     * @syscap SystemCapability.ArkUI.ArkUI.Full
349     * @crossplatform
350     * @atomicservice
351     * @since 12
352     */
353    italic: boolean;
354
355    /**
356     * Whether it is compact.
357     *
358     * @type { boolean }
359     * @syscap SystemCapability.ArkUI.ArkUI.Full
360     * @since 10
361     */
362    /**
363     * Whether it is compact.
364     *
365     * @type { boolean }
366     * @syscap SystemCapability.ArkUI.ArkUI.Full
367     * @atomicservice
368     * @since 11
369     */
370    /**
371     * Whether it is compact.
372     *
373     * @type { boolean }
374     * @syscap SystemCapability.ArkUI.ArkUI.Full
375     * @crossplatform
376     * @atomicservice
377     * @since 12
378     */
379    monoSpace: boolean;
380
381    /**
382     * Whether symbol fonts are supported.
383     *
384     * @type { boolean }
385     * @syscap SystemCapability.ArkUI.ArkUI.Full
386     * @since 10
387     */
388    /**
389     * Whether symbol fonts are supported.
390     *
391     * @type { boolean }
392     * @syscap SystemCapability.ArkUI.ArkUI.Full
393     * @atomicservice
394     * @since 11
395     */
396    /**
397     * Whether symbol fonts are supported.
398     *
399     * @type { boolean }
400     * @syscap SystemCapability.ArkUI.ArkUI.Full
401     * @crossplatform
402     * @atomicservice
403     * @since 12
404     */
405    symbolic: boolean;
406  }
407
408  /**
409   * @typedef UIFontConfig
410   * @syscap SystemCapability.ArkUI.ArkUI.Full
411   * @since 11
412   */
413  /**
414   * @typedef UIFontConfig
415   * @syscap SystemCapability.ArkUI.ArkUI.Full
416   * @atomicservice
417   * @since 12
418   */
419  interface UIFontConfig {
420    /**
421     * The paths of system font files.
422     * @type { Array<string> }
423     * @syscap SystemCapability.ArkUI.ArkUI.Full
424     * @since 11
425     */
426    /**
427     * The paths of system font files.
428     * @type { Array<string> }
429     * @syscap SystemCapability.ArkUI.ArkUI.Full
430     * @atomicservice
431     * @since 12
432     */
433    fontDir: Array<string>;
434
435    /**
436     * The generic font info.
437     * @type { Array<UIFontGenericInfo> }
438     * @syscap SystemCapability.ArkUI.ArkUI.Full
439     * @since 11
440     */
441    /**
442     * The generic font info.
443     * @type { Array<UIFontGenericInfo> }
444     * @syscap SystemCapability.ArkUI.ArkUI.Full
445     * @atomicservice
446     * @since 12
447     */
448    generic: Array<UIFontGenericInfo>;
449
450    /**
451     * The fallback font info.
452     * @type { Array<UIFontFallbackGroupInfo> }
453     * @syscap SystemCapability.ArkUI.ArkUI.Full
454     * @since 11
455     */
456    /**
457     * The fallback font info.
458     * @type { Array<UIFontFallbackGroupInfo> }
459     * @syscap SystemCapability.ArkUI.ArkUI.Full
460     * @atomicservice
461     * @since 12
462     */
463    fallbackGroups: Array<UIFontFallbackGroupInfo>;
464  }
465
466  /**
467   * @typedef UIFontGenericInfo
468   * @syscap SystemCapability.ArkUI.ArkUI.Full
469   * @since 11
470   */
471  /**
472   * @typedef UIFontGenericInfo
473   * @syscap SystemCapability.ArkUI.ArkUI.Full
474   * @atomicservice
475   * @since 12
476   */
477  interface UIFontGenericInfo {
478    /**
479     * Name of the font set.
480     * @type { string }
481     * @syscap SystemCapability.ArkUI.ArkUI.Full
482     * @since 11
483     */
484    /**
485     * Name of the font set.
486     * @type { string }
487     * @syscap SystemCapability.ArkUI.ArkUI.Full
488     * @atomicservice
489     * @since 12
490     */
491    family: string;
492
493    /**
494     * Alias info of the font set.
495     * @type { Array<UIFontAliasInfo> }
496     * @syscap SystemCapability.ArkUI.ArkUI.Full
497     * @since 11
498     */
499    /**
500     * Alias info of the font set.
501     * @type { Array<UIFontAliasInfo> }
502     * @syscap SystemCapability.ArkUI.ArkUI.Full
503     * @atomicservice
504     * @since 12
505     */
506    alias: Array<UIFontAliasInfo>;
507
508    /**
509     * Adjust info of the font set.
510     * @type { Array<UIFontAdjustInfo> }
511     * @syscap SystemCapability.ArkUI.ArkUI.Full
512     * @since 11
513     */
514    /**
515     * Adjust info of the font set.
516     * @type { Array<UIFontAdjustInfo> }
517     * @syscap SystemCapability.ArkUI.ArkUI.Full
518     * @atomicservice
519     * @since 12
520     */
521    adjust: Array<UIFontAdjustInfo>;
522  }
523
524  /**
525   * @typedef UIFontAliasInfo
526   * @syscap SystemCapability.ArkUI.ArkUI.Full
527   * @since 11
528   */
529  /**
530   * @typedef UIFontAliasInfo
531   * @syscap SystemCapability.ArkUI.ArkUI.Full
532   * @atomicservice
533   * @since 12
534   */
535  interface UIFontAliasInfo {
536    /**
537     * Font set name.
538     * @type { string }
539     * @syscap SystemCapability.ArkUI.ArkUI.Full
540     * @since 11
541     */
542    /**
543     * Font set name.
544     * @type { string }
545     * @syscap SystemCapability.ArkUI.ArkUI.Full
546     * @atomicservice
547     * @since 12
548     */
549    name: string;
550
551    /**
552     * Weight the font set contains only fonts with, if weight = 0,
553     * this font set can contain fonts with any weight.
554     * @type { number }
555     * @syscap SystemCapability.ArkUI.ArkUI.Full
556     * @since 11
557     */
558    /**
559     * Weight the font set contains only fonts with, if weight = 0,
560     * this font set can contain fonts with any weight.
561     * @type { number }
562     * @syscap SystemCapability.ArkUI.ArkUI.Full
563     * @atomicservice
564     * @since 12
565     */
566    weight: number;
567  }
568
569  /**
570   * @typedef UIFontAdjustInfo
571   * @syscap SystemCapability.ArkUI.ArkUI.Full
572   * @since 11
573   */
574  /**
575   * @typedef UIFontAdjustInfo
576   * @syscap SystemCapability.ArkUI.ArkUI.Full
577   * @atomicservice
578   * @since 12
579   */
580  interface UIFontAdjustInfo {
581    /**
582     * Original weight of the font
583     * @type { number }
584     * @syscap SystemCapability.ArkUI.ArkUI.Full
585     * @since 11
586     */
587    /**
588     * Original weight of the font
589     * @type { number }
590     * @syscap SystemCapability.ArkUI.ArkUI.Full
591     * @atomicservice
592     * @since 12
593     */
594    weight: number;
595    /**
596     * Font weight displayed in the app
597     * @type { number }
598     * @syscap SystemCapability.ArkUI.ArkUI.Full
599     * @since 11
600     */
601    /**
602     * Font weight displayed in the app
603     * @type { number }
604     * @syscap SystemCapability.ArkUI.ArkUI.Full
605     * @atomicservice
606     * @since 12
607     */
608    to: number;
609  }
610
611  /**
612   * @typedef UIFontFallbackGroupInfo
613   * @syscap SystemCapability.ArkUI.ArkUI.Full
614   * @since 11
615   */
616  /**
617   * @typedef UIFontFallbackGroupInfo
618   * @syscap SystemCapability.ArkUI.ArkUI.Full
619   * @atomicservice
620   * @since 12
621   */
622  interface UIFontFallbackGroupInfo {
623    /**
624     * Indicates which font set uses following list for fallback font
625     * if the font set name is "", it means that the following list can be fallback font for all font sets.
626     * @type { string }
627     * @syscap SystemCapability.ArkUI.ArkUI.Full
628     * @since 11
629     */
630    /**
631     * Indicates which font set uses following list for fallback font
632     * if the font set name is "", it means that the following list can be fallback font for all font sets.
633     * @type { string }
634     * @syscap SystemCapability.ArkUI.ArkUI.Full
635     * @atomicservice
636     * @since 12
637     */
638    fontSetName: string;
639
640    /**
641     * Fallback font list related.
642     * @type { Array<UIFontFallbackInfo> }
643     * @syscap SystemCapability.ArkUI.ArkUI.Full
644     * @since 11
645     */
646    /**
647     * Fallback font list related.
648     * @type { Array<UIFontFallbackInfo> }
649     * @syscap SystemCapability.ArkUI.ArkUI.Full
650     * @atomicservice
651     * @since 12
652     */
653    fallback: Array<UIFontFallbackInfo>;
654  }
655
656  /**
657   * @typedef UIFontFallbackInfo
658   * @syscap SystemCapability.ArkUI.ArkUI.Full
659   * @since 11
660   */
661  /**
662   * @typedef UIFontFallbackInfo
663   * @syscap SystemCapability.ArkUI.ArkUI.Full
664   * @atomicservice
665   * @since 12
666   */
667  interface UIFontFallbackInfo {
668    /**
669     * Language that font set support.
670     * @type { string }
671     * @syscap SystemCapability.ArkUI.ArkUI.Full
672     * @since 11
673     */
674    /**
675     * Language that font set support.
676     * @type { string }
677     * @syscap SystemCapability.ArkUI.ArkUI.Full
678     * @atomicservice
679     * @since 12
680     */
681    language: string;
682
683    /**
684     * Font name related.
685     * @type { string }
686     * @syscap SystemCapability.ArkUI.ArkUI.Full
687     * @since 11
688     */
689    /**
690     * Font name related.
691     * @type { string }
692     * @syscap SystemCapability.ArkUI.ArkUI.Full
693     * @atomicservice
694     * @since 12
695     */
696    family: string;
697  }
698
699  /**
700   * Register a customized font in the FontManager.
701   *
702   * @param { FontOptions } options - FontOptions
703   * @syscap SystemCapability.ArkUI.ArkUI.Full
704   * @since 9
705   */
706  /**
707   * Register a customized font in the FontManager.
708   *
709   * @param { FontOptions } options - FontOptions
710   * @syscap SystemCapability.ArkUI.ArkUI.Full
711   * @atomicservice
712   * @since 11
713   */
714  /**
715   * Register a customized font in the FontManager.
716   *
717   * @param { FontOptions } options - FontOptions
718   * @syscap SystemCapability.ArkUI.ArkUI.Full
719   * @crossplatform
720   * @atomicservice
721   * @since 12
722   * @deprecated since 18
723   * @useinstead ohos.arkui.UIContext.Font#registerFont
724   */
725  function registerFont(options: FontOptions): void;
726
727  /**
728   * Gets a list of fonts supported by system.
729   *
730   * @returns { Array<string> } A list of font names
731   * @syscap SystemCapability.ArkUI.ArkUI.Full
732   * @since 10
733   */
734  /**
735   * Gets a list of fonts supported by system.
736   *
737   * @returns { Array<string> } A list of font names
738   * @syscap SystemCapability.ArkUI.ArkUI.Full
739   * @atomicservice
740   * @since 11
741   */
742  /**
743   * Gets a list of fonts supported by system.
744   *
745   * @returns { Array<string> } A list of font names
746   * @syscap SystemCapability.ArkUI.ArkUI.Full
747   * @crossplatform
748   * @atomicservice
749   * @since 12
750   * @deprecated since 18
751   * @useinstead ohos.arkui.UIContext.Font#getSystemFontList
752   */
753  function getSystemFontList(): Array<string>;
754
755  /**
756   * Get font details according to the font name.
757   *
758   * @param { string } fontName - font name
759   * @returns { FontInfo } Returns the font info
760   * @syscap SystemCapability.ArkUI.ArkUI.Full
761   * @since 10
762   */
763  /**
764   * Get font details according to the font name.
765   *
766   * @param { string } fontName - font name
767   * @returns { FontInfo } Returns the font info
768   * @syscap SystemCapability.ArkUI.ArkUI.Full
769   * @atomicservice
770   * @since 11
771   */
772  /**
773   * Get font details according to the font name.
774   *
775   * @param { string } fontName - font name
776   * @returns { FontInfo } Returns the font info
777   * @syscap SystemCapability.ArkUI.ArkUI.Full
778   * @crossplatform
779   * @atomicservice
780   * @since 12
781   * @deprecated since 18
782   * @useinstead ohos.arkui.UIContext.Font#getFontByName
783   */
784  function getFontByName(fontName: string): FontInfo;
785
786  /**
787   * Get font details according to the font name.
788   *
789   * @returns { UIFontConfig } Returns the ui font config
790   * @syscap SystemCapability.ArkUI.ArkUI.Full
791   * @since 11
792   */
793  /**
794   * Get font details according to the font name.
795   *
796   * @returns { UIFontConfig } Returns the ui font config
797   * @syscap SystemCapability.ArkUI.ArkUI.Full
798   * @atomicservice
799   * @since 12
800   */
801  function getUIFontConfig(): UIFontConfig;
802}
803
804export default font;
805