drawing_text_typography.h
Overview
This file declares the functions related to typography in the drawing module.
File to include: <native_drawing/drawing_text_typography.h>
Library: libnative_drawing.so
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 8
Related module: Drawing
Summary
Structs
| Name | typedef Keyword | Description |
|---|---|---|
| OH_Drawing_PlaceholderSpan | OH_Drawing_PlaceholderSpan | Describes the placeholder that acts as a span. |
| OH_Drawing_FontDescriptor | OH_Drawing_FontDescriptor | Describes the detailed information about a system font. |
| OH_Drawing_LineMetrics | OH_Drawing_LineMetrics | Describes the measurement information about a line of text. |
| OH_Drawing_FontFallbackInfo | OH_Drawing_FontFallbackInfo | Describes the information about a font fallback. |
| OH_Drawing_FontFallbackGroup | OH_Drawing_FontFallbackGroup | Describes the information about a font fallback group. |
| OH_Drawing_FontAdjustInfo | OH_Drawing_FontAdjustInfo | Describes the information about a font weight mapping. |
| OH_Drawing_FontAliasInfo | OH_Drawing_FontAliasInfo | Describes the information about a font alias. |
| OH_Drawing_FontGenericInfo | OH_Drawing_FontGenericInfo | Describes the information about generic fonts supported by the system. |
| OH_Drawing_FontConfigInfo | OH_Drawing_FontConfigInfo | Describes the information about a system font configuration. |
| OH_Drawing_FontStyleStruct | OH_Drawing_FontStyleStruct | Describes a font style. |
| OH_Drawing_FontFeature | OH_Drawing_FontFeature | Describes a font feature. |
| OH_Drawing_StrutStyle | OH_Drawing_StrutStyle | Describes a strut style. The strut style determines the line spacing, baseline alignment mode, and other properties related to the line height when drawing texts. |
| OH_Drawing_RectSize | OH_Drawing_RectSize | Defines a text rectangle structure. |
Enums
| Name | typedef Keyword | Description |
|---|---|---|
| OH_Drawing_TextDirection | - | Enumerates the text directions. |
| OH_Drawing_TextAlign | - | Enumerates the text alignment modes. |
| OH_Drawing_FontWeight | - | Enumerates the font weights. |
| OH_Drawing_TextBaseline | - | Enumerates the text baselines. |
| OH_Drawing_TextDecoration | - | Enumerates the text decorations. |
| OH_Drawing_FontStyle | - | Enumerates the font styles. |
| OH_Drawing_PlaceholderVerticalAlignment | OH_Drawing_PlaceholderVerticalAlignment | Enumerates the vertical alignment modes of placeholders. |
| OH_Drawing_TextDecorationStyle | OH_Drawing_TextDecorationStyle | Enumerates the text decoration styles. |
| OH_Drawing_EllipsisModal | OH_Drawing_EllipsisModal | Enumerates the ellipsis styles. |
| OH_Drawing_BreakStrategy | OH_Drawing_BreakStrategy | Enumerates the text break strategies. |
| OH_Drawing_WordBreakType | OH_Drawing_WordBreakType | Enumerates the word break types. |
| OH_Drawing_RectHeightStyle | OH_Drawing_RectHeightStyle | Enumerates the rectangle height styles. |
| OH_Drawing_RectWidthStyle | OH_Drawing_RectWidthStyle | Enumerates the rectangle width styles. |
| OH_Drawing_TextBadgeType | OH_Drawing_TextBadgeType | Enumerates the text badge styles. |
| OH_Drawing_FontConfigInfoErrorCode | - | Enumerates the error codes that may be used during the obtaining of system font configurations. |
| OH_Drawing_FontWidth | - | Enumerates the font widths. |
| OH_Drawing_TextHeightBehavior | - | Enumerates the text height modifier patterns. |
| OH_Drawing_TextStyleType | - | Enumerates the text style types. |
| OH_Drawing_TextVerticalAlignment | OH_Drawing_TextVerticalAlignment | Enumerates the vertical alignment modes. |
| OH_Drawing_LineHeightStyle | OH_Drawing_LineHeightStyle | Enumerates the scaling base styles of the line height. The default style is TEXT_LINE_HEIGHT_BY_FONT_SIZE. |
| OH_Drawing_TextStyleAttributeId | OH_Drawing_TextStyleAttributeId | Enumerates the text style attributes. |
| OH_Drawing_TypographyStyleAttributeId | OH_Drawing_TypographyStyleAttributeId | Enumerates the typography style attributes. For the common attributes of the typography styles and text styles, you are advised to use the text style attributes, which can be obtained from OH_Drawing_TextStyleAttributeId. |
Functions
Enum Description
OH_Drawing_TextDirection
enum OH_Drawing_TextDirection
Description
Enumerates the text directions.
Since: 8
| Value | Description |
|---|---|
| TEXT_DIRECTION_RTL | Right to left (RTL). |
| TEXT_DIRECTION_LTR | Left to right (LTR). |
OH_Drawing_TextAlign
enum OH_Drawing_TextAlign
Description
Enumerates the text alignment modes.
Since: 8
| Value | Description |
|---|---|
| TEXT_ALIGN_LEFT | Left-aligned. |
| TEXT_ALIGN_RIGHT | Right-aligned. |
| TEXT_ALIGN_CENTER | Center-aligned. |
| TEXT_ALIGN_JUSTIFY | Justified, which means that each line (except the last line) is stretched so that every line has equal width, and the left and right margins are straight. |
| TEXT_ALIGN_START | When OH_Drawing_TextDirection is set to TEXT_DIRECTION_LTR, TEXT_ALIGN_START and TEXT_ALIGN_LEFT are the same. Similarly, when OH_Drawing_TextDirection is set to TEXT_DIRECTION_RTL, TEXT_ALIGN_START and TEXT_ALIGN_RIGHT are the same. |
| TEXT_ALIGN_END | When OH_Drawing_TextDirection is set to TEXT_DIRECTION_LTR, TEXT_ALIGN_END and TEXT_ALIGN_RIGHT are the same. Similarly, when OH_Drawing_TextDirection is set to TEXT_DIRECTION_RTL, TEXT_ALIGN_END and TEXT_ALIGN_LEFT are the same. |
OH_Drawing_FontWeight
enum OH_Drawing_FontWeight
Description
Enumerates the font weights.
Since: 8
| Value | Description |
|---|---|
| FONT_WEIGHT_100 | Thin. |
| FONT_WEIGHT_200 | Extra-light. |
| FONT_WEIGHT_300 | Light. |
| FONT_WEIGHT_400 | Normal/Regular. |
| FONT_WEIGHT_500 | Medium. |
| FONT_WEIGHT_600 | Semi-bold. |
| FONT_WEIGHT_700 | Bold. |
| FONT_WEIGHT_800 | Extra-bold. |
| FONT_WEIGHT_900 | Black. |
OH_Drawing_TextBaseline
enum OH_Drawing_TextBaseline
Description
Enumerates the text baselines.
Since: 8
| Value | Description |
|---|---|
| TEXT_BASELINE_ALPHABETIC | Alphabetic, where the letters in alphabets like English sit on. |
| TEXT_BASELINE_IDEOGRAPHIC | Ideographic, where the baseline is at the bottom of the text area. |
OH_Drawing_TextDecoration
enum OH_Drawing_TextDecoration
Description
Enumerates the text decorations.
Since: 8
| Value | Description |
|---|---|
| TEXT_DECORATION_NONE = 0x0 | No decoration. |
| TEXT_DECORATION_UNDERLINE = 0x1 | An underline is used for decoration. |
| TEXT_DECORATION_OVERLINE = 0x2 | An overline is used for decoration. |
| TEXT_DECORATION_LINE_THROUGH = 0x4 | A strikethrough is used for decoration. |
OH_Drawing_FontStyle
enum OH_Drawing_FontStyle
Description
Enumerates the font styles.
Since: 8
| Value | Description |
|---|---|
| FONT_STYLE_NORMAL | Normal style. |
| FONT_STYLE_ITALIC | Italic. |
| FONT_STYLE_OBLIQUE | Oblique. |
OH_Drawing_PlaceholderVerticalAlignment
enum OH_Drawing_PlaceholderVerticalAlignment
Description
Enumerates the vertical alignment modes of placeholders.
Since: 11
| Value | Description |
|---|---|
| ALIGNMENT_OFFSET_AT_BASELINE | Aligned to the baseline. |
| ALIGNMENT_ABOVE_BASELINE | Aligned above the baseline. |
| ALIGNMENT_BELOW_BASELINE | Aligned below the baseline. |
| ALIGNMENT_TOP_OF_ROW_BOX | Aligned to the top of the row box. |
| ALIGNMENT_BOTTOM_OF_ROW_BOX | Aligned to the bottom of the row box. |
| ALIGNMENT_CENTER_OF_ROW_BOX | Aligned to the center of the row box. |
| ALIGNMENT_FOLLOW_PARAGRAPH20+ | Follows the vertical alignment mode of the text. |
OH_Drawing_TextVerticalAlignment
enum OH_Drawing_TextVerticalAlignment
Description
Enumerates the vertical alignment modes.
Since: 20
| Value | Description |
|---|---|
| TEXT_VERTICAL_ALIGNMENT_BASELINE | Aligned to the baseline. |
| TEXT_VERTICAL_ALIGNMENT_BOTTOM | Bottom aligned. |
| TEXT_VERTICAL_ALIGNMENT_CENTER | Center-aligned. |
| TEXT_VERTICAL_ALIGNMENT_TOP | Top aligned. |
OH_Drawing_TextDecorationStyle
enum OH_Drawing_TextDecorationStyle
Description
Enumerates the text decoration styles.
Since: 11
| Value | Description |
|---|---|
| TEXT_DECORATION_STYLE_SOLID | Solid style. |
| TEXT_DECORATION_STYLE_DOUBLE | Double style. |
| TEXT_DECORATION_STYLE_DOTTED | Dotted style. |
| TEXT_DECORATION_STYLE_DASHED | Dashed style. |
| TEXT_DECORATION_STYLE_WAVY | Wavy style. |
OH_Drawing_EllipsisModal
enum OH_Drawing_EllipsisModal
Description
Enumerates the ellipsis styles.
Since: 11
| Value | Description |
|---|---|
| ELLIPSIS_MODAL_HEAD = 0 | Header ellipsis mode, that is, the ellipsis appears at the beginning of a line. This enumerated value is valid only when the maximum number of text lines is set to 1 by calling OH_Drawing_SetTypographyTextMaxLines. |
| ELLIPSIS_MODAL_MIDDLE = 1 | Middle ellipsis mode, that is, the ellipsis appears in the middle of a line. This enumerated value is valid only when the maximum number of text lines is set to 1 by calling OH_Drawing_SetTypographyTextMaxLines. |
| ELLIPSIS_MODAL_TAIL = 2 | End ellipsis mode, that is, the ellipsis appears at the end of a line. This enumerated value is valid when the maximum number of text lines is set to any value by calling OH_Drawing_SetTypographyTextMaxLines. |
| ELLIPSIS_MODAL_MULTILINE_HEAD = 3 | Header ellipsis mode, that is, the ellipsis appears at the beginning of a line. This enumerated value is valid when the maximum number of text lines is set to any value by calling OH_Drawing_SetTypographyTextMaxLines. Since: 24 |
| ELLIPSIS_MODAL_MULTILINE_MIDDLE = 4 | Middle ellipsis mode, that is, the ellipsis appears in the middle of a line. This enumerated value is valid when the maximum number of text lines is set to any value by calling OH_Drawing_SetTypographyTextMaxLines. Since: 24 |
OH_Drawing_BreakStrategy
enum OH_Drawing_BreakStrategy
Description
Enumerates the text break strategies.
Since: 11
| Value | Description |
|---|---|
| BREAK_STRATEGY_GREEDY = 0 | Each line is filled as much as possible during line break. |
| BREAK_STRATEGY_HIGH_QUALITY = 1 | Text continuity is preferentially considered during line break. |
| BREAK_STRATEGY_BALANCED = 2 | Line breaks are performed at the word boundary. |
OH_Drawing_WordBreakType
enum OH_Drawing_WordBreakType
Description
Enumerates the word break types.
Since: 11
| Value | Description |
|---|---|
| WORD_BREAK_TYPE_NORMAL = 0 | Normal mode. |
| WORD_BREAK_TYPE_BREAK_ALL = 1 | Breaks the words at any character to prevent overflow. |
| WORD_BREAK_TYPE_BREAK_WORD = 2 | Breaks the words at arbitrary points to prevent overflow. |
| WORD_BREAK_TYPE_BREAK_HYPHEN = 3 | Uses a hyphen (-) to break a word at the end of each line. If adding a hyphen is not possible, it will behave the same as WORD_BREAK_TYPE_BREAK_WORD. Since: 18 |
OH_Drawing_RectHeightStyle
enum OH_Drawing_RectHeightStyle
Description
Enumerates the rectangle height styles.
Since: 11
| Value | Description |
|---|---|
| RECT_HEIGHT_STYLE_TIGHT | Tight style. |
| RECT_HEIGHT_STYLE_MAX | Maximum style. |
| RECT_HEIGHT_STYLE_INCLUDELINESPACEMIDDLE | Middle style that includes the line spacing. |
| RECT_HEIGHT_STYLE_INCLUDELINESPACETOP | Top style that includes the line spacing. |
| RECT_HEIGHT_STYLE_INCLUDELINESPACEBOTTOM | Bottom style that includes the line spacing. |
| RECT_HEIGHT_STYLE_STRUCT | Structure style. |
OH_Drawing_RectWidthStyle
enum OH_Drawing_RectWidthStyle
Description
Enumerates the rectangle width styles.
Since: 11
| Value | Description |
|---|---|
| RECT_WIDTH_STYLE_TIGHT | Tight style. |
| RECT_WIDTH_STYLE_MAX | Maximum style. |
OH_Drawing_TextBadgeType
enum OH_Drawing_TextBadgeType
Description
Enumerates the text badge styles.
Since: 20
| Value | Description |
|---|---|
| TEXT_BADGE_NONE | Disables the superscript and subscript. |
| TEXT_SUPERSCRIPT | Enables the superscript. |
| TEXT_SUBSCRIPT | Enables the subscript. |
OH_Drawing_FontConfigInfoErrorCode
enum OH_Drawing_FontConfigInfoErrorCode
Description
Enumerates the error codes that may be used during the obtaining of system font configurations.
Since: 12
| Value | Description |
|---|---|
| SUCCESS_FONT_CONFIG_INFO = 0 | Operation successful. |
| ERROR_FONT_CONFIG_INFO_UNKNOWN = 1 | Unknown error. |
| ERROR_FONT_CONFIG_INFO_PARSE_FILE = 2 | Failed to parse the system configuration file. |
| ERROR_FONT_CONFIG_INFO_ALLOC_MEMORY = 3 | Memory allocation fails. |
| ERROR_FONT_CONFIG_INFO_COPY_STRING_DATA = 4 | Failed to copy the string data. |
OH_Drawing_FontWidth
enum OH_Drawing_FontWidth
Description
Enumerates the font widths.
Since: 12
| Value | Description |
|---|---|
| FONT_WIDTH_ULTRA_CONDENSED = 1 | Ultra condensed font. |
| FONT_WIDTH_EXTRA_CONDENSED = 2 | Extra condensed font. |
| FONT_WIDTH_CONDENSED = 3 | Condensed font. |
| FONT_WIDTH_SEMI_CONDENSED = 4 | Semi-condensed font. |
| FONT_WIDTH_NORMAL = 5 | Normal font. |
| FONT_WIDTH_SEMI_EXPANDED = 6 | Semi-expanded font. |
| FONT_WIDTH_EXPANDED = 7 | Expanded font. |
| FONT_WIDTH_EXTRA_EXPANDED = 8 | Extra expanded font. |
| FONT_WIDTH_ULTRA_EXPANDED = 9 | Ultra expanded font. |
OH_Drawing_TextHeightBehavior
enum OH_Drawing_TextHeightBehavior
Description
Enumerates the text height modifier patterns.
Since: 12
| Value | Description |
|---|---|
| TEXT_HEIGHT_ALL = 0x0 | Enables the height set by calling OH_Drawing_SetTextStyleFontHeight for the top of the first line and the bottom of the last line in a paragraph. |
| TEXT_HEIGHT_DISABLE_FIRST_ASCENT = 0x1 | Disables the height set by calling OH_Drawing_SetTextStyleFontHeight for the top of the first line in a paragraph. |
| TEXT_HEIGHT_DISABLE_LAST_ASCENT = 0x2 | Disables the height set by calling OH_Drawing_SetTextStyleFontHeight for the bottom of the last line in a paragraph. |
| TEXT_HEIGHT_DISABLE_ALL = 0x1 |0x2 | Disables the height set by calling OH_Drawing_SetTextStyleFontHeight for both the top of the first line and the bottom of the last line in a paragraph. |
OH_Drawing_TextStyleType
enum OH_Drawing_TextStyleType
Description
Enumerates the text style types.
Since: 12
| Value | Description |
|---|---|
| TEXT_STYLE_NONE | No text style. |
| TEXT_STYLE_ALL_ATTRIBUTES | All text styles. |
| TEXT_STYLE_FONT | Font style. |
| TEXT_STYLE_FOREGROUND | Text foreground style. |
| TEXT_STYLE_BACKGROUND | Text background style. |
| TEXT_STYLE_SHADOW | Text shadow style. |
| TEXT_STYLE_DECORATIONS | Text decoration style. |
| TEXT_STYLE_LETTER_SPACING | Text letter spacing style. |
| TEXT_STYLE_WORD_SPACING | Text word spacing style. |
OH_Drawing_LineHeightStyle
enum OH_Drawing_LineHeightStyle
Description
Enumerates the scaling base styles of the line height. The default style is TEXT_LINE_HEIGHT_BY_FONT_SIZE.
Since: 21
| Value | Description |
|---|---|
| TEXT_LINE_HEIGHT_BY_FONT_SIZE = 0 | Uses the font size as the scaling base. Formula for calculating the line height: FontSize x FontHeight. FontSize can be obtained from the OH_Drawing_TextStyleGetFontSize API. FontHeight can be obtained from the OH_Drawing_TextStyleGetFontHeight API. |
| TEXT_LINE_HEIGHT_BY_FONT_HEIGHT = 1 | Uses the font height as the scaling base. Formula for calculating the line height: font height x FontHeight. The font height is obtained after the text is shaped using the font file. FontHeight can be obtained from the OH_Drawing_TextStyleGetFontHeight API. |
OH_Drawing_TextStyleAttributeId
enum OH_Drawing_TextStyleAttributeId
Description
Enumerates the text style attributes.
Since: 21
| Value | Description |
|---|---|
| TEXT_STYLE_ATTR_D_LINE_HEIGHT_MAXIMUM = 0 | Maximum line height. If line height scaling is enabled, the maximum line height takes effect only when FontHeight (which can be obtained from OH_Drawing_TextStyleGetFontHeight) is greater than 0. The value is the positive part of a single-precision floating point number. By default, it equals the maximum possible value for such a number. |
| TEXT_STYLE_ATTR_D_LINE_HEIGHT_MINIMUM = 1 | Minimum line height. If line height scaling is enabled, the minimum line height takes effect only when FontHeight (which can be obtained from OH_Drawing_TextStyleGetFontHeight) is greater than 0. The value is the non-negative part of a single-precision floating point number. The default value is 0. |
| TEXT_STYLE_ATTR_I_LINE_HEIGHT_STYLE = 2 | Scaling base style of the line height. For details, see OH_Drawing_LineHeightStyle. |
| TEXT_STYLE_ATTR_I_FONT_WIDTH = 3 | Font width. |
| TEXT_STYLE_ATTR_I_FONT_EDGING = 4 | Font edge processing mode. Anti-aliasing is used by default. For details about how to process font edges, see OH_Drawing_FontEdging. Since: 24 |
OH_Drawing_TypographyStyleAttributeId
enum OH_Drawing_TypographyStyleAttributeId
Description
Enumerates the typography style attributes.
For the common attributes of the typography styles and text styles, you are advised to use the text style attributes, which can be obtained from OH_Drawing_TextStyleAttributeId.
Since: 21
| Value | Description |
|---|---|
| TYPOGRAPHY_STYLE_ATTR_D_LINE_HEIGHT_MAXIMUM = 0 | Maximum line height. If line height scaling is enabled, the maximum line height takes effect only when FontHeight (which can be obtained from OH_Drawing_TextStyleGetFontHeight) is greater than 0. The value is the positive part of a single-precision floating point number. |
| TYPOGRAPHY_STYLE_ATTR_D_LINE_HEIGHT_MINIMUM = 1 | Minimum line height. If line height scaling is enabled, the minimum line height takes effect only when FontHeight (which can be obtained from OH_Drawing_TextStyleGetFontHeight) is greater than 0. The value is the non-negative part of a single-precision floating point number. The default value is 0. |
| TYPOGRAPHY_STYLE_ATTR_D_LINE_SPACING = 2 | Interline spacing. lineSpacing is not restricted by the maximum and minimum line heights. By default, line spacing is added to the last line. You can set textHeightBehavior to DISABLE_LAST_ASCENT in OH_Drawing_TypographyTextSetHeightBehavior to disable the line spacing of the last line. The default value is 0. |
| TYPOGRAPHY_STYLE_ATTR_I_LINE_HEIGHT_STYLE = 3 | Scaling base style of the line height. For details, see OH_Drawing_LineHeightStyle. |
| TYPOGRAPHY_STYLE_ATTR_I_FONT_WIDTH = 4 | Font width. |
| TYPOGRAPHY_STYLE_ATTR_B_COMPRESS_HEAD_PUNCTUATION = 5 | Sets whether to use punctuation compression at the beginning of a line in text layout. NOTE 1. The font file must support the ss08 feature in OH_Drawing_FontFeature. Otherwise, compression cannot be performed. 2. Only the punctuations within the punctuation compression range at the beginning of a line are in the scope of this feature. Since: 23 |
| TYPOGRAPHY_STYLE_ATTR_B_INCLUDE_FONT_PADDING = 6 | Sets whether to enable the built-in padding of the font during text typography. Since: 23 |
| TYPOGRAPHY_STYLE_ATTR_B_FALLBACK_LINE_SPACING = 7 | Sets whether to enable the line spacing rollback mechanism during text typography. Since: 23 |
| TYPOGRAPHY_STYLE_ATTR_I_ELLIPSIS_MODAL = 8 | Ellipsis style. For details about the ellipsis style, see OH_Drawing_EllipsisModal. Since: 24 |
| TYPOGRAPHY_STYLE_ATTR_DA_LINE_HEAD_INDENT = 9 | First-line indent array. All values in the indent array must be greater than or equal to 0. Each element in the array represents the indentation value of a single line. If the actual number of text lines exceeds the length of the indent array, the last value of the array is applied to the extra lines. Since: 26.0.0 |
| TYPOGRAPHY_STYLE_ATTR_D_FIRST_LINE_HEAD_INDENT = 10 | First-line indent of a paragraph. The indent value must be greater than or equal to 0. Since: 26.0.0 |
| TYPOGRAPHY_STYLE_ATTR_DA_LINE_TAIL_INDENT = 11 | Last-line indent array. All values in the indent array must be greater than or equal to 0. Each element in the array represents the indentation value of a single line. If the actual number of text lines exceeds the length of the indent array, the last value of the array is applied to the extra lines. Since: 26.0.0 |
Function Description
OH_Drawing_CreateTypographyStyle()
OH_Drawing_TypographyStyle* OH_Drawing_CreateTypographyStyle(void)
Description
Creates an OH_Drawing_TypographyStyle object. Release this pointer by calling OH_Drawing_DestroyTypographyStyle when this object is no longer needed.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 8
Returns
| Type | Description |
|---|---|
| OH_Drawing_TypographyStyle* | Pointer to the created OH_Drawing_TypographyStyle object. |
OH_Drawing_DestroyTypographyStyle()
void OH_Drawing_DestroyTypographyStyle(OH_Drawing_TypographyStyle* style)
Description
Destroys an OH_Drawing_TypographyStyle object and reclaims the memory occupied by the object.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 8
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
OH_Drawing_SetTypographyTextDirection()
void OH_Drawing_SetTypographyTextDirection(OH_Drawing_TypographyStyle* style, int direction)
Description
Sets the text direction in a typography style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 8
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
| int direction | Text direction. For details about the available options, see OH_Drawing_TextDirection. |
OH_Drawing_SetTypographyTextAlign()
void OH_Drawing_SetTypographyTextAlign(OH_Drawing_TypographyStyle* style, int align)
Description
Text alignment mode.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 8
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
| int align | Text alignment mode. For details about the available options, see OH_Drawing_TextAlign. |
OH_Drawing_TypographyGetEffectiveAlignment()
int OH_Drawing_TypographyGetEffectiveAlignment(OH_Drawing_TypographyStyle* style)
Description
Obtains the text alignment mode.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Deprecated from: 18
Replaced by: OH_Drawing_TypographyStyleGetEffectiveAlignment
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
Returns
| Type | Description |
|---|---|
| int | Text alignment mode. |
OH_Drawing_SetTypographyTextMaxLines()
void OH_Drawing_SetTypographyTextMaxLines(OH_Drawing_TypographyStyle* style, int lineNumber)
Description
Sets the maximum number of lines in the text.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 8
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
| int lineNumber | Maximum number of lines. |
OH_Drawing_CreateTextStyle()
OH_Drawing_TextStyle* OH_Drawing_CreateTextStyle(void)
Description
Creates an OH_Drawing_TextStyle object.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 8
Returns
| Type | Description |
|---|---|
| OH_Drawing_TextStyle* | Pointer to the created OH_Drawing_TextStyle object. |
OH_Drawing_TypographyGetTextStyle()
OH_Drawing_TextStyle* OH_Drawing_TypographyGetTextStyle(OH_Drawing_TypographyStyle* style)
Description
Obtains the default text style of a typography style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_TextStyle* | Pointer to the OH_Drawing_TextStyle object. Release this pointer by calling OH_Drawing_DestroyTextStyle when this object is no longer needed. |
OH_Drawing_DestroyTextStyle()
void OH_Drawing_DestroyTextStyle(OH_Drawing_TextStyle* style)
Description
Destroys an OH_Drawing_TextStyle object and reclaims the memory occupied by the object.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 8
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
OH_Drawing_SetTextStyleColor()
void OH_Drawing_SetTextStyleColor(OH_Drawing_TextStyle* style, uint32_t color)
Description
Sets the color for a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 8
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
| uint32_t color | Color. |
OH_Drawing_SetTextStyleFontSize()
void OH_Drawing_SetTextStyleFontSize(OH_Drawing_TextStyle* style, double fontSize)
Description
Sets the font size for a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 8
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
| double fontSize | Font size to set. |
OH_Drawing_SetTextStyleFontWeight()
void OH_Drawing_SetTextStyleFontWeight(OH_Drawing_TextStyle* style, int fontWeight)
Description
Sets the font weight for a text style. Currently, only the default system font supports font weight adjustment. For other fonts, if the weight is less than semi-bold, there is no variation in stroke thickness. If the weight is greater than or equal to semi-bold, it might result in a fake bold effect.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 8
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
| int fontWeight | Font weight. For details about the available options, see OH_Drawing_FontWeight. |
OH_Drawing_SetTextStyleBaseLine()
void OH_Drawing_SetTextStyleBaseLine(OH_Drawing_TextStyle* style, int baseline)
Description
Sets the baseline for a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 8
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
| int baseline | Text baseline. For details about the available options, see OH_Drawing_TextBaseline. |
OH_Drawing_SetTextStyleDecoration()
void OH_Drawing_SetTextStyleDecoration(OH_Drawing_TextStyle* style, int decoration)
Description
Sets the decoration for a text style. Only one decoration can be set. To add multiple decorations, use OH_Drawing_AddTextStyleDecoration.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 8
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
| int decoration | Text decoration. For details about the available options, see OH_Drawing_TextDecoration. |
OH_Drawing_AddTextStyleDecoration()
void OH_Drawing_AddTextStyleDecoration(OH_Drawing_TextStyle* style, int decoration)
Description
Adds the decoration for a text style. Multiple decoration lines can be displayed.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 18
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
| int decoration | Decoration to add. The value 1 means to add an underline, 2 means to add an overline, and 4 means to add a strikethrough. You can add various decoration lines at a time via bitwise OR operations. If a decoration style that is not in the OH_Drawing_TextDecoration enumeration is set, the original decoration is retained. |
OH_Drawing_RemoveTextStyleDecoration()
void OH_Drawing_RemoveTextStyleDecoration(OH_Drawing_TextStyle* style, int decoration)
Description
Removes the decoration for a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 18
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
| int decoration | Decoration to remove. The value 1 means to remove an underline, 2 means to remove an overline, and 4 means to remove a strikethrough. You can remove various text decorations at a time via bitwise OR operations. If a decoration style that is not in the OH_Drawing_TextDecoration enumeration is set, the original decoration is retained. |
OH_Drawing_SetTextStyleDecorationColor()
void OH_Drawing_SetTextStyleDecorationColor(OH_Drawing_TextStyle* style, uint32_t color)
Description
Sets the decoration color for a text style. If this API is not called or color is set to 0, the decoration color follows the text color.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 8
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
| uint32_t color | Color. |
OH_Drawing_SetTextStyleFontHeight()
void OH_Drawing_SetTextStyleFontHeight(OH_Drawing_TextStyle* style, double fontHeight)
Description
Sets the line height based on the multiple of the font size.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 8
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
| double fontHeight | Multiple of the font size. |
OH_Drawing_SetTextStyleFontFamilies()
void OH_Drawing_SetTextStyleFontFamilies(OH_Drawing_TextStyle* style,int fontFamiliesNumber, const char* fontFamilies[])
Description
Sets the font families for a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 8
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
| int fontFamiliesNumber | Number of font families. A negative number is not allowed. |
| fontFamilies | Pointer to the font families. |
OH_Drawing_SetTextStyleFontStyle()
void OH_Drawing_SetTextStyleFontStyle(OH_Drawing_TextStyle* style, int fontStyle)
Description
Sets the font style for a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 8
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
| int fontStyle | Font style. For details about the available options, see OH_Drawing_FontStyle. |
OH_Drawing_SetTextStyleLocale()
void OH_Drawing_SetTextStyleLocale(OH_Drawing_TextStyle* style, const char* locale)
Description
Sets the locale for a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 8
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
| const char* locale | Pointer to the locale. For example, 'en' indicates English, 'zh-Hans' indicates Simplified Chinese, and 'zh-Hant' indicates Traditional Chinese. If it is not specified, the default locale is 'zh-Hans'. |
OH_Drawing_SetTextStyleForegroundBrush()
void OH_Drawing_SetTextStyleForegroundBrush(OH_Drawing_TextStyle* style, OH_Drawing_Brush* foregroundBrush)
Description
Sets the foreground brush for a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
| OH_Drawing_Brush* foregroundBrush | Pointer to the OH_Drawing_Brush object, which is obtained from OH_Drawing_BrushCreate. |
OH_Drawing_TextStyleGetForegroundBrush()
void OH_Drawing_TextStyleGetForegroundBrush(OH_Drawing_TextStyle* style, OH_Drawing_Brush* foregroundBrush)
Description
Obtains the foreground brush of a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
| OH_Drawing_Brush* foregroundBrush | Pointer to the OH_Drawing_Brush object, which is obtained from OH_Drawing_BrushCreate. |
OH_Drawing_SetTextStyleForegroundPen()
void OH_Drawing_SetTextStyleForegroundPen(OH_Drawing_TextStyle* style, OH_Drawing_Pen* foregroundPen)
Description
Sets the foreground pen for a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
| OH_Drawing_Pen* foregroundPen | Pointer to the OH_Drawing_Pen object, which is obtained from OH_Drawing_PenCreate. |
OH_Drawing_TextStyleGetForegroundPen()
void OH_Drawing_TextStyleGetForegroundPen(OH_Drawing_TextStyle* style, OH_Drawing_Pen* foregroundPen)
Description
Obtains the foreground pen of a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
| OH_Drawing_Pen* foregroundPen | Pointer to the OH_Drawing_Pen object, which is obtained from OH_Drawing_PenCreate. |
OH_Drawing_SetTextStyleBackgroundBrush()
void OH_Drawing_SetTextStyleBackgroundBrush(OH_Drawing_TextStyle* style, OH_Drawing_Brush* backgroundBrush)
Description
Sets the background brush for a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
| OH_Drawing_Brush* backgroundBrush | Pointer to the OH_Drawing_Brush object, which is obtained from OH_Drawing_BrushCreate. |
OH_Drawing_TextStyleGetBackgroundBrush()
void OH_Drawing_TextStyleGetBackgroundBrush(OH_Drawing_TextStyle* style, OH_Drawing_Brush* backgroundBrush)
Description
Obtains the background brush of a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
| OH_Drawing_Brush* backgroundBrush | Pointer to the OH_Drawing_Brush object, which is obtained from OH_Drawing_BrushCreate. |
OH_Drawing_SetTextStyleBackgroundPen()
void OH_Drawing_SetTextStyleBackgroundPen(OH_Drawing_TextStyle* style, OH_Drawing_Pen* backgroundPen)
Description
Sets the background pen for a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
| OH_Drawing_Pen* backgroundPen | Pointer to the OH_Drawing_Pen object, which is obtained from OH_Drawing_PenCreate. |
OH_Drawing_TextStyleGetBackgroundPen()
void OH_Drawing_TextStyleGetBackgroundPen(OH_Drawing_TextStyle* style, OH_Drawing_Pen* backgroundPen)
Description
Obtains the background pen of a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
| OH_Drawing_Pen* backgroundPen | Pointer to the OH_Drawing_Pen object, which is obtained from OH_Drawing_PenCreate. |
OH_Drawing_CreateTypographyHandler()
OH_Drawing_TypographyCreate* OH_Drawing_CreateTypographyHandler(OH_Drawing_TypographyStyle* style,OH_Drawing_FontCollection* fontCollection)
Description
Creates an OH_Drawing_TypographyCreate object. Release this pointer by calling OH_Drawing_DestroyTypographyHandler when this object is no longer needed. You are advised to use the OH_Drawing_CreateSharedFontCollection function to create an OH_Drawing_FontCollection object.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 8
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
| OH_Drawing_FontCollection* fontCollection | Pointer to the OH_Drawing_FontCollection object, which is obtained from OH_Drawing_CreateFontCollection. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_TypographyCreate* | Pointer to the OH_Drawing_TypographyCreate object created. |
OH_Drawing_DestroyTypographyHandler()
void OH_Drawing_DestroyTypographyHandler(OH_Drawing_TypographyCreate* handler)
Description
Destroys an OH_Drawing_TypographyCreate object and reclaims the memory occupied by the object.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 8
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyCreate* handler | Pointer to the OH_Drawing_TypographyCreate object, which is obtained from OH_Drawing_CreateTypographyHandler. |
OH_Drawing_TypographyHandlerPushTextStyle()
void OH_Drawing_TypographyHandlerPushTextStyle(OH_Drawing_TypographyCreate* handler, OH_Drawing_TextStyle* style)
Description
Pushes a text style into the text style stack. Any text added afterward will use the style currently on top of the stack.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 8
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyCreate* handler | Pointer to the OH_Drawing_TypographyCreate object, which is obtained from OH_Drawing_CreateTypographyHandler. |
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
OH_Drawing_TypographyHandlerAddText()
void OH_Drawing_TypographyHandlerAddText(OH_Drawing_TypographyCreate* handler, const char* text)
Description
Adds text.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 8
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyCreate* handler | Pointer to the OH_Drawing_TypographyCreate object, which is obtained from OH_Drawing_CreateTypographyHandler. |
| const char* text | Pointer to the text content. |
OH_Drawing_TypographyHandlerPopTextStyle()
void OH_Drawing_TypographyHandlerPopTextStyle(OH_Drawing_TypographyCreate* handler)
Description
Pops the top text style out of the text style stack.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 8
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyCreate* handler | Pointer to the OH_Drawing_TypographyCreate object, which is obtained from OH_Drawing_CreateTypographyHandler. |
OH_Drawing_CreateTypography()
OH_Drawing_Typography* OH_Drawing_CreateTypography(OH_Drawing_TypographyCreate* handler)
Description
Creates an OH_Drawing_Typography object. Release this pointer by calling OH_Drawing_DestroyTypography when this object is no longer needed.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 8
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyCreate* handler | Pointer to the OH_Drawing_TypographyCreate object, which is obtained from OH_Drawing_CreateTypographyHandler. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_Typography* | Pointer to the OH_Drawing_Typography object created. |
OH_Drawing_DestroyTypography()
void OH_Drawing_DestroyTypography(OH_Drawing_Typography* typography)
Description
Destroys an OH_Drawing_Typography object and reclaims the memory occupied by the object.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 8
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Typography* typography | Pointer to the OH_Drawing_Typography object, which is obtained from OH_Drawing_CreateTypography. |
OH_Drawing_TypographyLayout()
void OH_Drawing_TypographyLayout(OH_Drawing_Typography* typography, double maxWidth)
Description
Lays out the typography.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 8
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Typography* typography | Pointer to the OH_Drawing_Typography object, which is obtained from OH_Drawing_CreateTypography. |
| double maxWidth | Maximum text width. |
OH_Drawing_TypographyPaint()
void OH_Drawing_TypographyPaint(OH_Drawing_Typography* typography, OH_Drawing_Canvas* canvas,double positionX, double positionY)
Description
Draws text from the upper left corner at a specified position. This function must be called after OH_Drawing_TypographyLayout is called and applied.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 8
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Typography* typography | Pointer to the OH_Drawing_Typography object, which is obtained from OH_Drawing_CreateTypography. |
| OH_Drawing_Canvas* canvas | Pointer to the OH_Drawing_Canvas object, which is obtained from OH_Drawing_CanvasCreate. |
| double positionX | X coordinate. |
| double positionY | Y coordinate. |
OH_Drawing_TypographyPaintOnPath()
void OH_Drawing_TypographyPaintOnPath(OH_Drawing_Typography* typography, OH_Drawing_Canvas* canvas,OH_Drawing_Path* path, double hOffset, double vOffset)
Description
Draws text along a path. To prevent text overlap caused by the text width exceeding the layout width, you are advised to use OH_Drawing_SetTypographyTextMaxLines to limit the text to a single line.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Typography* typography | Pointer to the OH_Drawing_Typography object, which is obtained from OH_Drawing_CreateTypography. |
| OH_Drawing_Canvas* canvas | Pointer to the OH_Drawing_Canvas object, which is obtained from OH_Drawing_CanvasCreate. |
| OH_Drawing_Path* path | Pointer to the OH_Drawing_Path object, which is obtained from OH_Drawing_PathCreate. |
| double hOffset | Horizontal offset of the text along the path (X axis). A positive number indicates that the text is moved forward, and a negative number indicates that the text is moved backward. |
| double vOffset | Vertical offset of the text along the path (Y axis). A positive number indicates that the text is moved downward, and a negative number indicates that the text is moved upward. |
OH_Drawing_TypographyGetMaxWidth()
double OH_Drawing_TypographyGetMaxWidth(OH_Drawing_Typography* typography)
Description
Obtains the typography width set by the user. This function must be called after OH_Drawing_TypographyLayout is called.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 9
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Typography* typography | Pointer to the OH_Drawing_Typography object, which is obtained from OH_Drawing_CreateTypography. |
Returns
| Type | Description |
|---|---|
| double | Maximum width. |
OH_Drawing_TypographyGetHeight()
double OH_Drawing_TypographyGetHeight(OH_Drawing_Typography* typography)
Description
Obtains the overall height of a typography object. This function must be called after OH_Drawing_TypographyLayout is called.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 9
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Typography* typography | Pointer to the OH_Drawing_Typography object, which is obtained from OH_Drawing_CreateTypography. |
Returns
| Type | Description |
|---|---|
| double | Height. |
OH_Drawing_TypographyGetLongestLine()
double OH_Drawing_TypographyGetLongestLine(OH_Drawing_Typography* typography)
Description
Obtains the width of the longest line in a typography object. This function must be called after OH_Drawing_TypographyLayout is called. You are advised to round up the return value. If the text content is empty, 0.0 is returned.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 9
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Typography* typography | Pointer to the OH_Drawing_Typography object, which is obtained from OH_Drawing_CreateTypography. |
Returns
| Type | Description |
|---|---|
| double | Width of the longest line. |
OH_Drawing_TypographyGetLongestLineWithIndent()
double OH_Drawing_TypographyGetLongestLineWithIndent(OH_Drawing_Typography* typography)
Description
Obtains the width of the longest line of a typography object, including its indentation. This function must be called after OH_Drawing_TypographyLayout is called. You are advised to round up the return value. If the text content is empty, 0.0 is returned.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 13
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Typography* typography | Pointer to the OH_Drawing_Typography object, which is obtained from OH_Drawing_CreateTypography. |
Returns
| Type | Description |
|---|---|
| double | Width of the longest line, including its indentation, in px. |
OH_Drawing_TypographyGetMinIntrinsicWidth()
double OH_Drawing_TypographyGetMinIntrinsicWidth(OH_Drawing_Typography* typography)
Description
Obtains the minimum intrinsic width in a typography object. This function must be called after OH_Drawing_TypographyLayout is called.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 9
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Typography* typography | Pointer to the OH_Drawing_Typography object, which is obtained from OH_Drawing_CreateTypography. |
Returns
| Type | Description |
|---|---|
| double | Minimum intrinsic width. |
OH_Drawing_TypographyGetMaxIntrinsicWidth()
double OH_Drawing_TypographyGetMaxIntrinsicWidth(OH_Drawing_Typography* typography)
Description
Obtains the maximum intrinsic width in a typography object. This function must be called after OH_Drawing_TypographyLayout is called.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 9
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Typography* typography | Pointer to the OH_Drawing_Typography object, which is obtained from OH_Drawing_CreateTypography. |
Returns
| Type | Description |
|---|---|
| double | Maximum intrinsic width. |
OH_Drawing_TypographyGetAlphabeticBaseline()
double OH_Drawing_TypographyGetAlphabeticBaseline(OH_Drawing_Typography* typography)
Description
Obtains the alphabetic baseline in a typography object.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 9
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Typography* typography | Pointer to the OH_Drawing_Typography object, which is obtained from OH_Drawing_CreateTypography. |
Returns
| Type | Description |
|---|---|
| double | Alphabetic baseline. |
OH_Drawing_TypographyGetIdeographicBaseline()
double OH_Drawing_TypographyGetIdeographicBaseline(OH_Drawing_Typography* typography)
Description
Obtains the ideographic baseline in a typography object.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 9
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Typography* typography | Pointer to the OH_Drawing_Typography object, which is obtained from OH_Drawing_CreateTypography. |
Returns
| Type | Description |
|---|---|
| double | Ideographic baseline. |
OH_Drawing_TypographyHandlerAddPlaceholder()
void OH_Drawing_TypographyHandlerAddPlaceholder(OH_Drawing_TypographyCreate* handler,OH_Drawing_PlaceholderSpan* span)
Description
Adds a placeholder.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 11
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyCreate* handler | Pointer to the OH_Drawing_TypographyCreate object, which is obtained from OH_Drawing_CreateTypographyHandler. |
| OH_Drawing_PlaceholderSpan* span | Pointer to the OH_Drawing_PlaceholderSpan object. |
OH_Drawing_TypographyDidExceedMaxLines()
bool OH_Drawing_TypographyDidExceedMaxLines(OH_Drawing_Typography* typography)
Description
Checks whether the text in the typography object exceeds the line limit. This function must be called after OH_Drawing_TypographyLayout is called. It returns false if the line limit is not set using OH_Drawing_SetTypographyTextMaxLines.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 11
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Typography* typography | Pointer to the OH_Drawing_Typography object, which is obtained from OH_Drawing_CreateTypography. |
Returns
| Type | Description |
|---|---|
| bool | Returns true if the maximum number of lines is exceeded; returns false otherwise. |
OH_Drawing_TypographyGetRectsForRange()
OH_Drawing_TextBox* OH_Drawing_TypographyGetRectsForRange(OH_Drawing_Typography* typography,size_t start, size_t end, OH_Drawing_RectHeightStyle heightStyle, OH_Drawing_RectWidthStyle widthStyle)
Description
Obtains text boxes in a given range of a typography object. This function must be called after OH_Drawing_TypographyLayout is called. Release this pointer by calling OH_Drawing_TypographyDestroyTextBox when this object is no longer needed.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 11
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Typography* typography | Pointer to the OH_Drawing_Typography object, which is obtained from OH_Drawing_CreateTypography. |
| size_t start | Start position. |
| size_t end | End position. |
| OH_Drawing_RectHeightStyle heightStyle | Height style. For details about the available options, see OH_Drawing_RectHeightStyle. |
| OH_Drawing_RectWidthStyle widthStyle | Width style. For details about the available options, see OH_Drawing_RectWidthStyle. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_TextBox* | Text box in the specified range. For details, see OH_Drawing_TextBox. |
OH_Drawing_TypographyGetRectsForPlaceholders()
OH_Drawing_TextBox* OH_Drawing_TypographyGetRectsForPlaceholders(OH_Drawing_Typography* typography)
Description
Obtains text boxes for placeholders in a typography object. This function must be called after OH_Drawing_TypographyLayout is called. Release this pointer by calling OH_Drawing_TypographyDestroyTextBox when this object is no longer needed.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 11
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Typography* typography | Pointer to the OH_Drawing_Typography object, which is obtained from OH_Drawing_CreateTypography. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_TextBox* | Placeholder text box. The return type is OH_Drawing_TextBox. |
OH_Drawing_GetLeftFromTextBox()
float OH_Drawing_GetLeftFromTextBox(OH_Drawing_TextBox* textbox, int index)
Description
Obtains the left position of a text box.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 11
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextBox* textbox | Pointer to the OH_Drawing_TextBox object, which is obtained from OH_Drawing_TypographyGetRectsForRange or OH_Drawing_TypographyGetRectsForPlaceholders. |
| int index | Index of the text box. |
Returns
| Type | Description |
|---|---|
| float | Left position. |
OH_Drawing_GetRightFromTextBox()
float OH_Drawing_GetRightFromTextBox(OH_Drawing_TextBox* textbox, int index)
Description
Obtains the right position of a text box.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 11
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextBox* textbox | Pointer to the OH_Drawing_TextBox object, which is obtained from OH_Drawing_TypographyGetRectsForRange or OH_Drawing_TypographyGetRectsForPlaceholders. |
| int index | Index of the text box. |
Returns
| Type | Description |
|---|---|
| float | Right position. |
OH_Drawing_GetTopFromTextBox()
float OH_Drawing_GetTopFromTextBox(OH_Drawing_TextBox* textbox, int index)
Description
Obtains the top position of a text box.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 11
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextBox* textbox | Pointer to the OH_Drawing_TextBox object, which is obtained from OH_Drawing_TypographyGetRectsForRange or OH_Drawing_TypographyGetRectsForPlaceholders. |
| int index | Index of the text box. |
Returns
| Type | Description |
|---|---|
| float | Top position. |
OH_Drawing_GetBottomFromTextBox()
float OH_Drawing_GetBottomFromTextBox(OH_Drawing_TextBox* textbox, int index)
Description
Obtains the bottom position of a text box.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 11
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextBox* textbox | Pointer to the OH_Drawing_TextBox object, which is obtained from OH_Drawing_TypographyGetRectsForRange or OH_Drawing_TypographyGetRectsForPlaceholders. |
| int index | Index of the text box. |
Returns
| Type | Description |
|---|---|
| float | Bottom position. |
OH_Drawing_GetTextDirectionFromTextBox()
int OH_Drawing_GetTextDirectionFromTextBox(OH_Drawing_TextBox* textbox, int index)
Description
Obtains the text direction of a text box.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 11
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextBox* textbox | Pointer to the OH_Drawing_TextBox object, which is obtained from OH_Drawing_TypographyGetRectsForRange or OH_Drawing_TypographyGetRectsForPlaceholders. |
| int index | Index of the text box. |
Returns
| Type | Description |
|---|---|
| int | Text direction. |
OH_Drawing_GetSizeOfTextBox()
size_t OH_Drawing_GetSizeOfTextBox(OH_Drawing_TextBox* textBox)
Description
Obtains the number of text boxes.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 11
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextBox* textBox | Pointer to the OH_Drawing_TextBox object, which is obtained from OH_Drawing_TypographyGetRectsForRange or OH_Drawing_TypographyGetRectsForPlaceholders. |
Returns
| Type | Description |
|---|---|
| size_t | Number of text boxes. |
OH_Drawing_TypographyGetGlyphPositionAtCoordinate()
OH_Drawing_PositionAndAffinity* OH_Drawing_TypographyGetGlyphPositionAtCoordinate(OH_Drawing_Typography* typography,double dx, double dy)
Description
Obtains the position and affinity of the glyph at the given coordinates.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 11
Deprecated from: 18
Replaced by: OH_Drawing_TypographyGetGlyphPositionAtCoordinateWithCluster
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Typography* typography | Pointer to the OH_Drawing_Typography object, which is obtained from OH_Drawing_CreateTypography. |
| double dx | X coordinate. |
| double dy | Y coordinate. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_PositionAndAffinity* | OH_Drawing_PositionAndAffinity struct that holds the position and affinity of the glyph cluster. |
OH_Drawing_TypographyGetGlyphPositionAtCoordinateWithCluster()
OH_Drawing_PositionAndAffinity* OH_Drawing_TypographyGetGlyphPositionAtCoordinateWithCluster(OH_Drawing_Typography* typography, double dx, double dy)
Description
Obtains the position and affinity of the glyph cluster to which the glyph at the given coordinates belongs. The glyph cluster is a container that holds one or more glyphs.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 11
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Typography* typography | Pointer to the OH_Drawing_Typography object, which is obtained from OH_Drawing_CreateTypography. |
| double dx | X coordinate. |
| double dy | Y coordinate. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_PositionAndAffinity* | OH_Drawing_PositionAndAffinity struct that holds the position and affinity of the glyph cluster. |
OH_Drawing_GetPositionFromPositionAndAffinity()
size_t OH_Drawing_GetPositionFromPositionAndAffinity(OH_Drawing_PositionAndAffinity* positionAndAffinity)
Description
Obtains the position attribute of an OH_Drawing_PositionAndAffinity object.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 11
Parameters
| Name | Description |
|---|---|
| OH_Drawing_PositionAndAffinity* positionAndAffinity | Pointer to the OH_Drawing_PositionAndAffinity object, which is obtained from OH_Drawing_TypographyGetGlyphPositionAtCoordinate or OH_Drawing_TypographyGetGlyphPositionAtCoordinateWithCluster. |
Returns
| Type | Description |
|---|---|
| size_t | Position attribute. |
OH_Drawing_GetAffinityFromPositionAndAffinity()
int OH_Drawing_GetAffinityFromPositionAndAffinity(OH_Drawing_PositionAndAffinity* positionAndAffinity)
Description
Obtains the affinity attribute of an OH_Drawing_PositionAndAffinity object. The affinity determines whether the font is close to the front text or rear text.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 11
Parameters
| Name | Description |
|---|---|
| OH_Drawing_PositionAndAffinity* positionAndAffinity | Pointer to the OH_Drawing_PositionAndAffinity object, which is obtained from OH_Drawing_TypographyGetGlyphPositionAtCoordinate or OH_Drawing_TypographyGetGlyphPositionAtCoordinateWithCluster. |
Returns
| Type | Description |
|---|---|
| int | Affinity attribute. |
OH_Drawing_TypographyGetWordBoundary()
OH_Drawing_Range* OH_Drawing_TypographyGetWordBoundary(OH_Drawing_Typography* typography, size_t offset)
Description
Obtains the word boundary in a typography object.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 11
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Typography* typography | Pointer to the OH_Drawing_Typography object, which is obtained from OH_Drawing_CreateTypography. |
| size_t offset | Index of the word. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_Range* | OH_Drawing_Range struct that holds the word boundary. |
OH_Drawing_GetStartFromRange()
size_t OH_Drawing_GetStartFromRange(OH_Drawing_Range* range)
Description
Obtains the start position of an OH_Drawing_Range object.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 11
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Range* range | Pointer to the OH_Drawing_Range object, which is obtained from OH_Drawing_TypographyGetWordBoundary. |
Returns
| Type | Description |
|---|---|
| size_t | Start position. |
OH_Drawing_GetEndFromRange()
size_t OH_Drawing_GetEndFromRange(OH_Drawing_Range* range)
Description
Obtains the end position of an OH_Drawing_Range object.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 11
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Range* range | Pointer to the OH_Drawing_Range object, which is obtained from OH_Drawing_TypographyGetWordBoundary. |
Returns
| Type | Description |
|---|---|
| size_t | End position. |
OH_Drawing_TypographyGetLineCount()
size_t OH_Drawing_TypographyGetLineCount(OH_Drawing_Typography* typography)
Description
Obtains the number of lines in a typography object. This function must be called after OH_Drawing_TypographyLayout is called.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 11
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Typography* typography | Pointer to the OH_Drawing_Typography object, which is obtained from OH_Drawing_CreateTypography. |
Returns
| Type | Description |
|---|---|
| size_t | Number of rows obtained. |
OH_Drawing_SetTextStyleDecorationStyle()
void OH_Drawing_SetTextStyleDecorationStyle(OH_Drawing_TextStyle* style, int decorationStyle)
Description
Sets the decoration style for a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 11
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
| int decorationStyle | Text decoration style. For details about the available options, see OH_Drawing_TextDecorationStyle. |
OH_Drawing_SetTextStyleDecorationThicknessScale()
void OH_Drawing_SetTextStyleDecorationThicknessScale(OH_Drawing_TextStyle* style, double decorationThicknessScale)
Description
Sets the thickness scale factor for the decoration style of a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 11
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
| double decorationThicknessScale | Thickness scaling ratio. The default value is 1. If the value is less than or equal to 0, no decoration line is drawn. |
OH_Drawing_SetTextStyleLetterSpacing()
void OH_Drawing_SetTextStyleLetterSpacing(OH_Drawing_TextStyle* style, double letterSpacing)
Description
Sets the letter spacing for a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 11
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
| double letterSpacing | Letter spacing. |
OH_Drawing_SetTextStyleWordSpacing()
void OH_Drawing_SetTextStyleWordSpacing(OH_Drawing_TextStyle* style, double wordSpacing)
Description
Sets the word spacing for a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 11
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
| double wordSpacing | Letter spacing. |
OH_Drawing_SetTextStyleHalfLeading()
void OH_Drawing_SetTextStyleHalfLeading(OH_Drawing_TextStyle* style, bool halfLeading)
Description
Sets whether to enable half leading for a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 11
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
| bool halfLeading | Whether the half leading takes effect. true means yes; false otherwise. |
OH_Drawing_SetTextStyleEllipsis()
void OH_Drawing_SetTextStyleEllipsis(OH_Drawing_TextStyle* style, const char* ellipsis)
Description
Sets the ellipsis content for a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 11
Deprecated from: 18
Replaced by: OH_Drawing_SetTypographyTextEllipsis
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
| const char* ellipsis | Pointer to the ellipsis content. The data type is a pointer pointing to char. |
OH_Drawing_SetTextStyleEllipsisModal()
void OH_Drawing_SetTextStyleEllipsisModal(OH_Drawing_TextStyle* style, int ellipsisModal)
Description
Sets the ellipsis style for a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 11
Deprecated from: 18
Replaced by: OH_Drawing_SetTypographyTextEllipsisModal
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
| int ellipsisModal | Ellipsis style. For details about the available options, see OH_Drawing_EllipsisModal. |
OH_Drawing_SetTypographyTextBreakStrategy()
void OH_Drawing_SetTypographyTextBreakStrategy(OH_Drawing_TypographyStyle* style, int breakStrategy)
Description
Sets the text break strategy.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 11
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
| int breakStrategy | Break strategy. For details about the available options, see OH_Drawing_BreakStrategy. |
OH_Drawing_SetTypographyTextWordBreakType()
void OH_Drawing_SetTypographyTextWordBreakType(OH_Drawing_TypographyStyle* style, int wordBreakType)
Description
Sets the word break type.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 11
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
| int wordBreakType | Word break type. For details about the available options, see OH_Drawing_WordBreakType. |
OH_Drawing_SetTypographyTextEllipsisModal()
void OH_Drawing_SetTypographyTextEllipsisModal(OH_Drawing_TypographyStyle* style, int ellipsisModal)
Description
Sets the ellipsis style for a text style.
This API supports only the ellipsis styles ELLIPSIS_MODAL_HEAD, ELLIPSIS_MODAL_MIDDLE, and ELLIPSIS_MODAL_TAIL. For details, see the OH_Drawing_EllipsisModal enumeration.
NOTE
Since API version 24, you are advised to use the OH_Drawing_SetTypographyStyleAttributeInt API to set the ellipsis style to support more ellipsis-style enumerated values.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 11
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
| int ellipsisModal | Ellipsis style. For details about the available options, see OH_Drawing_EllipsisModal. |
OH_Drawing_SetTypographyTextEllipsis()
void OH_Drawing_SetTypographyTextEllipsis(OH_Drawing_TypographyStyle* style, const char* ellipsis)
Description
Sets the ellipsis text for a typography style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
| const char* ellipsis | Ellipsis text. |
OH_Drawing_TypographyGetLineHeight()
double OH_Drawing_TypographyGetLineHeight(OH_Drawing_Typography* typography, int lineNumber)
Description
Obtains the line height in a typography object. This function must be called after OH_Drawing_TypographyLayout is called.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 11
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Typography* typography | Pointer to the OH_Drawing_Typography object, which is obtained from OH_Drawing_CreateTypography. |
| int lineNumber | Target line. |
Returns
| Type | Description |
|---|---|
| double | Obtains the height of a given line. |
OH_Drawing_TypographyGetLineWidth()
double OH_Drawing_TypographyGetLineWidth(OH_Drawing_Typography* typography, int lineNumber)
Description
Obtains the line width of a specified line. This function must be called after OH_Drawing_TypographyLayout is called.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 11
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Typography* typography | Pointer to the OH_Drawing_Typography object, which is obtained from OH_Drawing_CreateTypography. |
| int lineNumber | Target line. |
Returns
| Type | Description |
|---|---|
| double | Obtains the width of a given line. |
OH_Drawing_SetTypographyTextSplitRatio()
void OH_Drawing_SetTypographyTextSplitRatio(OH_Drawing_TypographyStyle* style, float textSplitRatio)
Description
Sets the text split ratio.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
| float textSplitRatio | Text split ratio. |
OH_Drawing_TypographyIsLineUnlimited()
bool OH_Drawing_TypographyIsLineUnlimited(OH_Drawing_TypographyStyle* style)
Description
Checks whether the maximum number of lines is limited for text.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
Returns
| Type | Description |
|---|---|
| bool | Returns true if that the maximum number of lines is limited; returns false otherwise. |
OH_Drawing_TypographyIsEllipsized()
bool OH_Drawing_TypographyIsEllipsized(OH_Drawing_TypographyStyle* style)
Description
Checks whether an ellipsis is configured for a typography style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
Returns
| Type | Description |
|---|---|
| bool | Whether ellipsis is configured for the specified typography style. true means yes; false otherwise. |
OH_Drawing_SetTypographyTextLocale()
void OH_Drawing_SetTypographyTextLocale(OH_Drawing_TypographyStyle* style, const char* locale)
Description
Sets the locale for a typography style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
| const char* locale | Pointer to the locale. For example, 'en' indicates English, 'zh-Hans' indicates Simplified Chinese, and 'zh-Hant' indicates Traditional Chinese. |
OH_Drawing_TextStyleGetFontMetrics()
bool OH_Drawing_TextStyleGetFontMetrics(OH_Drawing_Typography* typography,OH_Drawing_TextStyle* style, OH_Drawing_Font_Metrics* fontmetrics)
Description
Obtains the font metrics of a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Typography* typography | Pointer to the OH_Drawing_Typography object, which is obtained from OH_Drawing_CreateTypography. |
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
| OH_Drawing_Font_Metrics* fontmetrics | Pointer to the OH_Drawing_Font_Metrics object, which is obtained from OH_Drawing_Font_Metrics. |
Returns
| Type | Description |
|---|---|
| bool | Whether the font attributes are obtained. true means yes; false otherwise. |
OH_Drawing_SetTypographyTextStyle()
void OH_Drawing_SetTypographyTextStyle(OH_Drawing_TypographyStyle* handler, OH_Drawing_TextStyle* style)
Description
Sets a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* handler | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
OH_Drawing_CreateFontDescriptor()
OH_Drawing_FontDescriptor* OH_Drawing_CreateFontDescriptor(void)
Description
Creates an OH_Drawing_FontDescriptor object to describe the detailed information about a system font.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Returns
| Type | Description |
|---|---|
| OH_Drawing_FontDescriptor* | Pointer to the created OH_Drawing_FontDescriptor object. |
OH_Drawing_DestroyFontDescriptor()
void OH_Drawing_DestroyFontDescriptor(OH_Drawing_FontDescriptor* descriptor)
Description
Destroys an OH_Drawing_FontDescriptor object and reclaims the memory occupied by the object.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_FontDescriptor* descriptor | Pointer to the OH_Drawing_FontDescriptor object, which is obtained from OH_Drawing_CreateFontDescriptor. |
OH_Drawing_CreateFontParser()
OH_Drawing_FontParser* OH_Drawing_CreateFontParser(void)
Description
Creates an OH_Drawing_FontParser object to parse a system font.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Returns
| Type | Description |
|---|---|
| OH_Drawing_FontParser* | Pointer to the created OH_Drawing_FontParser object. |
OH_Drawing_DestroyFontParser()
void OH_Drawing_DestroyFontParser(OH_Drawing_FontParser* parser)
Description
Destroys an OH_Drawing_FontParser object and reclaims the memory occupied by the object.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_FontParser* parser | Pointer to the OH_Drawing_FontParser object, which is obtained from OH_Drawing_CreateFontParser. |
OH_Drawing_FontParserGetSystemFontList()
char** OH_Drawing_FontParserGetSystemFontList(OH_Drawing_FontParser* fontParser, size_t* num)
Description
Obtains the list of system fonts. This function can be used only on 2-in-1 devices and phones.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_FontParser* fontParser | Pointer to the OH_Drawing_FontParser object, which is obtained from OH_Drawing_CreateFontParser. |
| size_t* num | Pointer to the number of system font names. |
Returns
| Type | Description |
|---|---|
| char** | System font list. |
OH_Drawing_DestroySystemFontList()
void OH_Drawing_DestroySystemFontList(char** fontList, size_t num)
Description
Reclaims the memory occupied by the system font list.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| char** fontList | Double pointer to the list of system font names. |
| size_t num | Number of system font names. |
OH_Drawing_FontParserGetFontByName()
OH_Drawing_FontDescriptor* OH_Drawing_FontParserGetFontByName(OH_Drawing_FontParser* fontParser, const char* name)
Description
Obtains the descriptor of a system font based on the font name.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_FontParser* fontParser | Pointer to the OH_Drawing_FontParser object, which is obtained from OH_Drawing_CreateFontParser. |
| const char* name | Pointer to the system font name. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_FontDescriptor* | Font descriptor object. Release this pointer by calling OH_Drawing_DestroyFontParser when this object is no longer needed. |
OH_Drawing_TypographyGetLineMetrics()
OH_Drawing_LineMetrics* OH_Drawing_TypographyGetLineMetrics(OH_Drawing_Typography* typography)
Description
Obtains the line metrics in a typography object. This function must be called after OH_Drawing_TypographyLayout is called. Release this pointer by calling OH_Drawing_DestroyLineMetrics when this object is no longer needed.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Typography* typography | Pointer to the OH_Drawing_Typography object, which is obtained from OH_Drawing_CreateTypography. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_LineMetrics* | Pointer to the OH_Drawing_LineMetrics object. |
OH_Drawing_LineMetricsGetSize()
size_t OH_Drawing_LineMetricsGetSize(OH_Drawing_LineMetrics* lineMetrics)
Description
Obtains the number of lines.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_LineMetrics* lineMetrics | Pointer to the OH_Drawing_LineMetrics object, which is obtained from OH_Drawing_LineMetrics. |
Returns
| Type | Description |
|---|---|
| size_t | Number of lines. |
OH_Drawing_DestroyLineMetrics()
void OH_Drawing_DestroyLineMetrics(OH_Drawing_LineMetrics* lineMetrics)
Description
Destroys an OH_Drawing_LineMetrics object and reclaims the memory occupied by the object.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_LineMetrics* lineMetrics | Pointer to the OH_Drawing_LineMetrics object, which is obtained from OH_Drawing_LineMetrics. |
OH_Drawing_TypographyGetLineMetricsAt()
bool OH_Drawing_TypographyGetLineMetricsAt(OH_Drawing_Typography* typography,int lineNumber, OH_Drawing_LineMetrics* lineMetric)
Description
Obtains the metrics of the given line in a typography object. For details, see the OH_Drawing_LineMetr struct. This function must be called after OH_Drawing_TypographyLayout is called.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Typography* typography | Pointer to the OH_Drawing_Typography object, which is obtained from OH_Drawing_CreateTypography. |
| int lineNumber | Line No. |
| OH_Drawing_LineMetrics* lineMetric | Pointer to the OH_Drawing_LineMetrics object, which is obtained from OH_Drawing_LineMetrics. |
Returns
| Type | Description |
|---|---|
| bool | Whether the metrics of the given line is obtained. true means yes; false otherwise. |
OH_Drawing_TypographyGetLineInfo()
bool OH_Drawing_TypographyGetLineInfo(OH_Drawing_Typography* typography, int lineNumber, bool oneLine,bool includeWhitespace, OH_Drawing_LineMetrics* drawingLineMetrics)
Description
Obtains the metrics of a given line or the metrics of the first character in a given line in a typography object. This function must be called after OH_Drawing_TypographyLayout is called.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Typography* typography | Pointer to the OH_Drawing_Typography object, which is obtained from OH_Drawing_CreateTypography. |
| int lineNumber | Row No. |
| bool oneLine | Whether to obtain the metrics of the entire line. The value true means to obtain the metrics of the entire line, and false means to obtain the metrics of the first character in the line. |
| bool includeWhitespace | Whether the text width includes the whitespace. true means yes; false otherwise. |
| OH_Drawing_LineMetrics* drawingLineMetrics | Pointer to the OH_Drawing_LineMetrics object, which is obtained from OH_Drawing_LineMetrics. |
Returns
| Type | Description |
|---|---|
| bool | Returns true if the metrics of the given line or the metrics of the first character in the given line is obtained; returns false otherwise. |
OH_Drawing_SetTypographyTextFontWeight()
void OH_Drawing_SetTypographyTextFontWeight(OH_Drawing_TypographyStyle* style, int weight)
Description
Sets the default font weight for a typography style. Currently, only the default system font supports font weight adjustment. For other fonts, if the weight is less than semi-bold, there is no variation in stroke thickness. If the weight is greater than or equal to semi-bold, it might result in a fake bold effect.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
| int weight | Font weight. For details about the available options, see OH_Drawing_FontWeight. |
OH_Drawing_SetTypographyTextFontStyle()
void OH_Drawing_SetTypographyTextFontStyle(OH_Drawing_TypographyStyle* style, int fontStyle)
Description
Sets the default font style for a typography style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
| int fontStyle | Font style. For details about the available options, see OH_Drawing_FontStyle. |
OH_Drawing_SetTypographyTextFontFamily()
void OH_Drawing_SetTypographyTextFontFamily(OH_Drawing_TypographyStyle* style, const char* fontFamily)
Description
Sets the font family name for text.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
| const char* fontFamily | Pointer to the name of the font family. |
OH_Drawing_SetTypographyTextFontSize()
void OH_Drawing_SetTypographyTextFontSize(OH_Drawing_TypographyStyle* style, double fontSize)
Description
Sets the font size for text.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
| double fontSize | Font size, which must be greater than 0. |
OH_Drawing_SetTypographyTextFontHeight()
void OH_Drawing_SetTypographyTextFontHeight(OH_Drawing_TypographyStyle* style, double fontHeight)
Description
Sets the font height for text.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
| double fontHeight | Font height. |
OH_Drawing_SetTypographyTextHalfLeading()
void OH_Drawing_SetTypographyTextHalfLeading(OH_Drawing_TypographyStyle* style, bool halfLeading)
Description
Sets whether to enable half leading for text.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
| bool halfLeading | Whether to enable half leading. The value true means to enable half lading, and false means the opposite. |
OH_Drawing_SetTypographyTextUseLineStyle()
void OH_Drawing_SetTypographyTextUseLineStyle(OH_Drawing_TypographyStyle* style, bool useLineStyle)
Description
Sets whether to enable the text line style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
| bool useLineStyle | Whether to enable the line style. The value true means to enable the line style, and false means the opposite. |
OH_Drawing_SetTypographyTextLineStyleFontWeight()
void OH_Drawing_SetTypographyTextLineStyleFontWeight(OH_Drawing_TypographyStyle* style, int weight)
Description
Sets the text font weight of the strut style in a typography style. Currently, only the default system font supports font weight adjustment. For other fonts, if the weight is less than semi-bold, there is no variation in stroke thickness. If the weight is greater than or equal to semi-bold, it might result in a fake bold effect.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
| int weight | Font weight. For details about the available options, see OH_Drawing_FontWeight. |
OH_Drawing_SetTypographyTextLineStyleFontStyle()
void OH_Drawing_SetTypographyTextLineStyleFontStyle(OH_Drawing_TypographyStyle* style, int fontStyle)
Description
Sets the font style of the strut style in a typography style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
| int fontStyle | Font style. For details about the available options, see OH_Drawing_FontStyle. |
OH_Drawing_SetTypographyTextLineStyleFontFamilies()
void OH_Drawing_SetTypographyTextLineStyleFontFamilies(OH_Drawing_TypographyStyle* style,int fontFamiliesNumber, const char* fontFamilies[])
Description
Sets the font families for a text line style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
| int fontFamiliesNumber | Number of font families. |
| fontFamilies | Pointer to the font families. |
OH_Drawing_SetTypographyTextLineStyleFontSize()
void OH_Drawing_SetTypographyTextLineStyleFontSize(OH_Drawing_TypographyStyle* style, double lineStyleFontSize)
Description
Sets the font size for a text line style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
| double lineStyleFontSize | Font size, which must be greater than 0. |
OH_Drawing_SetTypographyTextLineStyleFontHeight()
void OH_Drawing_SetTypographyTextLineStyleFontHeight(OH_Drawing_TypographyStyle* style, double lineStyleFontHeight)
Description
Sets the font height for a text line style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
| double lineStyleFontHeight | Font height. |
OH_Drawing_SetTypographyTextLineStyleHalfLeading()
void OH_Drawing_SetTypographyTextLineStyleHalfLeading(OH_Drawing_TypographyStyle* style, bool lineStyleHalfLeading)
Description
Sets whether to enable half leading for a text line style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
| bool lineStyleHalfLeading | Whether the half leading takes effect. true means yes; false otherwise. |
OH_Drawing_SetTypographyTextLineStyleSpacingScale()
void OH_Drawing_SetTypographyTextLineStyleSpacingScale(OH_Drawing_TypographyStyle* style, double spacingScale)
Description
Sets the spacing scale factor for a text line style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
| double spacingScale | Spacing ratio. |
OH_Drawing_SetTypographyTextLineStyleOnly()
void OH_Drawing_SetTypographyTextLineStyleOnly(OH_Drawing_TypographyStyle* style, bool lineStyleOnly)
Description
Sets whether to enable the text line style only.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
| bool lineStyleOnly | Whether to enable the line style only. true means yes; false otherwise. |
OH_Drawing_CreateTextShadow()
OH_Drawing_TextShadow* OH_Drawing_CreateTextShadow(void)
Description
Creates an OH_Drawing_TextShadow object. Release this pointer by calling OH_Drawing_DestroyTextShadow when this object is no longer needed.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Returns
| Type | Description |
|---|---|
| OH_Drawing_TextShadow* | Pointer to the OH_Drawing_TextShadow object created. |
OH_Drawing_DestroyTextShadow()
void OH_Drawing_DestroyTextShadow(OH_Drawing_TextShadow* shadow)
Description
Destroys an OH_Drawing_TextShadow object and reclaims the memory occupied by the object.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextShadow* shadow | Pointer to the OH_Drawing_TextShadow object, which is obtained from OH_Drawing_CreateTextShadow. |
OH_Drawing_TextStyleGetShadows()
OH_Drawing_TextShadow* OH_Drawing_TextStyleGetShadows(OH_Drawing_TextStyle* style)
Description
Obtains a text shadow container. Release this pointer by calling OH_Drawing_DestroyTextShadows when this object is no longer needed.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_TextShadow* | Pointer to the OH_Drawing_TextShadow object. |
OH_Drawing_TextStyleGetShadowCount()
int OH_Drawing_TextStyleGetShadowCount(OH_Drawing_TextStyle* style)
Description
Obtains the size of a text shadow container.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
Returns
| Type | Description |
|---|---|
| int | Size of a text shadow container. |
OH_Drawing_TextStyleAddShadow()
void OH_Drawing_TextStyleAddShadow(OH_Drawing_TextStyle* style, const OH_Drawing_TextShadow* shadow)
Description
Adds a shadow to a text shadow container.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
| const OH_Drawing_TextShadow* shadow | Pointer to the OH_Drawing_TextShadow object, which is obtained from OH_Drawing_CreateTextShadow. |
OH_Drawing_TextStyleClearShadows()
void OH_Drawing_TextStyleClearShadows(OH_Drawing_TextStyle* style)
Description
Clears all shadows in a text shadow container.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
OH_Drawing_TextStyleGetShadowWithIndex()
OH_Drawing_TextShadow* OH_Drawing_TextStyleGetShadowWithIndex(OH_Drawing_TextStyle* style, int index)
Description
Obtains a shadow with a given index in a text shadow container.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
| int index | Index. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_TextShadow* | Pointer to the OH_Drawing_TextShadow object. |
OH_Drawing_TypographySetIndents()
void OH_Drawing_TypographySetIndents(OH_Drawing_Typography* typography, int indentsNumber, const float indents[])
Description
Sets indents for typography. If this function is not called, texts will have no indentation applied.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Typography* typography | Pointer to the OH_Drawing_Typography object, which is obtained from OH_Drawing_CreateTypography. |
| int indentsNumber | Number of indents. The value must be less than or equal to the length of the indents array to avoid display exceptions caused by access to the out-of-bounds array. |
| indents | Pointer to a floating-point array, in which each element indicates an indentation width, in px. Before calling OH_Drawing_Typography API, you need to declare and initialize the floating-point array. |
OH_Drawing_TypographyGetIndentsWithIndex()
float OH_Drawing_TypographyGetIndentsWithIndex(OH_Drawing_Typography* typography, int index)
Description
Obtains indents with a given index in a typography object. The line index starts from 0.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Typography* typography | Pointer to the OH_Drawing_Typography object, which is obtained from OH_Drawing_CreateTypography. |
| int index | Index. |
Returns
| Type | Description |
|---|---|
| float | Indents. |
OH_Drawing_TypographyGetLineTextRange()
OH_Drawing_Range* OH_Drawing_TypographyGetLineTextRange(OH_Drawing_Typography* typography,int lineNumber, bool includeSpaces)
Description
Obtains the line bounds in a typography object. This function must be called after OH_Drawing_TypographyLayout is called. This function can only be used to obtain the bounds of existing lines. That is, the line index must start from 0, and the maximum index is OH_Drawing_TypographyGetLineCount – 1.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Typography* typography | Pointer to the OH_Drawing_Typography object, which is obtained from OH_Drawing_CreateTypography. |
| int lineNumber | Row index. |
| bool includeSpaces | Whether the returned bounds contain spaces. The value true means that the bounds contain spaces, and false means the opposite. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_Range* | Pointer to the OH_Drawing_Range object. If the line index is invalid, start and end in the result value are both 0. |
OH_Drawing_DestroyTextShadows()
void OH_Drawing_DestroyTextShadows(OH_Drawing_TextShadow* shadow)
Description
Reclaims the memory occupied by the vector consisting of the OH_Drawing_TextShadow objects.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextShadow* shadow | Pointer to the OH_Drawing_TextShadow object, which is obtained from OH_Drawing_CreateTextShadow. |
OH_Drawing_GetSystemFontConfigInfo()
OH_Drawing_FontConfigInfo* OH_Drawing_GetSystemFontConfigInfo(OH_Drawing_FontConfigInfoErrorCode* errorCode)
Description
Obtains the system font configuration.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_FontConfigInfoErrorCode* errorCode | Error code. For details, see OH_Drawing_FontConfigInfoErrorCode. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_FontConfigInfo* | Pointer to the system font configuration. When it is no longer required, call OH_Drawing_DestroySystemFontConfigInfo to release the pointer to the object. |
OH_Drawing_DestroySystemFontConfigInfo()
void OH_Drawing_DestroySystemFontConfigInfo(OH_Drawing_FontConfigInfo* drawFontCfgInfo)
Description
Reclaims the memory occupied by the system font configuration.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_FontConfigInfo* drawFontCfgInfo | Pointer to the OH_Drawing_FontConfigInfo object, which is obtained from OH_Drawing_GetSystemFontConfigInfo. |
OH_Drawing_SetTextStyleFontStyleStruct()
void OH_Drawing_SetTextStyleFontStyleStruct(OH_Drawing_TextStyle* drawingTextStyle,OH_Drawing_FontStyleStruct fontStyle)
Description
Sets the font style, including the font weight, width, and slant, for a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* drawingTextStyle | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
| OH_Drawing_FontStyleStruct fontStyle | Font style, including the font weight, width, and slant. |
OH_Drawing_SetTextStyleBadgeType()
void OH_Drawing_SetTextStyleBadgeType(OH_Drawing_TextStyle* style, OH_Drawing_TextBadgeType textBadgeType)
Description
Sets whether to use superscript or subscript in text layout. If this API is not called, the feature is disabled by default.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 20
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
| OH_Drawing_TextBadgeType textBadgeType | Sets whether to use superscript or subscript in text layout. TEXT_SUPERSCRIPT indicates that superscript is enabled, and TEXT_SUBSCRIPT indicates that subscript is enabled. The default value is TEXT_BADGE_NONE, indicating that neither superscript nor subscript is enabled. |
OH_Drawing_TextStyleGetFontStyleStruct()
OH_Drawing_FontStyleStruct OH_Drawing_TextStyleGetFontStyleStruct(OH_Drawing_TextStyle* drawingTextStyle)
Description
Obtains the font style, including the font weight, width, and slant, of a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* drawingTextStyle | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_FontStyleStruct | Font style, including the font weight, width, and slant. |
OH_Drawing_SetTypographyStyleFontStyleStruct()
void OH_Drawing_SetTypographyStyleFontStyleStruct(OH_Drawing_TypographyStyle* drawingStyle,OH_Drawing_FontStyleStruct fontStyle)
Description
Sets the font style, including the font weight, width, and slant, for the default text style of a typography style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* drawingStyle | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
| OH_Drawing_FontStyleStruct fontStyle | Font style, including the font weight, width, and slant. |
OH_Drawing_TypographyStyleGetFontStyleStruct()
OH_Drawing_FontStyleStruct OH_Drawing_TypographyStyleGetFontStyleStruct(OH_Drawing_TypographyStyle* drawingStyle)
Description
Obtains the font style, including the font weight, width, and slant, of the default text style of a typography style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* drawingStyle | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_FontStyleStruct | Font style, including the font weight, width, and slant. |
OH_Drawing_TextStyleSetBackgroundRect()
void OH_Drawing_TextStyleSetBackgroundRect(OH_Drawing_TextStyle* style,const OH_Drawing_RectStyle_Info* rectStyleInfo, int styleId)
Description
Sets a background rectangle and style ID for a text style. The style ID is valid only when the background box is a rounded rectangle.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
| const OH_Drawing_RectStyle_Info* rectStyleInfo | Pointer to the OH_Drawing_RectStyle_Info object. |
| int styleId | Style ID. The style ID is valid only when the background box is a rounded rectangle. Text processing is divided into multiple segments. Each segment has its own text style. id indicates the sequence number of the background box in which the segment is drawn. If the ID of each segment in a row is 0, all segments are drawn in the same background box. If a row contains segments with IDs 0 and 1, the segment with ID 0 is drawn in a background box, and the segment with ID 1 is drawn in another background box. Other cases can be deduced in the same way. |
OH_Drawing_TypographyHandlerAddSymbol()
void OH_Drawing_TypographyHandlerAddSymbol(OH_Drawing_TypographyCreate* handler, uint32_t symbol)
Description
Adds the symbol to use in the typography creation process.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyCreate* handler | Pointer to the OH_Drawing_TypographyCreate object, which is obtained from OH_Drawing_CreateTypographyHandler. |
| uint32_t symbol | Symbol value. For details, see the Unicode value in the HarmonyOS Symbol library. |
OH_Drawing_TextStyleAddFontFeature()
void OH_Drawing_TextStyleAddFontFeature(OH_Drawing_TextStyle* style, const char* tag, int value)
Description
Adds a font feature for a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
| const char* tag | Pointer to the string identified by the keyword in the font feature key-value pair. |
| int value | Value of the font feature key-value pair. |
OH_Drawing_TextStyleAddFontVariation()
void OH_Drawing_TextStyleAddFontVariation(OH_Drawing_TextStyle* style, const char* axis, const float value)
Description
Adds a font variation. This function takes effect only when the corresponding font file (.ttf file) supports variable adjustment. Otherwise, calling this function does not take effect.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
| const char* axis | Pointer to the key in the font variation key-value pair. Currently, only 'wght' is supported, indicating the font weight. |
| const float value | Value of the font variation key-value pair. Currently, the value range of 'wght' for the default font is [0,900]. |
OH_Drawing_TextStyleGetFontFeatures()
OH_Drawing_FontFeature* OH_Drawing_TextStyleGetFontFeatures(OH_Drawing_TextStyle* style)
Description
Obtains all the contents in a font feature map container of a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_FontFeature* | Pointer to the font feature struct, which stores all the contents obtained. |
OH_Drawing_TextStyleDestroyFontFeatures()
void OH_Drawing_TextStyleDestroyFontFeatures(OH_Drawing_FontFeature* fontFeature, size_t fontFeatureSize)
Description
Reclaims the memory occupied by the struct array that holds all the font features.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_FontFeature* fontFeature | Pointer to the struct array that holds all the font features, which is obtained from OH_Drawing_TextStyleGetFontFeatures. |
| size_t fontFeatureSize | Size of the struct array that holds all the font features. |
OH_Drawing_TextStyleGetFontFeatureSize()
size_t OH_Drawing_TextStyleGetFontFeatureSize(OH_Drawing_TextStyle* style)
Description
Obtains the size of a font feature map container in a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
Returns
| Type | Description |
|---|---|
| size_t | Size of a font feature map container. |
OH_Drawing_TextStyleClearFontFeature()
void OH_Drawing_TextStyleClearFontFeature(OH_Drawing_TextStyle* style)
Description
Clears all the contents in a font feature map container of a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
OH_Drawing_TextStyleGetBaselineShift()
double OH_Drawing_TextStyleGetBaselineShift(OH_Drawing_TextStyle* style)
Description
Obtains the baseline drift of a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
Returns
| Type | Description |
|---|---|
| double | Baseline shift. |
OH_Drawing_TextStyleSetBaselineShift()
void OH_Drawing_TextStyleSetBaselineShift(OH_Drawing_TextStyle* style, double lineShift)
Description
Sets a baseline drift for a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
| double lineShift | Baseline drift of the text style. |
OH_Drawing_TypographyTextSetHeightBehavior()
void OH_Drawing_TypographyTextSetHeightBehavior(OH_Drawing_TypographyStyle* style,OH_Drawing_TextHeightBehavior heightMode)
Description
Sets a text height modifier pattern.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
| OH_Drawing_TextHeightBehavior heightMode | Text height modifier mode. The value is an enumerated value of the OH_Drawing_TextHeightBehavior type. |
OH_Drawing_TypographyTextGetHeightBehavior()
OH_Drawing_TextHeightBehavior OH_Drawing_TypographyTextGetHeightBehavior(OH_Drawing_TypographyStyle* style)
Description
Obtains the text height modifier pattern.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_TextHeightBehavior | Text height modifier mode, which is an enumerated value of the OH_Drawing_TextHeightBehavior type. |
OH_Drawing_TypographyGetLineFontMetrics()
OH_Drawing_Font_Metrics* OH_Drawing_TypographyGetLineFontMetrics(OH_Drawing_Typography* typography,size_t lineNumber, size_t* fontMetricsSize)
Description
Obtains all font metrics from a given line in a typography object. This function must be called after OH_Drawing_TypographyLayout is called. Otherwise, a null pointer is returned. Release this pointer by calling OH_Drawing_TypographyDestroyLineFontMetrics when this object is no longer needed.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Typography* typography | Pointer to the OH_Drawing_Typography object, which is obtained from OH_Drawing_CreateTypography. |
| size_t lineNumber | Line number, which is an integer. The minimum value is 1, and the maximum value depends on the number of lines parsed by the font engine after text input. If a value greater than the maximum number is passed in, an error value is returned and an error message is printed. |
| size_t* fontMetricsSize | Pointer to the size of the struct. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_Font_Metrics* | Returns all the font metrics. |
OH_Drawing_TypographyDestroyLineFontMetrics()
void OH_Drawing_TypographyDestroyLineFontMetrics(OH_Drawing_Font_Metrics* lineFontMetric)
Description
Reclaims the memory occupied by the struct array that holds all the font metrics of a given line.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Font_Metrics* lineFontMetric | Pointer to the first address of the struct array. |
OH_Drawing_TextStyleIsEqual()
bool OH_Drawing_TextStyleIsEqual(const OH_Drawing_TextStyle* style, const OH_Drawing_TextStyle* comparedStyle)
Description
Checks whether two text styles are equal. The word width property is not involved in the comparison.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| const OH_Drawing_TextStyle* style | Pointer to the first text style. |
| const OH_Drawing_TextStyle* comparedStyle | Pointer to the first text style. |
Returns
| Type | Description |
|---|---|
| bool | Whether two text style objects are equal. true if the source rectangle is equal to the destination rectangle; false otherwise. |
OH_Drawing_TextStyleIsEqualByFont()
bool OH_Drawing_TextStyleIsEqualByFont(const OH_Drawing_TextStyle* style, const OH_Drawing_TextStyle* comparedStyle)
Description
Checks whether the font style properties of two text styles are equal.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| const OH_Drawing_TextStyle* style | Pointer to the first text style. |
| const OH_Drawing_TextStyle* comparedStyle | Pointer to the first text style. |
Returns
| Type | Description |
|---|---|
| bool | Returns true if the two are equal; returns false otherwise. |
OH_Drawing_TextStyleIsAttributeMatched()
bool OH_Drawing_TextStyleIsAttributeMatched(const OH_Drawing_TextStyle* style,const OH_Drawing_TextStyle* comparedStyle, OH_Drawing_TextStyleType textStyleType)
Description
Checks whether two text styles have the same font style type.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| const OH_Drawing_TextStyle* style | Pointer to the first text style. |
| const OH_Drawing_TextStyle* comparedStyle | Pointer to the first text style. |
| OH_Drawing_TextStyleType textStyleType | Text style types as in OH_Drawing_TextStyleType. |
Returns
| Type | Description |
|---|---|
| bool | Whether two text styles have the same font style type. true means yes; false otherwise. |
OH_Drawing_TextStyleSetPlaceholder()
void OH_Drawing_TextStyleSetPlaceholder(OH_Drawing_TextStyle* style)
Description
Adds a placeholder.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
OH_Drawing_TextStyleIsPlaceholder()
bool OH_Drawing_TextStyleIsPlaceholder(OH_Drawing_TextStyle* style)
Description
Checks whether a placeholder is set for a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
Returns
| Type | Description |
|---|---|
| bool | Checks whether a placeholder is set for a text style. true means yes; false otherwise. |
OH_Drawing_TypographyStyleGetEffectiveAlignment()
OH_Drawing_TextAlign OH_Drawing_TypographyStyleGetEffectiveAlignment(OH_Drawing_TypographyStyle* style)
Description
Obtains the text alignment mode.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_TextAlign | Text alignment modes as in OH_Drawing_TextAlign. |
OH_Drawing_TypographyStyleIsHintEnabled()
bool OH_Drawing_TypographyStyleIsHintEnabled(OH_Drawing_TypographyStyle* style)
Description
Checks whether font hinting is enabled for a typography style. Font hinting is used to improve the readability and appearance of small-sized text when rendering it.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
Returns
| Type | Description |
|---|---|
| bool | Whether to enable font hinting for a typography style. true: enabled; false: disabled. |
OH_Drawing_SetTypographyStyleTextStrutStyle()
void OH_Drawing_SetTypographyStyleTextStrutStyle(OH_Drawing_TypographyStyle* style, OH_Drawing_StrutStyle* strutstyle)
Description
Sets the strut style for a typography style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
| OH_Drawing_StrutStyle* strutstyle | Pointer to the OH_Drawing_StrutStyle object, which is obtained from OH_Drawing_TypographyStyleGetStrutStyle. |
OH_Drawing_TypographyStyleGetStrutStyle()
OH_Drawing_StrutStyle* OH_Drawing_TypographyStyleGetStrutStyle(OH_Drawing_TypographyStyle* style)
Description
Obtains the strut style of a typography style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_StrutStyle* | Pointer to the OH_Drawing_StrutStyle object. |
OH_Drawing_TypographyStyleDestroyStrutStyle()
void OH_Drawing_TypographyStyleDestroyStrutStyle(OH_Drawing_StrutStyle* strutstyle)
Description
Reclaims the memory occupied by a strut style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_StrutStyle* strutstyle | Pointer to the OH_Drawing_StrutStyle object, which is obtained from OH_Drawing_TypographyStyleGetStrutStyle. |
OH_Drawing_TypographyStyleStrutStyleEquals()
bool OH_Drawing_TypographyStyleStrutStyleEquals(OH_Drawing_StrutStyle* from, OH_Drawing_StrutStyle* to)
Description
Checks whether two strut styles are equal.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_StrutStyle* from | Pointer to the first strut style. |
| OH_Drawing_StrutStyle* to | Pointer to the second strut style. |
OH_Drawing_TypographyStyleSetHintsEnabled()
void OH_Drawing_TypographyStyleSetHintsEnabled(OH_Drawing_TypographyStyle* style, bool hintsEnabled)
Description
Sets whether to enable font hinting for a typography style. Font hinting is used to improve the readability and appearance of small-sized text when rendering it.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
| bool hintsEnabled | Whether to enable font hinting. true: enabled; false: disabled. |
OH_Drawing_TypographyMarkDirty()
void OH_Drawing_TypographyMarkDirty(OH_Drawing_Typography* typography)
Description
Marks a typography object as dirty data. This function is used to initialize the typography state.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Typography* typography | Pointer to the OH_Drawing_Typography object, which is obtained from OH_Drawing_CreateTypography. |
OH_Drawing_TypographyGetUnresolvedGlyphsCount()
int32_t OH_Drawing_TypographyGetUnresolvedGlyphsCount(OH_Drawing_Typography* typography)
Description
Obtains the number of unresolved glyphs in a typography object. This function can be called only after OH_Drawing_TypographyLayout is called and applied.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Typography* typography | Pointer to the OH_Drawing_Typography object, which is obtained from OH_Drawing_CreateTypography. |
Returns
| Type | Description |
|---|---|
| int32_t | Number of unresolved glyphs. |
OH_Drawing_TypographyUpdateFontSize()
void OH_Drawing_TypographyUpdateFontSize(OH_Drawing_Typography* typography, size_t from, size_t to, float fontSize)
Description
Updates the font size in a typography object.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Typography* typography | Pointer to the OH_Drawing_Typography object, which is obtained from OH_Drawing_CreateTypography. |
| size_t from | Reserved field, which is not used. |
| size_t to | Reserved field, which is not used. |
| float fontSize | New font size. |
OH_Drawing_TypographyUpdateFontColor()
void OH_Drawing_TypographyUpdateFontColor(OH_Drawing_Typography* typography, uint32_t color)
Description
Updates the font color in a typography object. This API call also updates the decoration color if it hasn't been set yet. The updated font color takes effect after you call OH_Drawing_TypographyPaint to draw the text.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 20
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Typography* typography | Pointer to the OH_Drawing_Typography object, which is obtained from OH_Drawing_CreateTypography. |
| uint32_t color | New font color. |
OH_Drawing_TypographyUpdateDecoration()
void OH_Drawing_TypographyUpdateDecoration(OH_Drawing_Typography* typography, OH_Drawing_TextDecoration decoration)
Description
Updates the decoration type of a typography object. The updated decoration type takes effect after you call OH_Drawing_TypographyPaint to draw the text.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 20
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Typography* typography | Pointer to the OH_Drawing_Typography object, which is obtained from OH_Drawing_CreateTypography. |
| OH_Drawing_TextDecoration decoration | Updated decoration type. For details, see OH_Drawing_TextDecoration. You can set multiple text decoration types at a time via bitwise OR operations. If a decoration type that is not in the OH_Drawing_TextDecoration enumeration is set, the original decoration is retained. |
OH_Drawing_TypographyUpdateDecorationThicknessScale()
void OH_Drawing_TypographyUpdateDecorationThicknessScale(OH_Drawing_Typography* typography,double decorationThicknessScale)
Description
Updates the decoration thickness scale of a typography object. The updated decoration thickness scale takes effect after you call OH_Drawing_TypographyPaint to draw the text.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 20
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Typography* typography | Pointer to the OH_Drawing_Typography object, which is obtained from OH_Drawing_CreateTypography. |
| double decorationThicknessScale | Thickness scaling ratio of the updated text decoration line. The thickness of the decoration line increases as the ratio increases. If the value is less than or equal to 0, the decoration line will not be drawn. |
OH_Drawing_TypographyUpdateDecorationStyle()
void OH_Drawing_TypographyUpdateDecorationStyle(OH_Drawing_Typography* typography,OH_Drawing_TextDecorationStyle decorationStyle)
Description
Updates the decoration style of a typography object. The updated decoration style takes effect after you call OH_Drawing_TypographyPaint to draw the text.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 20
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Typography* typography | Pointer to the OH_Drawing_Typography object, which is obtained from OH_Drawing_CreateTypography. |
| OH_Drawing_TextDecorationStyle decorationStyle | Updated text decoration style. For details about the available options, see OH_Drawing_TextDecorationStyle. |
OH_Drawing_TypographyTextGetLineStyle()
bool OH_Drawing_TypographyTextGetLineStyle(OH_Drawing_TypographyStyle* style)
Description
Checks whether the text line style is enabled for a typography style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
Returns
| Type | Description |
|---|---|
| bool | Whether the line style is enabled. true: enabled; false: disabled. |
OH_Drawing_TypographyTextlineStyleGetFontWeight()
OH_Drawing_FontWeight OH_Drawing_TypographyTextlineStyleGetFontWeight(OH_Drawing_TypographyStyle* style)
Description
Obtains the font weight of a text line style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_FontWeight | Font weight. For details about the available options, see OH_Drawing_FontWeight. |
OH_Drawing_TypographyTextlineStyleGetFontStyle()
OH_Drawing_FontStyle OH_Drawing_TypographyTextlineStyleGetFontStyle(OH_Drawing_TypographyStyle* style)
Description
Obtains the font style of the strut style in a typography style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_FontStyle | Font style of the strut style in a typography style. 1 indicates italic, and 0 or others indicate non-italic. For details, see the OH_Drawing_FontStyle enumeration. |
OH_Drawing_TypographyTextlineStyleGetFontFamilies()
char** OH_Drawing_TypographyTextlineStyleGetFontFamilies(OH_Drawing_TypographyStyle* style, size_t* num)
Description
Obtains the font families of a text line style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
| size_t* num | Pointer to the number of font families. |
Returns
| Type | Description |
|---|---|
| char** | Font families. |
OH_Drawing_TypographyTextlineStyleDestroyFontFamilies()
void OH_Drawing_TypographyTextlineStyleDestroyFontFamilies(char** fontFamilies, size_t fontFamiliesNum)
Description
Reclaims the memory occupied by the font families.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| char** fontFamilies | Double pointer to the font families. |
| size_t fontFamiliesNum | Number of font families. |
OH_Drawing_TypographyTextlineStyleGetFontSize()
double OH_Drawing_TypographyTextlineStyleGetFontSize(OH_Drawing_TypographyStyle* style)
Description
Obtains the font size of a text line style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
Returns
| Type | Description |
|---|---|
| double | Font size. |
OH_Drawing_TypographyTextlineStyleGetHeightScale()
double OH_Drawing_TypographyTextlineStyleGetHeightScale(OH_Drawing_TypographyStyle* style)
Description
Obtains the height scale factor of a text line style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
Returns
| Type | Description |
|---|---|
| double | Height scale factor. |
OH_Drawing_TypographyTextlineStyleGetHeightOnly()
bool OH_Drawing_TypographyTextlineStyleGetHeightOnly(OH_Drawing_TypographyStyle* style)
Description
Checks whether only the font height is used for a text line style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
Returns
| Type | Description |
|---|---|
| bool | Method for calculating the height of a font block. true means that the height is calculated based on the font size; false means that the height is calculated based on the line spacing. |
OH_Drawing_TypographyTextlineStyleGetHalfLeading()
bool OH_Drawing_TypographyTextlineStyleGetHalfLeading(OH_Drawing_TypographyStyle* style)
Description
Checks whether half leading is enabled for a text line style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
Returns
| Type | Description |
|---|---|
| bool | true if half leading is enabled; returns false otherwise. |
OH_Drawing_TypographyTextlineStyleGetSpacingScale()
double OH_Drawing_TypographyTextlineStyleGetSpacingScale(OH_Drawing_TypographyStyle* style)
Description
Obtains the spacing scale factor of a text line style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
Returns
| Type | Description |
|---|---|
| double | Spacing scale factor. |
OH_Drawing_TypographyTextlineGetStyleOnly()
bool OH_Drawing_TypographyTextlineGetStyleOnly(OH_Drawing_TypographyStyle* style)
Description
Checks whether only the text line style is enabled for a typography style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
Returns
| Type | Description |
|---|---|
| bool | Whether only the text line style is enabled for a typography style. true: enabled; false: disabled. |
OH_Drawing_TypographyGetTextAlign()
OH_Drawing_TextAlign OH_Drawing_TypographyGetTextAlign(OH_Drawing_TypographyStyle* style)
Description
Obtains the text alignment mode.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_TextAlign | Alignment mode. For details about the available options, see OH_Drawing_TextAlign. |
OH_Drawing_TypographyGetTextDirection()
OH_Drawing_TextDirection OH_Drawing_TypographyGetTextDirection(OH_Drawing_TypographyStyle* style)
Description
Obtains the text direction of a typography style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_TextDirection | Text direction. 0 means right-to-left; 1 means left-to-right. For details, see OH_Drawing_TextDirection. |
OH_Drawing_TypographyGetTextMaxLines()
size_t OH_Drawing_TypographyGetTextMaxLines(OH_Drawing_TypographyStyle* style)
Description
Obtains the maximum number of lines.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
Returns
| Type | Description |
|---|---|
| size_t | Maximum number of lines. |
OH_Drawing_TypographyGetTextEllipsis()
char* OH_Drawing_TypographyGetTextEllipsis(OH_Drawing_TypographyStyle* style)
Description
Obtains the text ellipsis content of a typography style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
Returns
| Type | Description |
|---|---|
| char* | Ellipsis text. |
OH_Drawing_TypographyDestroyEllipsis()
void OH_Drawing_TypographyDestroyEllipsis(char* ellipsis)
Description
Reclaims the memory occupied by the text ellipsis names.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| char* ellipsis | Pointer to the text ellipsis names. |
OH_Drawing_TypographyStyleEquals()
bool OH_Drawing_TypographyStyleEquals(OH_Drawing_TypographyStyle* from, OH_Drawing_TypographyStyle* to)
Description
Checks whether two typography styles are the same. The text height modifier mode OH_Drawing_TextHeightBehavior is not involved in the comparison.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* from | Pointer to the first typography style. |
| OH_Drawing_TypographyStyle* to | Pointer to the second typography style. |
Returns
| Type | Description |
|---|---|
| bool | Returns true if the two are the same; returns false otherwise. |
OH_Drawing_TextStyleGetColor()
uint32_t OH_Drawing_TextStyleGetColor(OH_Drawing_TextStyle* style)
Description
Obtains the color of a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
Returns
| Type | Description |
|---|---|
| uint32_t | Text color. |
OH_Drawing_TextStyleGetDecorationStyle()
OH_Drawing_TextDecorationStyle OH_Drawing_TextStyleGetDecorationStyle(OH_Drawing_TextStyle* style)
Description
Obtains the decoration style of a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_TextDecorationStyle | Text decoration style. For details, see OH_Drawing_TextDecorationStyle. |
OH_Drawing_TextStyleGetFontWeight()
OH_Drawing_FontWeight OH_Drawing_TextStyleGetFontWeight(OH_Drawing_TextStyle* style)
Description
Obtains the font weight of a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_FontWeight | Font weight. For details, see OH_Drawing_FontWeight. |
OH_Drawing_TextStyleGetFontStyle()
OH_Drawing_FontStyle OH_Drawing_TextStyleGetFontStyle(OH_Drawing_TextStyle* style)
Description
Obtains the font style of a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_FontStyle | Font style. For details, see OH_Drawing_FontStyle. |
OH_Drawing_TextStyleGetBaseline()
OH_Drawing_TextBaseline OH_Drawing_TextStyleGetBaseline(OH_Drawing_TextStyle* style)
Description
Obtains the baseline of a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_TextBaseline | Font baseline position. For details, see OH_Drawing_TextBaseline. |
OH_Drawing_TextStyleGetFontFamilies()
char** OH_Drawing_TextStyleGetFontFamilies(OH_Drawing_TextStyle* style, size_t* num)
Description
Obtains the font families of a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
| size_t* num | Pointer to the number of font families. |
Returns
| Type | Description |
|---|---|
| char** | Font families. |
OH_Drawing_TextStyleDestroyFontFamilies()
void OH_Drawing_TextStyleDestroyFontFamilies(char** fontFamilies, size_t num)
Description
Reclaims the memory occupied by the font families, where num specifies the number of font families.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| char** fontFamilies | Double pointer to the font families. |
| size_t num | Number of font families. |
OH_Drawing_TextStyleGetFontSize()
double OH_Drawing_TextStyleGetFontSize(OH_Drawing_TextStyle* style)
Description
Obtains the font size of a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
Returns
| Type | Description |
|---|---|
| double | Font size. |
OH_Drawing_TextStyleGetLetterSpacing()
double OH_Drawing_TextStyleGetLetterSpacing(OH_Drawing_TextStyle* style)
Description
Obtains the letter spacing of a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
Returns
| Type | Description |
|---|---|
| double | Letter spacing. |
OH_Drawing_TextStyleGetWordSpacing()
double OH_Drawing_TextStyleGetWordSpacing(OH_Drawing_TextStyle* style)
Description
Obtains the word spacing of a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
Returns
| Type | Description |
|---|---|
| double | Word spacing. |
OH_Drawing_TextStyleGetFontHeight()
double OH_Drawing_TextStyleGetFontHeight(OH_Drawing_TextStyle* style)
Description
Obtains the font height of a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
Returns
| Type | Description |
|---|---|
| double | Font height of a text style. |
OH_Drawing_TextStyleGetHalfLeading()
bool OH_Drawing_TextStyleGetHalfLeading(OH_Drawing_TextStyle* style)
Description
Checks whether half leading is enabled for a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
Returns
| Type | Description |
|---|---|
| bool | Whether half leading is enabled for a text style. true means enabled; false otherwise. |
OH_Drawing_TextStyleGetLocale()
const char* OH_Drawing_TextStyleGetLocale(OH_Drawing_TextStyle* style)
Description
Obtains the locale of a text style.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
Returns
| Type | Description |
|---|---|
| const char* | Pointer to the locale in the format of language-country. For example, zh-CN indicates Chinese (China), and en-US indicates English (United States). For details, see BCP 47. |
OH_Drawing_TypographyDestroyTextBox()
void OH_Drawing_TypographyDestroyTextBox(OH_Drawing_TextBox* textBox)
Description
Releases the memory occupied by a text box.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextBox* textBox | Pointer to the OH_Drawing_TextBox object. |
OH_Drawing_SetTextShadow()
void OH_Drawing_SetTextShadow(OH_Drawing_TextShadow* shadow, uint32_t color, OH_Drawing_Point* offset,double blurRadius)
Description
Sets a text shadow.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextShadow* shadow | Pointer to the OH_Drawing_TextShadow object, which is obtained from OH_Drawing_CreateTextShadow. |
| uint32_t color | Color of the text shadow. For example, if the input parameter is 0xAABBCCDD, AA indicates opacity, BB indicates the value of the red component, CC indicates the value of the green component, and DD indicates the value of the blue component. |
| OH_Drawing_Point* offset | Pointer to the OH_Drawing_Point object, which is the offset of the text shadow relative to the text. |
| double blurRadius | Blur radius. The value is a floating point number and has no unit. The value 0.0 means that there is no blur effect. |
OH_Drawing_CreateTextTab()
OH_Drawing_TextTab* OH_Drawing_CreateTextTab(OH_Drawing_TextAlign alignment, float location)
Description
Creates a text tab object.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 18
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextAlign alignment | Alignment mode of the text following the tab character. The value 1 means right alignment, 2 means center alignment, and 0 or other values mean left alignment. |
| float location | Alignment position of the text following the tab character. The unit is px. The minimum value is 1.0. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_TextTab* | Pointer to the OH_Drawing_TextTab object created. If a null pointer is returned, the creation fails. A possible cause is that no memory is available. |
OH_Drawing_DestroyTextTab()
void OH_Drawing_DestroyTextTab(OH_Drawing_TextTab* tab)
Description
Releases the memory occupied by a text tab object.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 18
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextTab* tab | Pointer to an OH_Drawing_TextTab object. |
OH_Drawing_GetTextTabAlignment()
OH_Drawing_TextAlign OH_Drawing_GetTextTabAlignment(OH_Drawing_TextTab* tab)
Description
Obtains the alignment mode of a text tab.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 18
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextTab* tab | Pointer to an OH_Drawing_TextTab object. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_TextAlign | Alignment mode. The value 1 means right alignment, 2 means center alignment, and 0 or other values mean left alignment. |
OH_Drawing_GetTextTabLocation()
float OH_Drawing_GetTextTabLocation(OH_Drawing_TextTab* tab)
Description
Obtains the location of a text tab.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 18
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextTab* tab | Pointer to an OH_Drawing_TextTab object. |
Returns
| Type | Description |
|---|---|
| float | Position of the text tab. |
OH_Drawing_SetTypographyTextTab()
void OH_Drawing_SetTypographyTextTab(OH_Drawing_TypographyStyle* style, OH_Drawing_TextTab* tab)
Description
Sets the alignment mode and location of a text tab. When the text alignment mode or ellipsis style is set, the tab does not take effect. When the tab location is less than 1.0, the tab is replaced with a space.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 18
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object. |
| OH_Drawing_TextTab* tab | Pointer to an OH_Drawing_TextTab object. |
OH_Drawing_GetDrawingArraySize()
size_t OH_Drawing_GetDrawingArraySize(OH_Drawing_Array* drawingArray)
Description
Obtains the number of objects in the input object array OH_Drawing_Array.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 14
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Array* drawingArray | Pointer to the OH_Drawing_Array object array. |
Returns
| Type | Description |
|---|---|
| size_t | Number of objects in the array. |
OH_Drawing_SetTypographyTextTrailingSpaceOptimized()
void OH_Drawing_SetTypographyTextTrailingSpaceOptimized(OH_Drawing_TypographyStyle* style, bool trailingSpaceOptimized)
Description
Sets whether to include the trailing spaces in alignment calculations during text typography.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 20
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle | Pointer to the OH_Drawing_TypographyStyle object. |
| bool | Sets whether to include the trailing spaces in alignment calculations during text typography. true means not to include; false (default) means to include. You are advised to set this parameter to true for center-aligned text. |
OH_Drawing_TypographyHandlerAddEncodedText()
void OH_Drawing_TypographyHandlerAddEncodedText(OH_Drawing_TypographyCreate* handler, const void* text,size_t byteLength, OH_Drawing_TextEncoding textEncodingType)
Description
Adds text encoded in a specified format.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 20
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyCreate* handler | Pointer to the OH_Drawing_TypographyCreate object, which is obtained from OH_Drawing_CreateTypographyHandler. |
| const void* text | Pointer to the text content. |
| size_t byteLength | Length of the text, in bytes. |
| OH_Drawing_TextEncoding textEncodingType | Text encoding type, which is an enumerated value of OH_Drawing_TextEncoding. Only TEXT_ENCODING_UTF8, TEXT_ENCODING_UTF16, and TEXT_ENCODING_UTF32 are supported. |
OH_Drawing_SetTypographyTextAutoSpace()
void OH_Drawing_SetTypographyTextAutoSpace(OH_Drawing_TypographyStyle *style, bool enableAutoSpace)
Description
Sets whether to enable automatic spacing during text typography.
This feature is disabled by default. If enabled, automatic spacing applies between CJK (Chinese, Japanese, and Korean) and Western characters (Latin, Cyrillic, and Greek), between CJK and digits, between CJK and copyright symbols, between copyright symbols and digits, and between copyright symbols and Western characters.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 20
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle *style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
| bool enableAutoSpace | Sets whether to enable automatic spacing during text typography. true means enabled; false (default) means disabled. |
OH_Drawing_TypographyUpdateDecorationColor()
void OH_Drawing_TypographyUpdateDecorationColor(OH_Drawing_Typography* typography, uint32_t color)
Description
Updates the decoration color of a typography object.
The updated decoration color takes effect after you call OH_Drawing_TypographyPaint to draw the text.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 20
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Typography* typography | Pointer to the OH_Drawing_Typography object, which is obtained from OH_Drawing_CreateTypography. |
| uint32_t color | Updated text decoration color. |
OH_Drawing_SetTypographyVerticalAlignment()
void OH_Drawing_SetTypographyVerticalAlignment(OH_Drawing_TypographyStyle* style,OH_Drawing_TextVerticalAlignment align)
Description
Vertical alignment mode of the text.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 20
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object, which is obtained from OH_Drawing_CreateTypographyStyle. |
| OH_Drawing_TextVerticalAlignment align | Vertical alignment mode of the text. The default mode is baseline alignment. For details about other options, see OH_Drawing_TextVerticalAlignment. |
OH_Drawing_CopyTypographyStyle()
OH_Drawing_TypographyStyle* OH_Drawing_CopyTypographyStyle(OH_Drawing_TypographyStyle* style)
Description
Creates a copy of an existing paragraph style object.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 20
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to the OH_Drawing_TypographyStyle object to be copied. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_TypographyStyle* | Pointer to the copied OH_Drawing_TypographyStyle object. If a null pointer is returned, the creation fails. The possible cause is that no memory is available or style is a null pointer. Release this pointer by calling OH_Drawing_DestroyTypographyStyle when this object is no longer needed. |
OH_Drawing_CopyTextStyle()
OH_Drawing_TextStyle* OH_Drawing_CopyTextStyle(OH_Drawing_TextStyle* style)
Description
Creates a copy of an existing text style object.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 20
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object to be copied. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_TextStyle* | Pointer to the copied OH_Drawing_TextStyle object. If a null pointer is returned, the creation fails. The possible cause is that no memory is available or style is a null pointer. Release this pointer by calling OH_Drawing_DestroyTextStyle when this object is no longer needed. |
OH_Drawing_CopyTextShadow()
OH_Drawing_TextShadow* OH_Drawing_CopyTextShadow(OH_Drawing_TextShadow* shadow)
Description
Creates a copy of an existing text shadow object.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 20
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextShadow* shadow | Pointer to the OH_Drawing_TextShadow object to be copied. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_TextShadow* | Pointer to the copied OH_Drawing_TextShadow object. If a null pointer is returned, the creation fails. The possible cause is that no memory is available or shadow is a null pointer. Release this pointer by calling OH_Drawing_DestroyTextShadow when this object is no longer needed. |
OH_Drawing_SetTextStyleAttributeDouble()
OH_Drawing_ErrorCode OH_Drawing_SetTextStyleAttributeDouble(OH_Drawing_TextStyle* style, OH_Drawing_TextStyleAttributeId id, double value)
Description
Sets the text style attribute of the double type.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 21
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to an OH_Drawing_TextStyle object. |
| OH_Drawing_TextStyleAttributeId id | Text style attribute ID. |
| double value | Text style attribute value. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_ErrorCode | Returns the execution result. OH_DRAWING_SUCCESS if the operation is successful. OH_DRAWING_ERROR_INVALID_PARAMETER if style is NULL. OH_DRAWING_ERROR_ATTRIBUTE_ID_MISMATCH if the input attribute ID does not match the called function. |
OH_Drawing_GetTextStyleAttributeDouble()
OH_Drawing_ErrorCode OH_Drawing_GetTextStyleAttributeDouble(OH_Drawing_TextStyle* style, OH_Drawing_TextStyleAttributeId id, double* value)
Description
Obtains the text style attribute of the double type.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 21
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to an OH_Drawing_TextStyle object. |
| OH_Drawing_TextStyleAttributeId id | Text style attribute ID. |
| double* value | Pointer to the attribute of the double type. It is used as an output parameter. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_ErrorCode | Returns the execution result. OH_DRAWING_SUCCESS if the operation is successful. OH_DRAWING_ERROR_INVALID_PARAMETER if style is NULL. OH_DRAWING_ERROR_ATTRIBUTE_ID_MISMATCH if the input attribute ID does not match the called function. |
OH_Drawing_SetTextStyleAttributeInt()
OH_Drawing_ErrorCode OH_Drawing_SetTextStyleAttributeInt(OH_Drawing_TextStyle* style, OH_Drawing_TextStyleAttributeId id, int value)
Description
Sets the text style attribute of the int type.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 21
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to an OH_Drawing_TextStyle object. |
| OH_Drawing_TextStyleAttributeId id | Text style attribute ID. |
| int value | Attribute value to set. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_ErrorCode | Returns the execution result. OH_DRAWING_SUCCESS if the operation is successful. OH_DRAWING_ERROR_INVALID_PARAMETER if style is NULL. OH_DRAWING_ERROR_ATTRIBUTE_ID_MISMATCH if the input attribute ID does not match the called function. OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE if the input value exceeds the value range of the attribute to be set. |
OH_Drawing_GetTextStyleAttributeInt()
OH_Drawing_ErrorCode OH_Drawing_GetTextStyleAttributeInt(OH_Drawing_TextStyle* style, OH_Drawing_TextStyleAttributeId id, int* value)
Description
Obtains the text style attribute of the int type.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 21
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to an OH_Drawing_TextStyle object. |
| OH_Drawing_TextStyleAttributeId id | Text style attribute ID. |
| int* value | Pointer to the attribute of the int type. It is used as an output parameter. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_ErrorCode | Returns the execution result. OH_DRAWING_SUCCESS if the operation is successful. OH_DRAWING_ERROR_INVALID_PARAMETER if style is NULL. OH_DRAWING_ERROR_ATTRIBUTE_ID_MISMATCH if the input attribute ID does not match the called function. |
OH_Drawing_SetTypographyStyleAttributeDouble()
OH_Drawing_ErrorCode OH_Drawing_SetTypographyStyleAttributeDouble(OH_Drawing_TypographyStyle* style, OH_Drawing_TypographyStyleAttributeId id, double value)
Description
Sets the typography style attribute of the double type.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 21
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to an OH_Drawing_TypographyStyle object. |
| OH_Drawing_TypographyStyleAttributeId id | Attribute ID of the text style. |
| double value | Attribute value to set. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_ErrorCode | Returns the execution result. OH_DRAWING_SUCCESS if the operation is successful. OH_DRAWING_ERROR_INVALID_PARAMETER if style is NULL. OH_DRAWING_ERROR_ATTRIBUTE_ID_MISMATCH if the input attribute ID does not match the called function. |
OH_Drawing_GetTypographyStyleAttributeDouble()
OH_Drawing_ErrorCode OH_Drawing_GetTypographyStyleAttributeDouble(OH_Drawing_TypographyStyle* style, OH_Drawing_TypographyStyleAttributeId id, double* value)
Description
Obtains the typography style attribute of the double type.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 21
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to an OH_Drawing_TypographyStyle object. |
| OH_Drawing_TypographyStyleAttributeId id | Attribute ID of the text style. |
| double* value | Pointer to the attribute of the double type. It is used as an output parameter. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_ErrorCode | Returns the execution result. OH_DRAWING_SUCCESS if the operation is successful. OH_DRAWING_ERROR_INVALID_PARAMETER if style is NULL. OH_DRAWING_ERROR_ATTRIBUTE_ID_MISMATCH if the input attribute ID does not match the called function. |
OH_Drawing_SetTypographyStyleAttributeInt()
OH_Drawing_ErrorCode OH_Drawing_SetTypographyStyleAttributeInt(OH_Drawing_TypographyStyle* style, OH_Drawing_TypographyStyleAttributeId id, int value)
Description
Sets the typography style attribute of the int type.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 21
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to an OH_Drawing_TypographyStyle object. |
| OH_Drawing_TypographyStyleAttributeId id | Attribute ID of the text style. |
| int value | Attribute value to set. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_ErrorCode | Returns the execution result. OH_DRAWING_SUCCESS if the operation is successful. OH_DRAWING_ERROR_INVALID_PARAMETER if style is NULL. OH_DRAWING_ERROR_ATTRIBUTE_ID_MISMATCH if the input attribute ID does not match the called function. OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE if the input value exceeds the value range of the attribute to be set. |
OH_Drawing_GetTypographyStyleAttributeInt()
OH_Drawing_ErrorCode OH_Drawing_GetTypographyStyleAttributeInt(OH_Drawing_TypographyStyle* style, OH_Drawing_TypographyStyleAttributeId id, int* value)
Description
Obtains the typography style attribute of the int type.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 21
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to an OH_Drawing_TypographyStyle object. |
| OH_Drawing_TypographyStyleAttributeId id | Attribute ID of the text style. |
| int* value | Pointer to the attribute of the int type. It is used as an output parameter. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_ErrorCode | Returns the execution result. OH_DRAWING_SUCCESS if the operation is successful. OH_DRAWING_ERROR_INVALID_PARAMETER if style is NULL. OH_DRAWING_ERROR_ATTRIBUTE_ID_MISMATCH if the input attribute ID does not match the called function. |
OH_Drawing_SetTypographyStyleAttributeBool()
OH_Drawing_ErrorCode OH_Drawing_SetTypographyStyleAttributeBool(OH_Drawing_TypographyStyle* style, OH_Drawing_TypographyStyleAttributeId id, bool value)
Description
Sets the typography style attribute of the bool type.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to an OH_Drawing_TypographyStyle object. |
| OH_Drawing_TypographyStyleAttributeId id | Attribute ID of the text style. |
| bool value | Attribute value to set. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_ErrorCode | Returns the execution result. OH_DRAWING_SUCCESS if the operation is successful. OH_DRAWING_ERROR_INCORRECT_PARAMETER if style is NULL. OH_DRAWING_ERROR_ATTRIBUTE_ID_MISMATCH if the input attribute ID does not match the called function. |
OH_Drawing_GetTypographyStyleAttributeBool()
OH_Drawing_ErrorCode OH_Drawing_GetTypographyStyleAttributeBool(OH_Drawing_TypographyStyle* style, OH_Drawing_TypographyStyleAttributeId id, bool* value)
Description
Obtains the typography style attribute of the bool type.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to an OH_Drawing_TypographyStyle object. |
| OH_Drawing_TypographyStyleAttributeId id | Attribute ID of the text style. |
| bool* value | Pointer to the bool attribute. It is used as an output parameter. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_ErrorCode | Returns the execution result. OH_DRAWING_SUCCESS if the operation is successful. OH_DRAWING_ERROR_INCORRECT_PARAMETER if style or value is NULL. OH_DRAWING_ERROR_ATTRIBUTE_ID_MISMATCH if the input attribute ID does not match the called function. |
OH_Drawing_SetTypographyStyleAttributeDoubleArray()
OH_Drawing_ErrorCode OH_Drawing_SetTypographyStyleAttributeDoubleArray(OH_Drawing_TypographyStyle* style, OH_Drawing_TypographyStyleAttributeId id, double* arrayValue, size_t arrayLength)
Description
Sets the typography style attribute of the floating-point array type.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 26.0.0
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TypographyStyle* style | Pointer to an OH_Drawing_TypographyStyle object. |
| OH_Drawing_TypographyStyleAttributeId id | Attribute ID of the text style. |
| double* arrayValue | Pointer to the floating-point array. |
| size_t arrayLength | Length of the floating-point array. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_ErrorCode | Returns the execution result. OH_DRAWING_SUCCESS if the operation is successful. OH_DRAWING_ERROR_INCORRECT_PARAMETER if the parameter style or arrayValue is a null pointer or arrayLength is 0. OH_DRAWING_ERROR_ATTRIBUTE_ID_MISMATCH if the input attribute ID does not match the called function. |
OH_Drawing_GetTypographyStyleAttributeDoubleArray()
OH_Drawing_ErrorCode OH_Drawing_GetTypographyStyleAttributeDoubleArray(const OH_Drawing_TypographyStyle* style, OH_Drawing_TypographyStyleAttributeId id, double** arrayValue, size_t* arrayLength)
Description
Obtains the typography style attribute of the floating-point array type.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 26.0.0
Parameters
| Name | Description |
|---|---|
| const OH_Drawing_TypographyStyle* style | Pointer to an OH_Drawing_TypographyStyle object. |
| OH_Drawing_TypographyStyleAttributeId id | Attribute ID of the text style. |
| double** arrayValue | Pointer to the floating-point array. It is used as an output parameter. |
| size_t* arrayLength | Length of the floating-point array. It is used as an output parameter. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_ErrorCode | Returns the execution result. OH_DRAWING_SUCCESS if the operation is successful. OH_DRAWING_ERROR_INCORRECT_PARAMETER if the parameter style or arrayValue is a null pointer or arrayLength is 0. OH_DRAWING_ERROR_ATTRIBUTE_ID_MISMATCH if the input attribute ID does not match the called function. |
OH_Drawing_DestroyPositionAndAffinity()
void OH_Drawing_DestroyPositionAndAffinity(OH_Drawing_PositionAndAffinity* positionAndAffinity)
Description
Destroys an OH_Drawing_PositionAndAffinity object and reclaims the memory occupied by the object.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_Drawing_PositionAndAffinity* positionAndAffinity | Pointer to the OH_Drawing_PositionAndAffinity object. |
OH_Drawing_TypographyGetCharacterRangeForGlyphRangeWithBuffer()
OH_Drawing_Range* OH_Drawing_TypographyGetCharacterRangeForGlyphRangeWithBuffer(OH_Drawing_Typography* typography, size_t glyphRangeStart, size_t glyphRangeEnd, OH_Drawing_Range** actualGlyphRange, OH_Drawing_TextEncoding textEncodingType)
Description
Obtains the character range corresponding to the specified glyph range.
Since: 24
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Typography* typography | Pointer to the OH_Drawing_Typography object, which is obtained from OH_Drawing_CreateTypography. |
| size_t glyphRangeStart | Start position of the glyph range. |
| size_t glyphRangeEnd | End position of the glyph range. |
| OH_Drawing_Range** actualGlyphRange | Returns the actual font range, indicating the level-2 pointer to OH_Drawing_Range. It is used as an output parameter. When the requested glyph range contains only a part of a complex glyph sequence, this parameter returns the corresponding complete glyph range. For example, ligatures and combined emojis may consist of multiple atomic glyphs and must be processed as a whole. If this parameter is NULL, the actual glyph range is not returned, indicating that the caller does not care about the actual glyph range information. After use, release the object through the OH_Drawing_ReleaseRangeBuffer API. |
| OH_Drawing_TextEncoding textEncodingType | Text encoding type OH_Drawing_TextEncoding. Currently, only UTF-8 and UTF-16 encoding types are supported. For UTF-8 encoding, the returned character range indicates the byte range. For UTF-16 encoding, the returned character range indicates the UTF-16 code unit range. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_Range* | Returns the OH_Drawing_Range object pointer that indicates the character range. When the object is no longer needed, use the OH_Drawing_ReleaseRangeBuffer API to release it. |
OH_Drawing_TypographyGetCharacterPositionAtCoordinateWithBuffer()
OH_Drawing_PositionAndAffinity* OH_Drawing_TypographyGetCharacterPositionAtCoordinateWithBuffer(OH_Drawing_Typography* typography, double dx, double dy, OH_Drawing_TextEncoding textEncodingType)
Description
Obtains the character position information closest to the specified coordinates.
Since: 24
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Typography* typography | Pointer to the OH_Drawing_Typography object, which is obtained from OH_Drawing_CreateTypography. |
| double dx | Horizontal coordinate in the text layout area, in physical pixels (px). X offset relative to the top-left corner of the text layout area, with the right direction as positive. Supports floating-point values and accepts negative values, which indicate positions to the left of the text layout area. If the coordinates are beyond the text layout area, the nearest character position is returned. It can be obtained through a touch event or click event. |
| double dy | Vertical coordinate in the text layout area, in physical pixels (px). Y offset relative to the top-left corner of the text layout area, with the downward direction as positive. Supports floating-point values and accepts negative values, which indicate positions above the text layout area. If the coordinates are beyond the text layout area, the nearest character position is returned. It can be obtained through a touch event or click event. |
| OH_Drawing_TextEncoding textEncodingType | Text encoding type OH_Drawing_TextEncoding. Currently, only UTF-8 and UTF-16 encoding types are supported. For UTF-8 encoding, the returned position indicates the byte offset. For UTF-16 encoding, the returned position indicates the UTF-16 code unit offset. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_PositionAndAffinity* | Returns the character index position and affinity at the coordinate. The return type is the OH_Drawing_PositionAndAffinity structure. When the object is no longer needed, call OH_Drawing_DestroyPositionAndAffinity to release it. |
OH_Drawing_TypographyGetGlyphRangeForCharacterRangeWithBuffer()
OH_Drawing_Range* OH_Drawing_TypographyGetGlyphRangeForCharacterRangeWithBuffer(OH_Drawing_Typography* typography, size_t characterRangeStart, size_t characterRangeEnd, OH_Drawing_Range** actualCharacterRange, OH_Drawing_TextEncoding textEncodingType)
Description
Obtains the glyph range corresponding to the specified character range.
Since: 24
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Typography* typography | Pointer to the OH_Drawing_Typography object, which is obtained from OH_Drawing_CreateTypography. |
| size_t characterRangeStart | Start position of the character range. |
| size_t characterRangeEnd | End position of the character range. |
| OH_Drawing_Range** actualCharacterRange | Returns the actual character range, indicating the level-2 pointer to OH_Drawing_Range. It is used as an output parameter. When the requested character range contains only a part of the combined character sequence, this parameter returns the corresponding complete character range. For example, a combined character consisting of a base character and a diacritical mark must be processed as a whole. If this parameter is NULL, the actual character range is not returned, indicating that the caller does not care about the actual character range information. After use, release the object through the OH_Drawing_ReleaseRangeBuffer API. |
| OH_Drawing_TextEncoding textEncodingType | Text encoding type OH_Drawing_TextEncoding. Currently, only UTF-8 and UTF-16 encoding types are supported. For UTF-8 encoding, the input character range should be interpreted as a byte range. For UTF-16 encoding, the input character range should be interpreted as a UTF-16 code unit range. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_Range* | Returns the OH_Drawing_Range object pointer that indicates the font range. If the object is no longer needed, use the OH_Drawing_ReleaseRangeBuffer API to release it. |
OH_Drawing_ReleaseRangeBuffer()
void OH_Drawing_ReleaseRangeBuffer(OH_Drawing_Range* range)
Description
Releases the memory occupied by the OH_Drawing_Range object.
Since: 24
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Range* range | Pointer to the OH_Drawing_Range object. |
OH_Drawing_TypographyLayoutWithConstraintsWithBuffer()
OH_Drawing_RectSize OH_Drawing_TypographyLayoutWithConstraintsWithBuffer(OH_Drawing_Typography* typography, OH_Drawing_RectSize constraintsRect, OH_Drawing_Array** fitStrRangeArr, size_t* fitStrRangeArrayLen)
Description
Arranges the text in the constraint rectangle.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 24
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Typography* typography | Pointer to the OH_Drawing_Typography object, which is obtained from OH_Drawing_CreateTypography. |
| OH_Drawing_RectSize constraintsRect | Height and width of the constrained layout. |
| OH_Drawing_Array** fitStrRangeArr | As an output parameter, it contains the character range of the paragraph text that is actually contained. Pointer to array object OH_Drawing_Array. Releases the memory through OH_Drawing_ReleaseArrayBuffer. |
| size_t* fitStrRangeArrayLen | As an output parameter, it indicates the size of the contained string array. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_RectSize | Returns the OH_Drawing_RectSize object, indicating the actual rectangle of the paragraph text. |
OH_Drawing_GetRangeByArrayIndex()
OH_Drawing_Range* OH_Drawing_GetRangeByArrayIndex(OH_Drawing_Array* array, size_t index)
Description
Obtains the pointer to the OH_Drawing_Range object based on the array index.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 24
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Array* array | Pointer to array object OH_Drawing_Array. |
| size_t index | Index of the target OH_Drawing_Range object in the array. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_Range* | Returns the pointer to the OH_Drawing_Range object. |
OH_Drawing_ReleaseArrayBuffer()
OH_Drawing_ErrorCode OH_Drawing_ReleaseArrayBuffer(OH_Drawing_Array* array)
Description
Releases the memory occupied by the OH_Drawing_Array object.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 24
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Array* array | Pointer to array object OH_Drawing_Array. Supported array types: Array of full font names, which is obtained through OH_Drawing_GetSystemFontFullNamesByType. Array of text lines, which is obtained through OH_Drawing_TypographyGetTextLines. Array of string indexes, which is obtained through OH_Drawing_GetRunStringIndices. Array of rectangles, which is obtained through OH_Drawing_RectCreateArray. Array of font descriptors, which is obtained through OH_Drawing_GetFontFullDescriptorsFromStream or OH_Drawing_GetFontFullDescriptorsFromPath. Array of text ranges, which is obtained through OH_Drawing_TypographyLayoutWithConstraintsWithBuffer. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_ErrorCode | Returns the execution result. OH_DRAWING_SUCCESS if the operation is successful. OH_DRAWING_ERROR_INCORRECT_PARAMETER if array is a null pointer or the type is not supported. |
OH_Drawing_TextStyleAddFontVariationWithNormalization()
void OH_Drawing_TextStyleAddFontVariationWithNormalization(OH_Drawing_TextStyle* style, const char* axis, const float normalizedValue)
Description
Adds the normalized variable font attributes. This function takes effect only when the corresponding font file (.ttf file) supports variable adjustment.
Since: 24
Parameters
| Name | Description |
|---|---|
| OH_Drawing_TextStyle* style | Pointer to the OH_Drawing_TextStyle object, which is obtained from OH_Drawing_CreateTextStyle. |
| const char* axis | Pointer to the key in the font variation key-value pair. |
| const float normalizedValue | Value of the font variation key-value pair. The normalized value range is [-1,1], mapping the range from the minimum value to the maximum value configured in the font file. 0 indicates the default value configured in the font file. |
你可能感兴趣的鸿蒙文章
openharmony 鸿蒙 capi-drawing-gpu-context-h
openharmony 鸿蒙 capi-drawing-nativepixelmap-
openharmony 鸿蒙 capi-nativevsync-oh-nativevsync-expectedraterange
openharmony 鸿蒙 capi-drawing-oh-drawing-brush
openharmony 鸿蒙 capi-drawing-oh-drawing-image-info
openharmony 鸿蒙 capi-drawing-text-linetypography-h
openharmony 鸿蒙 capi-oh-nativeimage-oh-nativeimage
openharmony 鸿蒙 capi-drawing-typeface-h