add draw single character

Signed-off-by: ustc-tianyu <dutianyu4@huawei.com>
This commit is contained in:
ustc-tianyu 2024-07-04 14:48:54 +08:00
parent 97f45e6cbd
commit 8a0dbf1c0e
3 changed files with 44 additions and 0 deletions

View File

@ -406,6 +406,25 @@ void OH_Drawing_CanvasDrawArc(OH_Drawing_Canvas*, const OH_Drawing_Rect*, float
*/
void OH_Drawing_CanvasDrawRoundRect(OH_Drawing_Canvas*, const OH_Drawing_RoundRect*);
/**
* @brief Draws a single character.
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
* @param OH_Drawing_Canvas Indicates the pointer to an <b>OH_Drawing_Canvas</b> object.
* @param str Indicates the single character encoded in UTF-8.
* @param OH_Drawing_Font Indicates the pointer to an <b>OH_Drawing_Font</b> object.
* @param x Indicates the horizontal offset applied to the single character.
* @param y Indicates the vertical offset applied to the single character.
* @return Returns the error code.
* Returns {@link OH_DRAWING_SUCCESS} if the operation is successful.
* Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if any of canvas, str
* and font is nullptr or strlen(str) is 0.
* @since 12
* @version 1.0
*/
OH_Drawing_ErrorCode OH_Drawing_CanvasDrawSingleCharacter(OH_Drawing_Canvas* canvas, const char* str,
const OH_Drawing_Font* font, float x, float y);
/**
* @brief Draws a textblob.
*

View File

@ -240,6 +240,23 @@ uint32_t OH_Drawing_FontTextToGlyphs(const OH_Drawing_Font*, const void* text, u
*/
void OH_Drawing_FontGetWidths(const OH_Drawing_Font*, const uint16_t* glyphs, int count, float* widths);
/**
* @brief Measures the width of a single character.
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
* @param font Indicates the pointer to an <b>OH_Drawing_Font</b> object.
* @param str Indicates the single character encoded in UTF-8.
* @param textWidth Indicates the width of the single character.
* @return Returns the error code.
* Returns {@link OH_DRAWING_SUCCESS} if the operation is successful.
* Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if any of font, str
* and textWidth is nullptr or strlen(str) is 0.
* @since 12
* @version 1.0
*/
OH_Drawing_ErrorCode OH_Drawing_FontMeasureSingleCharacter(const OH_Drawing_Font* font, const char* str,
float* textWidth);
/**
* @brief Measures the width of text.
*

View File

@ -86,6 +86,10 @@
},
{ "name": "OH_Drawing_CanvasDrawRect" },
{ "name": "OH_Drawing_CanvasDrawRoundRect" },
{
"first_introduced": "12",
"name": "OH_Drawing_CanvasDrawSingleCharacter"
},
{ "name": "OH_Drawing_CanvasDrawTextBlob" },
{
"first_introduced": "12",
@ -222,6 +226,10 @@
"first_introduced": "12",
"name": "OH_Drawing_FontIsSubpixel"
},
{
"first_introduced": "12",
"name": "OH_Drawing_FontMeasureSingleCharacter"
},
{
"first_introduced": "12",
"name": "OH_Drawing_FontMeasureText"