diff --git a/graphic/graphic_2d/native_drawing/drawing_text_typography.h b/graphic/graphic_2d/native_drawing/drawing_text_typography.h index 6899fed889683b9e19b88d8452c1e020c41f86ce..8e4d2e9ef046b9c9a12e91dda986acd5d550e9b9 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_typography.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_typography.h @@ -353,6 +353,36 @@ typedef struct OH_Drawing_LineMetrics { OH_Drawing_Font_Metrics firstCharMetrics; } OH_Drawing_LineMetrics; +/** + * @brief Defines the fontfeature. + * + * @since 12 + * @version 1.0 + */ +typedef struct { + /** key of fontfeature */ + char* fontFeatureKey; + /** value of fontfeature */ + int fontFeatureValue; +} OH_Drawing_FontFeature; + +/** + * @brief Enumerates of heightmode of text. + * + * @since 12 + * @version 1.0 + */ +enum OH_Drawing_TextHeightBehavior { + /** both ascend of first row and last row style */ + TEXT_HEIGHT_ALL = 0x0, + /** forbidding ascend of first row style*/ + TEXT_HEIGHT_DISABLE_FIRST_ASCENT = 0x1, + /** forbidding ascend of last row style */ + TEXT_HEIGHT_DISABLE_LAST_ASCENT = 0x2, + /** neither ascend of first row nor last row style */ + TEXT_HEIGHT_DISABLE_ALL = 0x1 | 0x2, +}; + /** * @brief Creates an OH_Drawing_TypographyStyle object. * @@ -1518,7 +1548,7 @@ void OH_Drawing_SetTypographyTextLineStyleFontStyle(OH_Drawing_TypographyStyle*, * @version 1.0 */ void OH_Drawing_SetTypographyTextLineStyleFontFamilies(OH_Drawing_TypographyStyle*, int, const char* fontFamilies[]); - + /** * @brief Sets the font size of line style for text typography. * @@ -1684,6 +1714,128 @@ float OH_Drawing_TypographyGetIndentsWithIndex(OH_Drawing_Typography*, int); */ void OH_Drawing_DestroyTextShadows(OH_Drawing_TextShadow*); +/** + * @brief Set struct of background rect and styleId of text. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_TextStyle Indicates the pointer to an OH_Drawing_TextStyle object. + * @param OH_Drawing_RectStyle_Info Indicates the pointer to an OH_Drawing_RectStyle_Info object. + * @param styleId Indicates the styleId of text to set. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_TextStyleSetBackgroundRect(OH_Drawing_TextStyle*, const OH_Drawing_RectStyle_Info*, int styleId); + +/** + * @brief Add symbols in creating typography. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_TypographyCreate Indicates the pointer to an OH_Drawing_TypographyCreate object. + * @param symbol Indicates the symbol to set. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_TypographyHandlerAddSymbol(OH_Drawing_TypographyCreate*, uint32_t symbol); + +/** + * @brief Add font feature. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_TextStyle Indicates the pointer to an OH_Drawing_TextStyle object. + * @param tag Indicates the pointer to the tag to set. + * @param value Indicates the value to set. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_TextStyleAddFontFeature(OH_Drawing_TextStyle*, const char* tag, int value); + +/** + * @brief Get all font features. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_TextStyle Indicates the pointer to an OH_Drawing_TextStyle object. + * @return OH_Drawing_FontFeature Indicates the pointer to an array of structures of OH_Drawing_FontFeature. + * @since 12 + * @version 1.0 + */ +OH_Drawing_FontFeature* OH_Drawing_TextStyleGetFontFeatures(OH_Drawing_TextStyle*); + +/** + * @brief Release the memory occupied by array of structures of font features. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_FontFeature Indicates the pointer to an array of structures of OH_Drawing_FontFeature. + * @param fontFeatureSize Indicates the size of array of structures of OH_Drawing_FontFeature. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_TextStyleDestroyFontFeatures(OH_Drawing_FontFeature*, size_t fontFeatureSize); + +/** + * @brief Get size of font features. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_TextStyle Indicates the pointer to an OH_Drawing_TextStyle object. + * @return Returns the size of fontfeatures map. + * @since 12 + * @version 1.0 + */ +size_t OH_Drawing_TextStyleGetFontFeatureSize(OH_Drawing_TextStyle*); + +/** + * @brief Clear font features. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_TextStyle Indicates the pointer to an OH_Drawing_TextStyle object. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_TextStyleClearFontFeature(OH_Drawing_TextStyle*); + +/** + * @brief Set baseline shift of text. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_TextStyle Indicates the pointer to an OH_Drawing_TextStyle object. + * @param lineShift Indicates the baseline shift to set. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_TextStyleSetBaseLineShift(OH_Drawing_TextStyle*, double lineShift); + +/** + * @brief Get baseline shift of text. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_TextStyle Indicates the pointer to an OH_Drawing_TextStyle object. + * @return Returns the baseline shift. + * @since 12 + * @version 1.0 + */ +double OH_Drawing_TextStyleGetBaseLineShift(OH_Drawing_TextStyle*); + +/** + * @brief Set mode of applying the leading over and under text. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_TypographyStyle Indicates the pointer to an OH_Drawing_TypographyStyle object. + * @param heightMode Indicates the mode to set. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_TypographyTextSetHeightMode(OH_Drawing_TypographyStyle*, OH_Drawing_TextHeightBehavior heightMode); + +/** + * @brief Get mode of applying the leading over and under text. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_TypographyStyle Indicates the pointer to an OH_Drawing_TypographyStyle object. + * @return Returns the mode. + * @since 12 + * @version 1.0 + */ +OH_Drawing_TextHeightBehavior OH_Drawing_TypographyTextGetHeightMode(OH_Drawing_TypographyStyle*); + #ifdef __cplusplus } #endif diff --git a/graphic/graphic_2d/native_drawing/drawing_types.h b/graphic/graphic_2d/native_drawing/drawing_types.h index 23e50f38dc3175744df726236a0011a5715abcec..5065acfca4e88f38c318952aa1d7c5e1469f34b3 100644 --- a/graphic/graphic_2d/native_drawing/drawing_types.h +++ b/graphic/graphic_2d/native_drawing/drawing_types.h @@ -384,6 +384,25 @@ typedef struct { OH_Drawing_AlphaFormat alphaType; } OH_Drawing_Image_Info; +/** + * @brief Defines rectstyle info struct. + * + * @since 12 + * @version 1.0 + */ +typedef struct { + /** color of rectstyle */ + uint32_t color; + /** radius in left top of rectstyle */ + double leftTopRadius; + /** radius in right top of rectstyle */ + double rightTopRadius; + /** radius in right bottom of rectstyle */ + double rightBottomRadius; + /** radius in left bottom of rectstyle */ + double leftBottomRadius; +} OH_Drawing_RectStyle_Info; + /** * @brief Enumerates text encoding types. * @since 12 diff --git a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json index d8586b349e19d12808e182919e7b24210e30abde..df1867f112b2d6e191b5f373ee1e78395ce59adc 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -509,7 +509,7 @@ { "first_introduced": "12", "name": "OH_Drawing_TextStyleGetBackgroundPen" - }, + }, { "first_introduced": "12", "name": "OH_Drawing_DisableFontCollectionFallback" @@ -582,9 +582,53 @@ "first_introduced": "12", "name": "OH_Drawing_SetTypographyTextFontHeight" }, + { + "first_introduced": "12", + "name": "OH_Drawing_TextStyleSetBackgroundRect" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_TypographyHandlerAddSymbol" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_TextStyleAddFontFeature" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_TextStyleGetFontFeatures" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_TextStyleDestroyFontFeatures" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_TextStyleGetFontFeatureSize" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_TextStyleClearFontFeature" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_TextStyleGetBaseLineShift" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_TextStyleSetBaseLineShift" + }, { "first_introduced": "12", "name": "OH_Drawing_CreateSharedFontCollection" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_TypographyTextSetHeightMode" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_TypographyTextGetHeightMode" } ] \ No newline at end of file