diff --git a/graphic/graphic_2d/native_drawing/drawing_typeface.h b/graphic/graphic_2d/native_drawing/drawing_typeface.h
index 0208f5ff9e598d6b2ad5974ba001442e01caca72..fa3d016e98bf069bb4f1725181c220b38283bbb4 100644
--- a/graphic/graphic_2d/native_drawing/drawing_typeface.h
+++ b/graphic/graphic_2d/native_drawing/drawing_typeface.h
@@ -40,6 +40,7 @@
* @version 1.0
*/
+#include "drawing_error_code.h"
#include "drawing_types.h"
#ifdef __cplusplus
@@ -57,7 +58,7 @@ extern "C" {
OH_Drawing_Typeface* OH_Drawing_TypefaceCreateDefault(void);
/**
- * @brief Creates a OH_Drawing_Typeface object by file.
+ * @brief Creates an OH_Drawing_Typeface object by file.
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
* @param path file path.
@@ -69,7 +70,44 @@ OH_Drawing_Typeface* OH_Drawing_TypefaceCreateDefault(void);
OH_Drawing_Typeface* OH_Drawing_TypefaceCreateFromFile(const char* path, int index);
/**
- * @brief Creates a OH_Drawing_Typeface object by given a stream. If the stream is not a valid
+ * @brief Creates an OH_Drawing_Typeface object with the specified font arguments from a file.
+ * If the OH_Drawing_Typeface object does not support the variations described in fontArguments,
+ * this function creates an OH_Drawing_Typeface object without font arguments.
+ * In this case, this function provides the same capability as {@link OH_Drawing_TypefaceCreateFromFile}.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param path Indicates the file path.
+ * @param fontArguments Indicates the pointer to an OH_Drawing_FontArguments object.
+ * @return Returns the pointer to the OH_Drawing_Typeface object created.
+ * If nullptr is returned, the creation fails.
+ * The possible cause of the failure is that the available memory is empty,
+ * or either path or fontArguments is nullptr, or the path is invalid.
+ * @since 13
+ * @version 1.0
+ */
+OH_Drawing_Typeface* OH_Drawing_TypefaceCreateFromFileWithArguments(const char* path,
+ const OH_Drawing_FontArguments* fontArguments);
+
+/**
+ * @brief Creates an OH_Drawing_Typeface object with the specified font arguments from
+ * an existing OH_Drawing_Typeface object.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param current Indicates the existing OH_Drawing_Typeface object.
+ * @param fontArguments Indicates the pointer to an OH_Drawing_FontArguments object.
+ * @return Returns the pointer to the OH_Drawing_Typeface object created.
+ * If nullptr is returned, the creation fails.
+ * The possible cause of the failure is that the available memory is empty,
+ * or either current or fontArguments is nullptr,
+ * or current does not support the variations described in fontArguments.
+ * @since 13
+ * @version 1.0
+ */
+OH_Drawing_Typeface* OH_Drawing_TypefaceCreateFromCurrent(const OH_Drawing_Typeface* current,
+ const OH_Drawing_FontArguments* fontArguments);
+
+/**
+ * @brief Creates an OH_Drawing_Typeface object by given a stream. If the stream is not a valid
* font file, returns nullptr. Ownership of the stream is transferred, so the caller must not reference
* it or free it again.
*
@@ -92,6 +130,48 @@ OH_Drawing_Typeface* OH_Drawing_TypefaceCreateFromStream(OH_Drawing_MemoryStream
*/
void OH_Drawing_TypefaceDestroy(OH_Drawing_Typeface*);
+/**
+ * @brief Creates an OH_Drawing_FontArguments object.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @return Returns the pointer to the OH_Drawing_FontArguments object created.
+ * If nullptr is returned, the creation fails.
+ * The possible cause of the failure is that the available memory is empty.
+ * @since 13
+ * @version 1.0
+ */
+OH_Drawing_FontArguments* OH_Drawing_FontArgumentsCreate(void);
+
+/**
+ * @brief Adds a font variation axis for an OH_Drawing_FontArguments object.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param fontArguments Indicates the pointer to an OH_Drawing_FontArguments object.
+ * @param axis Indicates the axis tag, which must contain four ASCII characters.
+ * @param value Indicates the value of the axis field.
+ * @return Returns the error code.
+ * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful.
+ * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if either fontArguments or axis is nullptr,
+ * or the length of axis is not 4.
+ * @since 13
+ * @version 1.0
+ */
+OH_Drawing_ErrorCode OH_Drawing_FontArgumentsAddVariation(OH_Drawing_FontArguments* fontArguments,
+ const char* axis, float value);
+
+/**
+ * @brief Destroys an OH_Drawing_FontArguments object and reclaims the memory occupied by the object.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param fontArguments Indicates the pointer to an OH_Drawing_FontArguments object.
+ * @return Returns the error code.
+ * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful.
+ * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if fontArguments is nullptr.
+ * @since 13
+ * @version 1.0
+ */
+OH_Drawing_ErrorCode OH_Drawing_FontArgumentsDestroy(OH_Drawing_FontArguments* fontArguments);
+
#ifdef __cplusplus
}
#endif
diff --git a/graphic/graphic_2d/native_drawing/drawing_types.h b/graphic/graphic_2d/native_drawing/drawing_types.h
index 71697e908abfac66b7acd413391b6b4efed54990..f10b9f8bff7a223dd43f523de72d89874989de26 100644
--- a/graphic/graphic_2d/native_drawing/drawing_types.h
+++ b/graphic/graphic_2d/native_drawing/drawing_types.h
@@ -239,6 +239,14 @@ typedef struct OH_Drawing_Font OH_Drawing_Font;
*/
typedef struct OH_Drawing_MemoryStream OH_Drawing_MemoryStream;
+/**
+ * @brief Defines fontArguments, which is used to describe the arguments for a font.
+ *
+ * @since 13
+ * @version 1.0
+ */
+typedef struct OH_Drawing_FontArguments OH_Drawing_FontArguments;
+
/**
* @brief Defines a typeface, which is used to describe the typeface.
*
diff --git a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json
index 5f0503977701871b7aae307aa923489bc8de0424..c4dcab005ec3a9ec23b9107e55701a0835c0036a 100644
--- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json
+++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json
@@ -176,6 +176,18 @@
},
{ "name": "OH_Drawing_FilterSetMaskFilter" },
{ "name": "OH_Drawing_FilterDestroy" },
+ {
+ "first_introduced": "13",
+ "name": "OH_Drawing_FontArgumentsAddVariation"
+ },
+ {
+ "first_introduced": "13",
+ "name": "OH_Drawing_FontArgumentsCreate"
+ },
+ {
+ "first_introduced": "13",
+ "name": "OH_Drawing_FontArgumentsDestroy"
+ },
{ "name": "OH_Drawing_FontCreate" },
{ "name": "OH_Drawing_FontDestroy" },
{
@@ -680,7 +692,15 @@
{ "name": "OH_Drawing_MemoryStreamCreate" },
{ "name": "OH_Drawing_MemoryStreamDestroy" },
{ "name": "OH_Drawing_TypefaceCreateDefault" },
+ {
+ "first_introduced": "13",
+ "name": "OH_Drawing_TypefaceCreateFromCurrent"
+ },
{ "name": "OH_Drawing_TypefaceCreateFromFile" },
+ {
+ "first_introduced": "13",
+ "name": "OH_Drawing_TypefaceCreateFromFileWithArguments"
+ },
{ "name": "OH_Drawing_TypefaceCreateFromStream" },
{ "name": "OH_Drawing_TypefaceDestroy" },
{ "name": "OH_Drawing_CreateTypographyHandler" },