1 /* 2 * Copyright (c) 2021-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 #ifndef C_INCLUDE_DRAWING_TEXT_TYPOGRAPHY_H 17 #define C_INCLUDE_DRAWING_TEXT_TYPOGRAPHY_H 18 19 /** 20 * @addtogroup Drawing 21 * @{ 22 * 23 * @brief Provides the 2D drawing capability. 24 * 25 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 26 * 27 * @since 8 28 * @version 1.0 29 */ 30 31 /** 32 * @file drawing_text_typography.h 33 * 34 * @brief Declares functions related to <b>typography</b> in the drawing module. 35 * 36 * @since 8 37 * @version 1.0 38 */ 39 40 #include "cstddef" 41 #include "drawing_canvas.h" 42 #include "drawing_color.h" 43 #include "drawing_text_declaration.h" 44 #include "drawing_types.h" 45 46 #include "stdint.h" 47 48 #ifdef __cplusplus 49 extern "C" { 50 #endif 51 52 /** 53 * @brief Enumerates text directions. 54 */ 55 enum OH_Drawing_TextDirection { 56 /** Right to left (RTL) */ 57 TEXT_DIRECTION_RTL, 58 /** Left to right (LTR) */ 59 TEXT_DIRECTION_LTR, 60 }; 61 62 /** 63 * @brief Enumerates text alignment modes. 64 */ 65 enum OH_Drawing_TextAlign { 66 /** Left-aligned */ 67 TEXT_ALIGN_LEFT, 68 /** Right-aligned */ 69 TEXT_ALIGN_RIGHT, 70 /** Center-aligned */ 71 TEXT_ALIGN_CENTER, 72 /** 73 * Justified, which means that each line (except the last line) is stretched so that every line has equal width, 74 * and the left and right margins are straight. 75 */ 76 TEXT_ALIGN_JUSTIFY, 77 /** 78 * <b>TEXT_ALIGN_START</b> achieves the same effect as <b>TEXT_ALIGN_LEFT</b> 79 * when <b>OH_Drawing_TextDirection</b> is <b>TEXT_DIRECTION_LTR</b>; 80 * it achieves the same effect as <b>TEXT_ALIGN_RIGHT</b> 81 * when <b>OH_Drawing_TextDirection</b> is <b>TEXT_DIRECTION_RTL</b>. 82 */ 83 TEXT_ALIGN_START, 84 /** 85 * <b>TEXT_ALIGN_END</b> achieves the same effect as <b>TEXT_ALIGN_RIGHT</b> 86 * when <b>OH_Drawing_TextDirection</b> is <b>TEXT_DIRECTION_LTR</b>; 87 * it achieves the same effect as <b>TEXT_ALIGN_LEFT</b> 88 * when <b>OH_Drawing_TextDirection</b> is <b>TEXT_DIRECTION_RTL</b>. 89 */ 90 TEXT_ALIGN_END, 91 }; 92 93 /** 94 * @brief Enumerates font weights. 95 */ 96 enum OH_Drawing_FontWeight { 97 /** Thin */ 98 FONT_WEIGHT_100, 99 /** Extra-light */ 100 FONT_WEIGHT_200, 101 /** Light */ 102 FONT_WEIGHT_300, 103 /** Normal/Regular */ 104 FONT_WEIGHT_400, 105 /** Medium*/ 106 FONT_WEIGHT_500, 107 /** Semi-bold */ 108 FONT_WEIGHT_600, 109 /** Bold */ 110 FONT_WEIGHT_700, 111 /** Extra-bold */ 112 FONT_WEIGHT_800, 113 /** Black */ 114 FONT_WEIGHT_900, 115 }; 116 117 /** 118 * @brief Enumerates text baselines. 119 */ 120 enum OH_Drawing_TextBaseline { 121 /** Alphabetic, where the letters in alphabets like English sit on. */ 122 TEXT_BASELINE_ALPHABETIC, 123 /** Ideographic. The baseline is at the bottom of the text area. */ 124 TEXT_BASELINE_IDEOGRAPHIC, 125 }; 126 127 /** 128 * @brief Enumerates text decorations. 129 */ 130 enum OH_Drawing_TextDecoration { 131 /** No decoration. */ 132 TEXT_DECORATION_NONE = 0x0, 133 /** A underline is used for decoration. */ 134 TEXT_DECORATION_UNDERLINE = 0x1, 135 /** An overline is used for decoration. */ 136 TEXT_DECORATION_OVERLINE = 0x2, 137 /** A strikethrough is used for decoration. */ 138 TEXT_DECORATION_LINE_THROUGH = 0x4, 139 }; 140 141 /** 142 * @brief Enumerates font styles. 143 */ 144 enum OH_Drawing_FontStyle { 145 /** Normal style */ 146 FONT_STYLE_NORMAL, 147 /** Italic style */ 148 FONT_STYLE_ITALIC, 149 }; 150 151 /** 152 * @brief Enumerates placeholder vertical alignment. 153 * 154 * @since 11 155 * @version 1.0 156 */ 157 typedef enum { 158 /** Offset At Baseline */ 159 ALIGNMENT_OFFSET_AT_BASELINE, 160 /** Above Baseline */ 161 ALIGNMENT_ABOVE_BASELINE, 162 /** Below Baseline */ 163 ALIGNMENT_BELOW_BASELINE, 164 /** Top of Row Box */ 165 ALIGNMENT_TOP_OF_ROW_BOX, 166 /** Bottom of Row Box */ 167 ALIGNMENT_BOTTOM_OF_ROW_BOX, 168 /** Center of Row Box */ 169 ALIGNMENT_CENTER_OF_ROW_BOX, 170 } OH_Drawing_PlaceholderVerticalAlignment; 171 172 /** 173 * @brief Defines the placeholder span. 174 * 175 * @since 11 176 * @version 1.0 177 */ 178 typedef struct { 179 /** width of placeholder */ 180 double width; 181 /** height of placeholder */ 182 double height; 183 /** alignment of placeholder */ 184 OH_Drawing_PlaceholderVerticalAlignment alignment; 185 /** baseline of placeholder */ 186 OH_Drawing_TextBaseline baseline; 187 /** baselineoffset of placeholder */ 188 double baselineOffset; 189 } OH_Drawing_PlaceholderSpan; 190 191 /** 192 * @brief Enumerates text decoration style. 193 * 194 * @since 11 195 * @version 1.0 196 */ 197 typedef enum { 198 /** Solid style */ 199 TEXT_DECORATION_STYLE_SOLID, 200 /** Double style */ 201 TEXT_DECORATION_STYLE_DOUBLE, 202 /** Dotted style */ 203 TEXT_DECORATION_STYLE_DOTTED, 204 /** Dashed style */ 205 TEXT_DECORATION_STYLE_DASHED, 206 /** Wavy style */ 207 TEXT_DECORATION_STYLE_WAVY, 208 } OH_Drawing_TextDecorationStyle; 209 210 /** 211 * @brief Enumerates ellipsis modal. 212 * 213 * @since 11 214 * @version 1.0 215 */ 216 typedef enum { 217 /** Head modal */ 218 ELLIPSIS_MODAL_HEAD = 0, 219 /** Middle modal */ 220 ELLIPSIS_MODAL_MIDDLE = 1, 221 /** Tail modal */ 222 ELLIPSIS_MODAL_TAIL = 2, 223 } OH_Drawing_EllipsisModal; 224 225 /** 226 * @brief Enumerates break strategy. 227 * 228 * @since 11 229 * @version 1.0 230 */ 231 typedef enum { 232 /** Greedy strategy */ 233 BREAK_STRATEGY_GREEDY = 0, 234 /** Quality strategy */ 235 BREAK_STRATEGY_HIGH_QUALITY = 1, 236 /** Balanced strategy */ 237 BREAK_STRATEGY_BALANCED = 2, 238 } OH_Drawing_BreakStrategy; 239 240 /** 241 * @brief Enumerates word break type. 242 * 243 * @since 11 244 * @version 1.0 245 */ 246 typedef enum { 247 /** Normal type */ 248 WORD_BREAK_TYPE_NORMAL = 0, 249 /** Break All type */ 250 WORD_BREAK_TYPE_BREAK_ALL = 1, 251 /** Break Word type */ 252 WORD_BREAK_TYPE_BREAK_WORD = 2, 253 } OH_Drawing_WordBreakType; 254 255 /** 256 * @brief Enumerates rect height style. 257 * 258 * @since 11 259 * @version 1.0 260 */ 261 typedef enum { 262 /** Tight style */ 263 RECT_HEIGHT_STYLE_TIGHT, 264 /** Max style */ 265 RECT_HEIGHT_STYLE_MAX, 266 /** Includelinespacemiddle style */ 267 RECT_HEIGHT_STYLE_INCLUDELINESPACEMIDDLE, 268 /** Includelinespacetop style */ 269 RECT_HEIGHT_STYLE_INCLUDELINESPACETOP, 270 /** Includelinespacebottom style */ 271 RECT_HEIGHT_STYLE_INCLUDELINESPACEBOTTOM, 272 /** Struct style */ 273 RECT_HEIGHT_STYLE_STRUCT, 274 } OH_Drawing_RectHeightStyle; 275 276 /** 277 * @brief Enumerates rect Width style. 278 * 279 * @since 11 280 * @version 1.0 281 */ 282 typedef enum { 283 /** Tight style */ 284 RECT_WIDTH_STYLE_TIGHT, 285 /** Max style */ 286 RECT_WIDTH_STYLE_MAX, 287 } OH_Drawing_RectWidthStyle; 288 289 /** 290 * @brief Creates an <b>OH_Drawing_TypographyStyle</b> object. 291 * 292 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 293 * @return Returns the pointer to the <b>OH_Drawing_TypographyStyle</b> object created. 294 * @since 8 295 * @version 1.0 296 */ 297 OH_Drawing_TypographyStyle* OH_Drawing_CreateTypographyStyle(void); 298 299 /** 300 * @brief Releases the memory occupied by an <b>OH_Drawing_TypographyStyle</b> object. 301 * 302 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 303 * @param OH_Drawing_TypographyStyle Indicates the pointer to an <b>OH_Drawing_TypographyStyle</b> object. 304 * @since 8 305 * @version 1.0 306 */ 307 void OH_Drawing_DestroyTypographyStyle(OH_Drawing_TypographyStyle*); 308 309 /** 310 * @brief Sets the text direction. 311 * 312 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 313 * @param OH_Drawing_TypographyStyle Indicates the pointer to an <b>OH_Drawing_TypographyStyle</b> object. 314 * @param int Indicates the text direction to set. For details, see the enum <b>OH_Drawing_TextDirection</b>. 315 * @since 8 316 * @version 1.0 317 */ 318 void OH_Drawing_SetTypographyTextDirection(OH_Drawing_TypographyStyle*, int /* OH_Drawing_TextDirection */); 319 320 /** 321 * @brief Sets the text alignment mode. 322 * 323 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 324 * @param OH_Drawing_TypographyStyle Indicates the pointer to an <b>OH_Drawing_TypographyStyle</b> object. 325 * @param int Indicates the text alignment mode to set. For details, see the enum <b>OH_Drawing_TextAlign</b>. 326 * @since 8 327 * @version 1.0 328 */ 329 void OH_Drawing_SetTypographyTextAlign(OH_Drawing_TypographyStyle*, int /* OH_Drawing_TextAlign */); 330 331 /** 332 * @brief Sets the maximum number of lines in a text file. 333 * 334 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 335 * @param OH_Drawing_TypographyStyle Indicates the pointer to an <b>OH_Drawing_TypographyStyle</b> object. 336 * @param int Indicates the maximum number of lines to set. 337 * @since 8 338 * @version 1.0 339 */ 340 void OH_Drawing_SetTypographyTextMaxLines(OH_Drawing_TypographyStyle*, int /* maxLines */); 341 342 /** 343 * @brief Creates an <b>OH_Drawing_TextStyle</b> object. 344 * 345 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 346 * @return Returns the pointer to the <b>OH_Drawing_TextStyle</b> object created. 347 * @since 8 348 * @version 1.0 349 */ 350 OH_Drawing_TextStyle* OH_Drawing_CreateTextStyle(void); 351 352 /** 353 * @brief Releases the memory occupied by an <b>OH_Drawing_TextStyle</b> object. 354 * 355 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 356 * @param OH_Drawing_TextStyle Indicates the pointer to an <b>OH_Drawing_TextStyle</b> object. 357 * @since 8 358 * @version 1.0 359 */ 360 void OH_Drawing_DestroyTextStyle(OH_Drawing_TextStyle*); 361 362 /** 363 * @brief Sets the text color. 364 * 365 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 366 * @param OH_Drawing_TextStyle Indicates the pointer to an <b>OH_Drawing_TextStyle</b> object. 367 * @param uint32_t Indicates the color to set. 368 * @since 8 369 * @version 1.0 370 */ 371 void OH_Drawing_SetTextStyleColor(OH_Drawing_TextStyle*, uint32_t /* color */); 372 373 /** 374 * @brief Sets the font size. 375 * 376 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 377 * @param OH_Drawing_TextStyle Indicates the pointer to an <b>OH_Drawing_TextStyle</b> object. 378 * @param double Indicates the font size to set. 379 * @since 8 380 * @version 1.0 381 */ 382 void OH_Drawing_SetTextStyleFontSize(OH_Drawing_TextStyle*, double /* fontSize */); 383 384 /** 385 * @brief Sets the font weight. 386 * 387 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 388 * @param OH_Drawing_TextStyle Indicates the pointer to an <b>OH_Drawing_TextStyle</b> object. 389 * @param int Indicates the font weight to set. For details, see the enum <b>OH_Drawing_FontWeight</b>. 390 * @since 8 391 * @version 1.0 392 */ 393 void OH_Drawing_SetTextStyleFontWeight(OH_Drawing_TextStyle*, int /* OH_Drawing_FontWeight */); 394 395 /** 396 * @brief Sets the text baseline. 397 * 398 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 399 * @param OH_Drawing_TextStyle Indicates the pointer to an <b>OH_Drawing_TextStyle</b> object. 400 * @param int Indicates the text baseline to set. For details, see the enum <b>OH_Drawing_TextBaseline</b>. 401 * @since 8 402 * @version 1.0 403 */ 404 void OH_Drawing_SetTextStyleBaseLine(OH_Drawing_TextStyle*, int /* OH_Drawing_TextBaseline */); 405 406 /** 407 * @brief Sets the text decoration. 408 * 409 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 410 * @param OH_Drawing_TextStyle Indicates the pointer to an <b>OH_Drawing_TextStyle</b> object. 411 * @param int Indicates the text decoration to set. For details, see the enum <b>OH_Drawing_TextDecoration</b>. 412 * @since 8 413 * @version 1.0 414 */ 415 void OH_Drawing_SetTextStyleDecoration(OH_Drawing_TextStyle*, int /* OH_Drawing_TextDecoration */); 416 417 /** 418 * @brief Sets the color for the text decoration. 419 * 420 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 421 * @param OH_Drawing_TextStyle Indicates the pointer to an <b>OH_Drawing_TextStyle</b> object. 422 * @param uint32_t Indicates the color to set. 423 * @since 8 424 * @version 1.0 425 */ 426 void OH_Drawing_SetTextStyleDecorationColor(OH_Drawing_TextStyle*, uint32_t /* color */); 427 428 /** 429 * @brief Sets the font height. 430 * 431 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 432 * @param OH_Drawing_TextStyle Indicates the pointer to an <b>OH_Drawing_TextStyle</b> object. 433 * @param double Indicates the font height to set. 434 * @since 8 435 * @version 1.0 436 */ 437 void OH_Drawing_SetTextStyleFontHeight(OH_Drawing_TextStyle*, double /* fontHeight */); 438 439 /** 440 * @brief Sets the font families. 441 * 442 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 443 * @param OH_Drawing_TextStyle Indicates the pointer to an <b>OH_Drawing_TextStyle</b> object. 444 * @param int Indicates the number of font families to set. 445 * @param char Indicates the pointer to the font families to set. 446 * @since 8 447 * @version 1.0 448 */ 449 void OH_Drawing_SetTextStyleFontFamilies(OH_Drawing_TextStyle*, 450 int /* fontFamiliesNumber */, const char* fontFamilies[]); 451 452 /** 453 * @brief Sets the font style. 454 * 455 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 456 * @param OH_Drawing_TextStyle Indicates the pointer to an <b>OH_Drawing_TextStyle</b> object. 457 * @param int Indicates the font style to set. For details, see the enum <b>OH_Drawing_FontStyle</b>. 458 * @since 8 459 * @version 1.0 460 */ 461 void OH_Drawing_SetTextStyleFontStyle(OH_Drawing_TextStyle*, int /* OH_Drawing_FontStyle */); 462 463 /** 464 * @brief Sets the locale. 465 * 466 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 467 * @param OH_Drawing_TextStyle Indicates the pointer to an <b>OH_Drawing_TextStyle</b> object. 468 * @param char Indicates the pointer to the locale to set. 469 * @since 8 470 * @version 1.0 471 */ 472 void OH_Drawing_SetTextStyleLocale(OH_Drawing_TextStyle*, const char*); 473 474 /** 475 * @brief Creates a pointer to an <b>OH_Drawing_TypographyCreate</b> object. 476 * 477 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 478 * @param OH_Drawing_TypographyStyle Indicates the pointer to an <b>OH_Drawing_TypographyStyle</b> object. 479 * @param OH_Drawing_FontCollection Indicates the pointer to an <b>OH_Drawing_FontCollection</b> object. 480 * @return Returns the pointer to the <b>OH_Drawing_TypographyCreate</b> object created. 481 * @since 8 482 * @version 1.0 483 */ 484 OH_Drawing_TypographyCreate* OH_Drawing_CreateTypographyHandler(OH_Drawing_TypographyStyle*, 485 OH_Drawing_FontCollection*); 486 487 /** 488 * @brief Releases the memory occupied by an <b>OH_Drawing_TypographyCreate</b> object. 489 * 490 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 491 * @param OH_Drawing_TypographyCreate Indicates the pointer to an <b>OH_Drawing_TypographyCreate</b> object. 492 * @since 8 493 * @version 1.0 494 */ 495 void OH_Drawing_DestroyTypographyHandler(OH_Drawing_TypographyCreate*); 496 497 /** 498 * @brief Sets the text style. 499 * 500 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 501 * @param OH_Drawing_TypographyCreate Indicates the pointer to an <b>OH_Drawing_TypographyCreate</b> object. 502 * @param OH_Drawing_TextStyle Indicates the pointer to an <b>OH_Drawing_TextStyle</b> object. 503 * @since 8 504 * @version 1.0 505 */ 506 void OH_Drawing_TypographyHandlerPushTextStyle(OH_Drawing_TypographyCreate*, OH_Drawing_TextStyle*); 507 508 /** 509 * @brief Sets the text content. 510 * 511 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 512 * @param OH_Drawing_TypographyCreate Indicates the pointer to an <b>OH_Drawing_TypographyCreate</b> object. 513 * @param char Indicates the pointer to the text content to set. 514 * @since 8 515 * @version 1.0 516 */ 517 void OH_Drawing_TypographyHandlerAddText(OH_Drawing_TypographyCreate*, const char*); 518 519 /** 520 * @brief Removes the topmost style in the stack, leaving the remaining styles in effect. 521 * 522 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 523 * @param OH_Drawing_TypographyCreate Indicates the pointer to an <b>OH_Drawing_TypographyCreate</b> object. 524 * @since 8 525 * @version 1.0 526 */ 527 void OH_Drawing_TypographyHandlerPopTextStyle(OH_Drawing_TypographyCreate*); 528 529 /** 530 * @brief Creates an <b>OH_Drawing_Typography</b> object. 531 * 532 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 533 * @param OH_Drawing_TypographyCreate Indicates the pointer to an <b>OH_Drawing_TypographyCreate</b> object. 534 * @return Returns the pointer to the <b>OH_Drawing_Typography</b> object created. 535 * @since 8 536 * @version 1.0 537 */ 538 OH_Drawing_Typography* OH_Drawing_CreateTypography(OH_Drawing_TypographyCreate*); 539 540 /** 541 * @brief Releases the memory occupied by an <b>OH_Drawing_Typography</b> object. 542 * 543 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 544 * @param OH_Drawing_Typography Indicates the pointer to an <b>OH_Drawing_Typography</b> object. 545 * @since 8 546 * @version 1.0 547 */ 548 void OH_Drawing_DestroyTypography(OH_Drawing_Typography*); 549 550 /** 551 * @brief Lays out the typography. 552 * 553 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 554 * @param OH_Drawing_Typography Indicates the pointer to an <b>OH_Drawing_Typography</b> object. 555 * @param double Indicates the maximum text width to set. 556 * @since 8 557 * @version 1.0 558 */ 559 void OH_Drawing_TypographyLayout(OH_Drawing_Typography*, double /* maxWidth */); 560 561 /** 562 * @brief Paints text on the canvas. 563 * 564 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 565 * @param OH_Drawing_Typography Indicates the pointer to an <b>OH_Drawing_Typography</b> object. 566 * @param OH_Drawing_Canvas Indicates the pointer to an <b>OH_Drawing_Canvas</b> object. 567 * @param double Indicates the x coordinate. 568 * @param double Indicates the y coordinate. 569 * @since 8 570 * @version 1.0 571 */ 572 void OH_Drawing_TypographyPaint(OH_Drawing_Typography*, OH_Drawing_Canvas*, 573 double /* potisionX */, double /* potisionY */); 574 575 /** 576 * @brief Gets the max width. 577 * 578 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 579 * @param OH_Drawing_Typography Indicates the pointer to an <b>OH_Drawing_Typography</b> object. 580 * @return Returns the max width. 581 * @since 9 582 * @version 1.1 583 */ 584 double OH_Drawing_TypographyGetMaxWidth(OH_Drawing_Typography*); 585 586 /** 587 * @brief Gets the height. 588 * 589 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 590 * @param OH_Drawing_Typography Indicates the pointer to an <b>OH_Drawing_Typography</b> object. 591 * @return Returns the height. 592 * @since 9 593 * @version 1.1 594 */ 595 double OH_Drawing_TypographyGetHeight(OH_Drawing_Typography*); 596 597 /** 598 * @brief Obtains the width of the longest line. You are advised to round up the return value in actual use. 599 * When the text content is empty, the minimum float value, 600 * that is, -340282346638528859811704183484516925440.000000, is returned. 601 * 602 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 603 * @param OH_Drawing_Typography Pointer to an <b>OH_Drawing_Typography</b> object, which is obtained by 604 * {@link OH_Drawing_CreateTypography}. 605 * @return Returns the width of the longest line. 606 * @since 9 607 * @version 1.1 608 */ 609 double OH_Drawing_TypographyGetLongestLine(OH_Drawing_Typography*); 610 611 /** 612 * @brief Gets the min intrinsic width. 613 * 614 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 615 * @param OH_Drawing_Typography Indicates the pointer to an <b>OH_Drawing_Typography</b> object. 616 * @return Returns the min intrinsic width. 617 * @since 9 618 * @version 1.1 619 */ 620 double OH_Drawing_TypographyGetMinIntrinsicWidth(OH_Drawing_Typography*); 621 622 /** 623 * @brief Gets the max intrinsic width. 624 * 625 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 626 * @param OH_Drawing_Typography Indicates the pointer to an <b>OH_Drawing_Typography</b> object. 627 * @return Returns the max intrinsic width. 628 * @since 9 629 * @version 1.1 630 */ 631 double OH_Drawing_TypographyGetMaxIntrinsicWidth(OH_Drawing_Typography*); 632 633 /** 634 * @brief Gets the alphabetic baseline. 635 * 636 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 637 * @param OH_Drawing_Typography Indicates the pointer to an <b>OH_Drawing_Typography</b> object. 638 * @return Returns the alphabetic baseline. 639 * @since 9 640 * @version 1.1 641 */ 642 double OH_Drawing_TypographyGetAlphabeticBaseline(OH_Drawing_Typography*); 643 644 /** 645 * @brief Gets the ideographic baseline. 646 * 647 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 648 * @param OH_Drawing_Typography Indicates the pointer to an <b>OH_Drawing_Typography</b> object. 649 * @return Returns the ideographic baseline. 650 * @since 9 651 * @version 1.1 652 */ 653 double OH_Drawing_TypographyGetIdeographicBaseline(OH_Drawing_Typography*); 654 655 /** 656 * @brief Sets the placeholder. 657 * 658 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 659 * @param OH_Drawing_TypographyCreate Indicates the pointer to an <b>OH_Drawing_TypographyCreate</b> object. 660 * @param OH_Drawing_PlaceholderSpan Indicates the pointer to an <b>OH_Drawing_PlaceholderSpan</b> object. 661 * @since 11 662 * @version 1.0 663 */ 664 void OH_Drawing_TypographyHandlerAddPlaceholder(OH_Drawing_TypographyCreate*, OH_Drawing_PlaceholderSpan*); 665 666 /** 667 * @brief Gets the exceed maxLines. 668 * 669 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 670 * @param OH_Drawing_Typography Indicates the pointer to an <b>OH_Drawing_Typography</b> object. 671 * @return Returns the exceed maxLines. 672 * @since 11 673 * @version 1.0 674 */ 675 bool OH_Drawing_TypographyDidExceedMaxLines(OH_Drawing_Typography*); 676 677 /** 678 * @brief Gets the rects for range. 679 * 680 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 681 * @param OH_Drawing_Typography Indicates the pointer to an <b>OH_Drawing_Typography</b> object. 682 * @param size_t Indicates the start of range to set. 683 * @param size_t Indicates the end of range to set. 684 * @param OH_Drawing_RectHeightStyle Indicates the height style to set. 685 * For details, see the enum <b>OH_Drawing_RectHeightStyle</b>. 686 * @param OH_Drawing_RectWidthStyle Indicates the width style to set. 687 * For details, see the enum <b>OH_Drawing_RectWidthStyle</b>. 688 * @return Returns the rects for range. 689 * @since 11 690 * @version 1.0 691 */ 692 OH_Drawing_TextBox* OH_Drawing_TypographyGetRectsForRange(OH_Drawing_Typography*, 693 size_t, size_t, OH_Drawing_RectHeightStyle, OH_Drawing_RectWidthStyle); 694 695 /** 696 * @brief Gets the rects for placeholders. 697 * 698 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 699 * @param OH_Drawing_Typography Indicates the pointer to an <b>OH_Drawing_Typography</b> object. 700 * @return Returns the rects for placeholders. 701 * @since 11 702 * @version 1.0 703 */ 704 OH_Drawing_TextBox* OH_Drawing_TypographyGetRectsForPlaceholders(OH_Drawing_Typography*); 705 706 /** 707 * @brief Gets left from textbox. 708 * 709 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 710 * @param OH_Drawing_TextBox Indicates the pointer to an <b>OH_Drawing_TextBox</b> object. 711 * @param int Indicates the index of textbox. 712 * @return Returns left from textbox. 713 * @since 11 714 * @version 1.0 715 */ 716 float OH_Drawing_GetLeftFromTextBox(OH_Drawing_TextBox*, int); 717 718 /** 719 * @brief Gets right from textbox. 720 * 721 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 722 * @param OH_Drawing_TextBox Indicates the pointer to an <b>OH_Drawing_TextBox</b> object. 723 * @param int Indicates the index of textbox. 724 * @return Returns right from textbox. 725 * @since 11 726 * @version 1.0 727 */ 728 float OH_Drawing_GetRightFromTextBox(OH_Drawing_TextBox*, int); 729 730 /** 731 * @brief Gets top from textbox. 732 * 733 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 734 * @param OH_Drawing_TextBox Indicates the pointer to an <b>OH_Drawing_TextBox</b> object. 735 * @param int Indicates the index of textbox. 736 * @return Returns top from textbox. 737 * @since 11 738 * @version 1.0 739 */ 740 float OH_Drawing_GetTopFromTextBox(OH_Drawing_TextBox*, int); 741 742 /** 743 * @brief Gets bottom from textbox. 744 * 745 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 746 * @param OH_Drawing_TextBox Indicates the pointer to an <b>OH_Drawing_TextBox</b> object. 747 * @param int Indicates the index of textbox. 748 * @return Returns bottom from textbox. 749 * @since 11 750 * @version 1.0 751 */ 752 float OH_Drawing_GetBottomFromTextBox(OH_Drawing_TextBox*, int); 753 754 /** 755 * @brief Gets direction from textbox. 756 * 757 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 758 * @param OH_Drawing_TextBox Indicates the pointer to an <b>OH_Drawing_TextBox</b> object. 759 * @param int Indicates the index of textbox. 760 * @return Returns direction from textbox. 761 * @since 11 762 * @version 1.0 763 */ 764 int OH_Drawing_GetTextDirectionFromTextBox(OH_Drawing_TextBox*, int); 765 766 /** 767 * @brief Gets size of textbox. 768 * 769 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 770 * @param OH_Drawing_TextBox Indicates the pointer to an <b>OH_Drawing_TextBox</b> object. 771 * @return Returns size of textbox. 772 * @since 11 773 * @version 1.0 774 */ 775 size_t OH_Drawing_GetSizeOfTextBox(OH_Drawing_TextBox*); 776 777 /** 778 * @brief Gets the glyphposition at coordinate. 779 * 780 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 781 * @param OH_Drawing_Typography Indicates the pointer to an <b>OH_Drawing_Typography</b> object. 782 * @param double Indicates the positionX of typography to set. 783 * @param double Indicates the positionY of typography to set. 784 * @return Returns the glyphposition at coordinate. 785 * @since 11 786 * @version 1.0 787 */ 788 OH_Drawing_PositionAndAffinity* OH_Drawing_TypographyGetGlyphPositionAtCoordinate(OH_Drawing_Typography*, 789 double, double); 790 791 /** 792 * @brief Gets the glyphposition at coordinate with cluster. 793 * 794 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 795 * @param OH_Drawing_Typography Indicates the pointer to an <b>OH_Drawing_Typography</b> object. 796 * @param double Indicates the positionX of typography to set. 797 * @param double Indicates the positionY of typography to set. 798 * @return Returns the glyphposition at coordinate with cluster. 799 * @since 11 800 * @version 1.0 801 */ 802 OH_Drawing_PositionAndAffinity* OH_Drawing_TypographyGetGlyphPositionAtCoordinateWithCluster(OH_Drawing_Typography*, 803 double, double); 804 805 /** 806 * @brief Gets position from position and affinity. 807 * 808 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 809 * @param OH_Drawing_PositionAndAffinity Indicates the pointer to an <b>OH_Drawing_PositionAndAffinity</b> object. 810 * @return Returns position from position and affinity. 811 * @since 11 812 * @version 1.0 813 */ 814 size_t OH_Drawing_GetPositionFromPositionAndAffinity(OH_Drawing_PositionAndAffinity*); 815 816 /** 817 * @brief Gets affinity from position and affinity. 818 * 819 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 820 * @param OH_Drawing_PositionAndAffinity Indicates the pointer to an <b>OH_Drawing_PositionAndAffinity</b> object. 821 * @return Returns affinity from position and affinity. 822 * @since 11 823 * @version 1.0 824 */ 825 int OH_Drawing_GetAffinityFromPositionAndAffinity(OH_Drawing_PositionAndAffinity*); 826 827 /** 828 * @brief Gets the word boundary. 829 * 830 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 831 * @param OH_Drawing_Typography Indicates the pointer to an <b>OH_Drawing_Typography</b> object. 832 * @param size_t Indicates the size of text to set. 833 * @return Returns the word boundary. 834 * @since 11 835 * @version 1.0 836 */ 837 OH_Drawing_Range* OH_Drawing_TypographyGetWordBoundary(OH_Drawing_Typography*, size_t); 838 839 /** 840 * @brief Gets start from range. 841 * 842 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 843 * @param OH_Drawing_Range Indicates the pointer to an <b>OH_Drawing_Range</b> object. 844 * @return Returns start from range. 845 * @since 11 846 * @version 1.0 847 */ 848 size_t OH_Drawing_GetStartFromRange(OH_Drawing_Range*); 849 850 /** 851 * @brief Gets end from range. 852 * 853 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 854 * @param OH_Drawing_Range Indicates the pointer to an <b>OH_Drawing_Range</b> object. 855 * @return Returns end from range. 856 * @since 11 857 * @version 1.0 858 */ 859 size_t OH_Drawing_GetEndFromRange(OH_Drawing_Range*); 860 861 /** 862 * @brief Gets the line count. 863 * 864 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 865 * @param OH_Drawing_Typography Indicates the pointer to an <b>OH_Drawing_Typography</b> object. 866 * @return Returns the line count. 867 * @since 11 868 * @version 1.0 869 */ 870 size_t OH_Drawing_TypographyGetLineCount(OH_Drawing_Typography*); 871 872 /** 873 * @brief Sets the decoration style. 874 * 875 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 876 * @param OH_Drawing_TextStyle Indicates the pointer to an <b>OH_Drawing_TextStyle</b> object. 877 * @param int Indicates the text decoration style to set. 878 * For details, see the enum <b>OH_Drawing_TextDecorationStyle</b>. 879 * @since 11 880 * @version 1.0 881 */ 882 void OH_Drawing_SetTextStyleDecorationStyle(OH_Drawing_TextStyle*, int); 883 884 /** 885 * @brief Sets the decoration thickness scale. 886 * 887 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 888 * @param OH_Drawing_TextStyle Indicates the pointer to an <b>OH_Drawing_TextStyle</b> object. 889 * @param double Indicates the thickness scale of text decoration to set. 890 * @since 11 891 * @version 1.0 892 */ 893 void OH_Drawing_SetTextStyleDecorationThicknessScale(OH_Drawing_TextStyle*, double); 894 895 /** 896 * @brief Sets the letter spacing. 897 * 898 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 899 * @param OH_Drawing_TextStyle Indicates the pointer to an <b>OH_Drawing_TextStyle</b> object. 900 * @param double Indicates the letter space to set. 901 * @since 11 902 * @version 1.0 903 */ 904 void OH_Drawing_SetTextStyleLetterSpacing(OH_Drawing_TextStyle*, double); 905 906 /** 907 * @brief Sets the word spacing. 908 * 909 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 910 * @param OH_Drawing_TextStyle Indicates the pointer to an <b>OH_Drawing_TextStyle</b> object. 911 * @param double Indicates the word space to set. 912 * @since 11 913 * @version 1.0 914 */ 915 void OH_Drawing_SetTextStyleWordSpacing(OH_Drawing_TextStyle*, double); 916 917 /** 918 * @brief Sets the half leading. 919 * 920 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 921 * @param OH_Drawing_TextStyle Indicates the pointer to an <b>OH_Drawing_TextStyle</b> object. 922 * @param bool Indicates the half leading to set. 923 * @since 11 924 * @version 1.0 925 */ 926 void OH_Drawing_SetTextStyleHalfLeading(OH_Drawing_TextStyle*, bool); 927 928 /** 929 * @brief Sets the ellipsis. 930 * 931 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 932 * @param OH_Drawing_TextStyle Indicates the pointer to an <b>OH_Drawing_TextStyle</b> object. 933 * @param char* Indicates the pointer to ellipsis style. 934 * @since 11 935 * @version 1.0 936 */ 937 void OH_Drawing_SetTextStyleEllipsis(OH_Drawing_TextStyle*, const char*); 938 939 /** 940 * @brief Sets the ellipsis modal. 941 * 942 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 943 * @param OH_Drawing_TextStyle Indicates the pointer to an <b>OH_Drawing_TextStyle</b> object. 944 * @param int Indicates the ellipsis model to set. For details, see the enum <b>OH_Drawing_EllipsisModal</b>. 945 * @since 11 946 * @version 1.0 947 */ 948 void OH_Drawing_SetTextStyleEllipsisModal(OH_Drawing_TextStyle*, int); 949 950 /** 951 * @brief Sets the break strategy. 952 * 953 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 954 * @param OH_Drawing_TypographyStyle Indicates the pointer to an <b>OH_Drawing_TypographyStyle</b> object. 955 * @param int Indicates the break strategy to set. For details, see the enum <b>OH_Drawing_BreakStrategy</b>. 956 * @since 11 957 * @version 1.0 958 */ 959 void OH_Drawing_SetTypographyTextBreakStrategy(OH_Drawing_TypographyStyle*, int); 960 961 /** 962 * @brief Sets the word break type. 963 * 964 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 965 * @param OH_Drawing_TypographyStyle Indicates the pointer to an <b>OH_Drawing_TypographyStyle</b> object. 966 * @param int Indicates the word break type to set. For details, see the enum <b>OH_Drawing_WordBreakType</b>. 967 * @since 11 968 * @version 1.0 969 */ 970 void OH_Drawing_SetTypographyTextWordBreakType(OH_Drawing_TypographyStyle*, int); 971 972 /** 973 * @brief Sets the ellipsis modal. 974 * 975 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 976 * @param OH_Drawing_TypographyStyle Indicates the pointer to an <b>OH_Drawing_TypographyStyle</b> object. 977 * @param int Indicates the ellipsis modal to set. For details, see the enum <b>OH_Drawing_EllipsisModal</b>. 978 * @since 11 979 * @version 1.0 980 */ 981 void OH_Drawing_SetTypographyTextEllipsisModal(OH_Drawing_TypographyStyle*, int); 982 983 /** 984 * @brief get line height. 985 * 986 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 987 * @param OH_Drawing_Typography Indicates the pointer to an <b>OH_Drawing_Typography</b> object. 988 * @param int Indicates the line number. 989 * @return Returns line height. 990 * @since 11 991 * @version 1.0 992 */ 993 double OH_Drawing_TypographyGetLineHeight(OH_Drawing_Typography*, int); 994 995 /** 996 * @brief get line width. 997 * 998 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 999 * @param OH_Drawing_Typography Indicates the pointer to an <b>OH_Drawing_Typography</b> object. 1000 * @param int Indicates the line number. 1001 * @return Returns line width. 1002 * @since 11 1003 * @version 1.0 1004 */ 1005 double OH_Drawing_TypographyGetLineWidth(OH_Drawing_Typography*, int); 1006 1007 #ifdef __cplusplus 1008 } 1009 #endif 1010 /** @} */ 1011 #endif