• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022-2024 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/**
17 * @file
18 * @kit ArkUI
19 */
20
21
22/**
23 * Defines the options of MeasureText.
24 *
25 * @interface MeasureOptions
26 * @syscap SystemCapability.ArkUI.ArkUI.Full
27 * @since 9
28 */
29/**
30 * Defines the options of MeasureText.
31 *
32 * @interface MeasureOptions
33 * @syscap SystemCapability.ArkUI.ArkUI.Full
34 * @crossplatform
35 * @since 11
36 */
37/**
38 * Defines the options of MeasureText.
39 *
40 * @interface MeasureOptions
41 * @syscap SystemCapability.ArkUI.ArkUI.Full
42 * @crossplatform
43 * @atomicservice
44 * @since 12
45 */
46export interface MeasureOptions {
47  /**
48   * Text to display.
49   *
50   * @type { string | Resource }
51   * @syscap SystemCapability.ArkUI.ArkUI.Full
52   * @since 9
53   */
54  /**
55   * Text to display.
56   *
57   * @type { string | Resource }
58   * @syscap SystemCapability.ArkUI.ArkUI.Full
59   * @since 10
60   */
61  /**
62   * Text to display.
63   *
64   * @type { string | Resource }
65   * @syscap SystemCapability.ArkUI.ArkUI.Full
66   * @crossplatform
67   * @atomicservice
68   * @since 12
69   */
70  textContent: string | Resource;
71
72  /**
73   * Text display area of width.
74   *
75   * @type { ?(number | string | Resource) }
76   * @syscap SystemCapability.ArkUI.ArkUI.Full
77   * @since 10
78   */
79  /**
80   * Text display area of width.
81   *
82   * @type { ?(number | string | Resource) }
83   * @syscap SystemCapability.ArkUI.ArkUI.Full
84   * @crossplatform
85   * @atomicservice
86   * @since 12
87   */
88  constraintWidth?: number | string | Resource;
89
90  /**
91   * Font Size.
92   *
93   * @type { ?(number | string | Resource) }
94   * @syscap SystemCapability.ArkUI.ArkUI.Full
95   * @since 9
96   */
97  /**
98   * Font Size.
99   *
100   * @type { ?(number | string | Resource) }
101   * @syscap SystemCapability.ArkUI.ArkUI.Full
102   * @crossplatform
103   * @atomicservice
104   * @since 12
105   */
106  fontSize?: number | string | Resource;
107
108  /**
109   * Font style.
110   *
111   * @type { ?(number | FontStyle) }
112   * @syscap SystemCapability.ArkUI.ArkUI.Full
113   * @since 9
114   */
115  /**
116   * Font style.
117   *
118   * @type { ?(number | FontStyle) }
119   * @syscap SystemCapability.ArkUI.ArkUI.Full
120   * @crossplatform
121   * @atomicservice
122   * @since 12
123   */
124  fontStyle?: number | FontStyle;
125
126  /**
127   * Font weight.
128   *
129   * @type { ?(number | string | FontWeight) }
130   * @syscap SystemCapability.ArkUI.ArkUI.Full
131   * @since 9
132   */
133  /**
134   * Font weight.
135   *
136   * @type { ?(number | string | FontWeight) }
137   * @syscap SystemCapability.ArkUI.ArkUI.Full
138   * @crossplatform
139   * @atomicservice
140   * @since 12
141   */
142  fontWeight?: number | string | FontWeight;
143
144  /**
145   * Font list of text.
146   *
147   * @type { ?(string | Resource) }
148   * @syscap SystemCapability.ArkUI.ArkUI.Full
149   * @since 9
150   */
151  /**
152   * Font list of text.
153   *
154   * @type { ?(string | Resource) }
155   * @syscap SystemCapability.ArkUI.ArkUI.Full
156   * @crossplatform
157   * @atomicservice
158   * @since 12
159   */
160  fontFamily?: string | Resource;
161
162  /**
163   * Distance between text fonts.
164   *
165   * @type { ?(number | string) }
166   * @syscap SystemCapability.ArkUI.ArkUI.Full
167   * @since 9
168   */
169  /**
170   * Distance between text fonts.
171   *
172   * @type { ?(number | string) }
173   * @syscap SystemCapability.ArkUI.ArkUI.Full
174   * @crossplatform
175   * @atomicservice
176   * @since 12
177   */
178  letterSpacing?: number | string;
179
180  /**
181   * Alignment of text.
182   *
183   * @type { ?(number | TextAlign) }
184   * @syscap SystemCapability.ArkUI.ArkUI.Full
185   * @since 10
186   */
187  /**
188   * Alignment of text.
189   *
190   * @type { ?(number | TextAlign) }
191   * @syscap SystemCapability.ArkUI.ArkUI.Full
192   * @crossplatform
193   * @atomicservice
194   * @since 12
195   */
196  textAlign?: number | TextAlign;
197
198  /**
199   * Overflow mode of the font.
200   *
201   * @type { ?(number | TextOverflow) }
202   * @syscap SystemCapability.ArkUI.ArkUI.Full
203   * @since 10
204   */
205  /**
206   * Overflow mode of the font.
207   *
208   * @type { ?(number | TextOverflow) }
209   * @syscap SystemCapability.ArkUI.ArkUI.Full
210   * @crossplatform
211   * @atomicservice
212   * @since 12
213   */
214  overflow?: number | TextOverflow;
215
216  /**
217   * Maximum number of lines of text.
218   *
219   * @type { ?number }
220   * @syscap SystemCapability.ArkUI.ArkUI.Full
221   * @since 10
222   */
223  /**
224   * Maximum number of lines of text.
225   *
226   * @type { ?number }
227   * @syscap SystemCapability.ArkUI.ArkUI.Full
228   * @crossplatform
229   * @atomicservice
230   * @since 12
231   */
232  maxLines?: number;
233
234  /**
235   * Vertical center mode of the font.
236   *
237   * @type { ?(number | string | Resource) }
238   * @syscap SystemCapability.ArkUI.ArkUI.Full
239   * @since 10
240   */
241  /**
242   * Vertical center mode of the font.
243   *
244   * @type { ?(number | string | Resource) }
245   * @syscap SystemCapability.ArkUI.ArkUI.Full
246   * @crossplatform
247   * @atomicservice
248   * @since 12
249   */
250  lineHeight?: number | string | Resource;
251
252  /**
253   * Baseline offset.
254   *
255   * @type { ?(number | string) }
256   * @syscap SystemCapability.ArkUI.ArkUI.Full
257   * @since 10
258   */
259  /**
260   * Baseline offset.
261   *
262   * @type { ?(number | string) }
263   * @syscap SystemCapability.ArkUI.ArkUI.Full
264   * @crossplatform
265   * @atomicservice
266   * @since 12
267   */
268  baselineOffset?: number | string;
269
270  /**
271   * Type of letter in the text font
272   *
273   * @type { ?(number | TextCase) }
274   * @syscap SystemCapability.ArkUI.ArkUI.Full
275   * @since 10
276   */
277  /**
278   * Type of letter in the text font
279   *
280   * @type { ?(number | TextCase) }
281   * @syscap SystemCapability.ArkUI.ArkUI.Full
282   * @crossplatform
283   * @atomicservice
284   * @since 12
285   */
286  textCase?: number | TextCase;
287
288  /**
289   * Specify the indentation of the first line in a text-block.
290   *
291   * @type { ?(number | string) }
292   * @syscap SystemCapability.ArkUI.ArkUI.Full
293   * @crossplatform
294   * @since 11
295   */
296  /**
297   * Specify the indentation of the first line in a text-block.
298   *
299   * @type { ?(number | string) }
300   * @syscap SystemCapability.ArkUI.ArkUI.Full
301   * @crossplatform
302   * @atomicservice
303   * @since 12
304   */
305  textIndent?: number | string;
306
307  /**
308   * Set the word break type.
309   *
310   * @type { ?WordBreak }
311   * @syscap SystemCapability.ArkUI.ArkUI.Full
312   * @crossplatform
313   * @since 11
314   */
315  /**
316   * Set the word break type.
317   *
318   * @type { ?WordBreak }
319   * @syscap SystemCapability.ArkUI.ArkUI.Full
320   * @crossplatform
321   * @atomicservice
322   * @since 12
323   */
324  wordBreak?: WordBreak;
325}
326
327/**
328 * Defines the Measure interface.
329 *
330 * @syscap SystemCapability.ArkUI.ArkUI.Full
331 * @since 9
332 */
333/**
334 * Defines the Measure interface.
335 *
336 * @syscap SystemCapability.ArkUI.ArkUI.Full
337 * @crossplatform
338 * @atomicservice
339 * @since 12
340 */
341export default class MeasureText {
342  /**
343   * Displays the textWidth.
344   *
345   * @param { MeasureOptions } options - Options.
346   * @returns { number }
347   * @syscap SystemCapability.ArkUI.ArkUI.Full
348   * @since 9
349   */
350  /**
351   * Displays the textWidth.
352   *
353   * @param { MeasureOptions } options - Options.
354   * @returns { number }
355   * @syscap SystemCapability.ArkUI.ArkUI.Full
356   * @crossplatform
357   * @since 11
358   */
359  /**
360   * Displays the textWidth.
361   *
362   * @param { MeasureOptions } options - Options.
363   * @returns { number }
364   * @syscap SystemCapability.ArkUI.ArkUI.Full
365   * @crossplatform
366   * @atomicservice
367   * @since 12
368   * @deprecated since 18
369   * @useinstead ohos.arkui.UIContext.MeasureUtils#measureText
370   */
371  static measureText(options: MeasureOptions): number;
372
373  /**
374   * Displays the text width and height.
375   *
376   * @param { MeasureOptions } options - Options of measure area occupied by text.
377   * @returns { SizeOptions } width and height for text to display \
378   * @syscap SystemCapability.ArkUI.ArkUI.Full
379   * @since 10
380   */
381  /**
382   * Displays the text width and height.
383   *
384   * @param { MeasureOptions } options - Options of measure area occupied by text.
385   * @returns { SizeOptions } width and height for text to display \
386   * @syscap SystemCapability.ArkUI.ArkUI.Full
387   * @crossplatform
388   * @since 11
389   */
390  /**
391   * Displays the text width and height.
392   *
393   * @param { MeasureOptions } options - Options of measure area occupied by text.
394   * @returns { SizeOptions } width and height for text to display \
395   * @syscap SystemCapability.ArkUI.ArkUI.Full
396   * @crossplatform
397   * @atomicservice
398   * @since 12
399   * @deprecated since 18
400   * @useinstead ohos.arkui.UIContext.MeasureUtils#measureTextSize
401   */
402  static measureTextSize(options: MeasureOptions): SizeOptions;
403}
404