• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022 Huawei Device 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/// <reference path="../component/units.d.ts" />
17
18import { Resource } from 'GlobalResource';
19
20/**
21 * Defines the options of MeasureText.
22 * @syscap SystemCapability.ArkUI.ArkUI.Full
23 * @since 9
24 */
25export interface MeasureOptions {
26
27    /**
28     * Text to display.
29     * @syscap SystemCapability.ArkUI.ArkUI.Full
30     * @since 9
31     */
32    textContent: string;
33
34    /**
35     * Font Size.
36     * @syscap SystemCapability.ArkUI.ArkUI.Full
37     * @since 9
38     */
39    fontSize?: number | string | Resource;
40
41    /**
42     * Font style.
43     * @syscap SystemCapability.ArkUI.ArkUI.Full
44     * @since 9
45     */
46    fontStyle?: number | FontStyle;
47
48    /**
49     * Font weight.
50     * @syscap SystemCapability.ArkUI.ArkUI.Full
51     * @since 9
52     */
53    fontWeight?: number | string | FontWeight;
54
55    /**
56     * Font list of text.
57     * @syscap SystemCapability.ArkUI.ArkUI.Full
58     * @since 9
59     */
60    fontFamily?: string | Resource;
61
62    /**
63     * Distance between text fonts.
64     * @syscap SystemCapability.ArkUI.ArkUI.Full
65     * @since 9
66     */
67    letterSpacing?: number | string;
68}
69
70/**
71 * Defines the Measure interface.
72 * since 9
73 */
74export default class MeasureText {
75
76    /**
77     * Displays the textWidth.
78     * @syscap SystemCapability.ArkUI.ArkUI.Full
79     * @param options Options.
80     * @since 9
81     */
82    static measureText(options: MeasureOptions): number;
83}
84