diff --git a/graphic/graphic_2d/native_drawing/drawing_font.h b/graphic/graphic_2d/native_drawing/drawing_font.h index 38ea644f359e53892c949eb6f499df748d079975..a01698eb5bf4529fa02ede18d2485fa390fae163 100644 --- a/graphic/graphic_2d/native_drawing/drawing_font.h +++ b/graphic/graphic_2d/native_drawing/drawing_font.h @@ -497,6 +497,50 @@ typedef struct OH_Drawing_Font_Metrics { */ float OH_Drawing_FontGetMetrics(OH_Drawing_Font*, OH_Drawing_Font_Metrics*); +/** + * @brief Retrieves the bound for each glyph in glyphs. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Font Indicates the pointer to an OH_Drawing_Font object. + * @param glyphs Indicates the array of glyph indices to be measured. + * @param count Indicates the number of glyphs. + * @param OH_Drawing_Array Indicates the bound for each glyph returned to the caller. + * @since 13 + * @version 1.0 + */ +void OH_Drawing_FontGetBounds(const OH_Drawing_Font*, const uint16_t* glyphs, int count, OH_Drawing_Array*); + +/** + * @brief create a path object of specified Glyph. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Font Indicates the pointer to an OH_Drawing_Font object. + * @param glyph glyph index to be measured. + * @return Returns an OH_Drawing_Path object, must be release by OH_Drawing_PathDestroy + * Returns nullptr if OH_Drawing_Font is nullptr. + * @since 13 + * @version 1.0 + */ +OH_Drawing_Path* OH_Drawing_FontCreatePathForGlyph(OH_Drawing_Font*, uint16_t glyph); + +/** + * @brief Get the text outline path. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Font Indicates the pointer to an OH_Drawing_Font object. + * @param text Indicates the character storage encoded with text encoding. + * @param byteLength Indicates the text length in bytes. + * @param encoding Indicates the text encoding. + * @param x Indicates x coordinates of the text. + * @param y Indicates y coordinates of the text. + * @return Returns an OH_Drawing_Path object, must be release by OH_Drawing_PathDestroy. + * Returns nullptr if OH_Drawing_Font is nullptr. + * @since 12 + * @version 1.0 + */ +OH_Drawing_Path* OH_Drawing_FontGetTextPath(OH_Drawing_Font* cFont, const void* text, size_t byteLength, + OH_Drawing_TextEncoding encoding, float x, float y); + #ifdef __cplusplus } #endif diff --git a/graphic/graphic_2d/native_drawing/drawing_rect.h b/graphic/graphic_2d/native_drawing/drawing_rect.h index e07abff68df1f0ac2cd19ec03a9dacac6565144f..ef317d956ce81799435a55468de97ec80b2b5e2b 100644 --- a/graphic/graphic_2d/native_drawing/drawing_rect.h +++ b/graphic/graphic_2d/native_drawing/drawing_rect.h @@ -214,6 +214,51 @@ void OH_Drawing_RectCopy(OH_Drawing_Rect* src, OH_Drawing_Rect* dst); */ void OH_Drawing_RectDestroy(OH_Drawing_Rect*); +/** + * @brief Creates an OH_Drawing_Array object, used to store multiple OH_Drawing_Rect object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param size Indicates the size of the array object + * @return Returns the pointer to the OH_Drawing_Array object created + * Must be release by OH_Drawing_RectDestroyArray interface + * @since 13 + * @version 1.0 + */ +OH_Drawing_Array* OH_Drawing_RectCreateArray(size_t size); + +/** + * @brief Return the size of an OH_Drawing_Array object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Array Indicates the array object + * @return The size of the array object + * @since 13 + * @version 1.0 + */ +size_t OH_Drawing_RectGetArraySize(OH_Drawing_Array*); + +/** + * @brief return the specified OH_Drawing_Rect object from OH_Drawing_Array object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param rectArr Indicates the array object + * @param index Indicates the index of array, caller must make sure the index is valid. + * @return Returns the pointer to the OH_Drawing_Rect object. + * @since 13 + * @version 1.0 + */ +OH_Drawing_Rect* OH_Drawing_RectGetArrayElement(OH_Drawing_Array* rectArr, size_t index); + +/** + * @brief Destroys an OH_Drawing_Array object and reclaims the memory occupied by the object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Array Indicates the pointer to an OH_Drawing_Array object. + * @since 13 + * @version 1.0 + */ +void OH_Drawing_RectDestroyArray(OH_Drawing_Array*); + #ifdef __cplusplus } #endif diff --git a/graphic/graphic_2d/native_drawing/drawing_text_declaration.h b/graphic/graphic_2d/native_drawing/drawing_text_declaration.h index 9a324c807a683863d649a9e7bc6ec5139a59f919..3d49007d8eeeadf961d7c5783b59874a57ec95e9 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_declaration.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_declaration.h @@ -60,6 +60,14 @@ typedef struct OH_Drawing_FontCollection OH_Drawing_FontCollection; */ typedef struct OH_Drawing_Typography OH_Drawing_Typography; +/** + * @brief Defines an OH_Drawing_LineTypography, which is used to perform line layout. + * + * @since 13 + * @version 1.0 + */ +typedef struct OH_Drawing_LineTypography OH_Drawing_LineTypography; + /** * @brief Defines an OH_Drawing_TextStyle, which is used to manage text colors and decorations. * @@ -125,6 +133,30 @@ typedef struct OH_Drawing_FontParser OH_Drawing_FontParser; */ typedef struct OH_Drawing_TextShadow OH_Drawing_TextShadow; +/** + * @brief Defines an OH_Drawing_TextTab, which is used to to store the tab alignment type and position. + * + * @since 13 + * @version 1.0 + */ +typedef struct OH_Drawing_TextTab OH_Drawing_TextTab; + +/** + * @brief Defines an OH_Drawing_TextLine, which is used to manage text line. + * + * @since 13 + * @version 1.0 + */ +typedef struct OH_Drawing_TextLine OH_Drawing_TextLine; + +/** + * @brief Defines an OH_Drawing_Run, which is used to manage run. + * + * @since 13 + * @version 1.0 + */ +typedef struct OH_Drawing_Run OH_Drawing_Run; + #ifdef __cplusplus } #endif diff --git a/graphic/graphic_2d/native_drawing/drawing_text_typography.h b/graphic/graphic_2d/native_drawing/drawing_text_typography.h index d821c385580bc0c2fe13343d5bb52928b2a6adc0..4273b1d9fa0fd37ebfee67c47838c995a8a14cc1 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_typography.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_typography.h @@ -412,6 +412,19 @@ typedef struct OH_Drawing_FontConfigInfo { OH_Drawing_FontFallbackGroup* fallbackGroupSet; } OH_Drawing_FontConfigInfo; +/** + * @brief Type style flag. + * + * @since 13 + * @version 1.0 + */ +typedef enum { + /** Italic font */ + ITALIC = 1 << 0, + /** Bold font */ + BOLD = 1 << 1, +} OH_Drawing_FontTypeStyle; + /** * @brief Describes the font information. * @@ -420,27 +433,48 @@ typedef struct OH_Drawing_FontConfigInfo { */ typedef struct OH_Drawing_FontDescriptor { /** The file path of System font */ - char* path; + char* path = NULL; /** A name that uniquely identifies the font */ - char* postScriptName; + char* postScriptName = NULL; /** The name of System font */ - char* fullName; + char* fullName = NULL; /** The family of System font */ - char* fontFamily; + char* fontFamily = NULL; /** The subfont family of the system font */ - char* fontSubfamily; + char* fontSubfamily = NULL; /** The weight of System font */ - int weight; + int weight = 0; /** The width of System font */ - int width; + int width = 0; /** Whether the system font is tilted */ - int italic; + int italic = 0; /** Whether the system font is compact */ - bool monoSpace; + bool monoSpace = false; /** whether symbolic fonts are supported */ - bool symbolic; + bool symbolic = false; + /** Font size */ + size_t size = 0; + /** Font style flag, from OH_Drawing_FontTypeStyle */ + int typeStyle = 0; } OH_Drawing_FontDescriptor; +/** + * @brief An enumeration of system font types. + * + * @since 13 + * @version 1.0 + */ +typedef enum { + /** All font types */ + ALL = 1 << 0, + /** System generic font type */ + GENERIC = 1 << 1, + /** Stylish font type */ + STYLISH = 1 << 2, + /** Installed font types */ + INSTALLED = 1 << 3, +} OH_Drawing_SystemFontType; + /** * @brief The metrics of line. * @@ -1460,6 +1494,31 @@ OH_Drawing_FontDescriptor* OH_Drawing_CreateFontDescriptor(void); */ void OH_Drawing_DestroyFontDescriptor(OH_Drawing_FontDescriptor*); +/** + * @brief Obtain all OH_Drawing_FontDescriptor matching the specified OH_Drawing_FontDescriptor, + * where the 'path' and 'size' fields are not considered as valid matching values. If all fields are default values, + * get all OH_Drawing_FontDescriptor. If the match fails, return nullptr. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param desc The pointer to the OH_Drawing_FontDescriptor object. + * @param num Indicates the count of obtained OH_Drawing_FontDescriptor. + * @return Returns an array of OH_Drawing_FontDescriptor. + * @since 13 + * @version 1.0 + */ +OH_Drawing_FontDescriptor* OH_Drawing_MatchingFontDescriptors(OH_Drawing_FontDescriptor* desc, size_t* num); + +/** + * @brief Releases the OH_Drawing_FontDescriptor array. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param desc Pointer to OH_Drawing_FontDescriptor array. + * @param num Represents the number of members of the OH_Drawing_FontDescriptor array. + * @since 13 + * @version 1.0 + */ +void OH_Drawing_DestroyFontDescriptors(OH_Drawing_FontDescriptor* descriptors, size_t num); + /** * @brief Creates an OH_Drawing_FontParser object. * @@ -1480,6 +1539,50 @@ OH_Drawing_FontParser* OH_Drawing_CreateFontParser(void); */ void OH_Drawing_DestroyFontParser(OH_Drawing_FontParser*); +/** + * @brief Get font details according to the full name of the font. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param char* Indicates the full name of the font. + * @return Indicates the pointer to a font descriptor object OH_Drawing_FontDescriptor. + * @since 13 + * @version 1.0 + */ +OH_Drawing_FontDescriptor* OH_Drawing_GetFontDescriptorByName(const char* fullName); + +/** + * @brief Obtain the corresponding font list based on the font type. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_SystemFontType Indicates enumerates of system font type. + * @return Returns an array of full name. + * @since 13 + * @version 1.0 + */ +OH_Drawing_Array* OH_Drawing_GetSystemFontListByType(OH_Drawing_SystemFontType fontType); + +/** + * @brief Gets the full name indices by index. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Array Indicates an array of full name. + * @param size_t The index of full name. + * @return Returns a full name of the font. + * @since 13 + * @version 1.0 + */ +char* OH_Drawing_GetSystemFontListElement(OH_Drawing_Array* fullNameList, size_t index); + +/** + * @brief Releases the memory occupied by a list of system font names. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Array Indicates an array of full name. + * @since 13 + * @version 1.0 + */ +void OH_Drawing_DestroySystemFontListByType(OH_Drawing_Array* fullNameList); + /** * @brief Gets a list of system font names. * @@ -2753,6 +2856,529 @@ void OH_Drawing_TypographyDestroyTextBox(OH_Drawing_TextBox*); void OH_Drawing_SetTextShadow(OH_Drawing_TextShadow* shadow, uint32_t color, OH_Drawing_Point* offset, double blurRadius); +/** + * @brief Get DrawingArray size. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param drawingArray Indicates the pointer to the array object OH_Drawing_Array. + * @return Size of array. + * @since 13 + * @version 1.0 + */ +size_t OH_Drawing_GetDrawingArraySize(OH_Drawing_Array* drawingArray); + +/** + * @brief Get text line information. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Typography Indicates the pointer to a typography object OH_Drawing_Typography. + * @return Indicates the pointer to a text line array object OH_Drawing_Array. + * @since 13 + * @version 1.0 + */ +OH_Drawing_Array* OH_Drawing_TypographyGetTextLines(OH_Drawing_Typography* typography); + +/** + * @brief Releases the memory occupied by the text line array object OH_Drawing_Array. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param lines Indicates the pointer to the text line array object OH_Drawing_Array. + * @since 13 + * @version 1.0 + */ +void OH_Drawing_DestroyTextLines(OH_Drawing_Array* lines); + +/** + * @brief Releases the memory occupied by the text line object OH_Drawing_TextLine. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param line Indicates the pointer to the text line object OH_Drawing_TextLine. + * @since 13 + * @version 1.0 + */ +void OH_Drawing_DestroyTextLine(OH_Drawing_TextLine* line); + +/** + * @brief Get the text line object by index. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param lines Indicates the pointer to the text line array object OH_Drawing_Array. + * @param index text line object index. + * @return Indicates the pointer to a text line object OH_Drawing_TextLine. + * @since 13 + * @version 1.0 + */ +OH_Drawing_TextLine* OH_Drawing_GetTextLinesIndex(OH_Drawing_Array* lines, size_t index); + +/** + * @brief Get the count of glyphs. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param line Indicates the pointer to an OH_Drawing_TextLine object. + * @return Returns the count of glyphs. + * @since 13 + * @version 1.0 + */ +double OH_Drawing_TextLineGetGlyphCount(OH_Drawing_TextLine* line); + +/** + * @brief Get the range of text line. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param line Indicates the pointer to an OH_Drawing_TextLine object. + * @param start Indicates the pointer to text line start position. + * @param end Indicates the pointer to text line end position. + * @since 13 + * @version 1.0 + */ +void OH_Drawing_TextLineGetTextRange(OH_Drawing_TextLine* line, size_t* start, size_t* end); + +/** + * @brief Get the glyph runs array of text line. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param line Indicates the pointer to an OH_Drawing_TextLine object. + * @return Indicates the pointer to a glyph runs array object of text line OH_Drawing_Array. + * @since 13 + * @version 1.0 + */ +OH_Drawing_Array* OH_Drawing_TextLineGetGlyphRuns(OH_Drawing_TextLine* line); + +/** + * @brief Releases the memory occupied by the run array object OH_Drawing_Array. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param runs Indicates the pointer to the run array object OH_Drawing_Array. + * @since 13 + * @version 1.0 + */ +void OH_Drawing_DestroyRuns(OH_Drawing_Array* runs); + +/** + * @brief Get the run object by index. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param runs Indicates the pointer to the run array object OH_Drawing_Array. + * @param index run object index. + * @return Indicates the pointer to a run object OH_Drawing_Run. + * @since 13 + * @version 1.0 + */ +OH_Drawing_Run* OH_Drawing_GetRunsIndex(OH_Drawing_Array* runs, size_t index); + +/** + * @brief Paint the range of text line. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param line Indicates the pointer to an OH_Drawing_TextLine object. + * @param canvas Draw the text line on the canvas. + * @param x Represents the X-axis position on the canvas. + * @param y Represents the Y-axis position on the canvas. + * @return Returns the pointer to the OH_Drawing_TextLine object created. + * @since 13 + * @version 1.0 + */ +void OH_Drawing_TextLinePaint(OH_Drawing_TextLine* line, OH_Drawing_Canvas* canvas, double x, double y); + +/** + * @brief Creates a text line object that is aligned at both ends. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param line Indicates the pointer to an OH_Drawing_TextLine object. + * @param justifiedFactor The coefficients that align the two ends. + * @param justifiedWidth The width of the two ends aligned. + * @return Returns the pointer to the OH_Drawing_TextLine object created. + * @since 13 + * @version 1.0 + */ +OH_Drawing_TextLine* OH_Drawing_TextLineCreateJustifiedLine(OH_Drawing_TextLine* line, double justifiedFactor, + double justifiedWidth); + +/** + * @brief Gets the text line typographic bounds. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param line Indicates the pointer to an OH_Drawing_TextLine object. + * @param ascent Indicates the distance that the pointer points to remain above the baseline. + * @param descent Indicates the pointer to the distance that remains below the baseline. + * @param leading Indicates the pointer to the line Spacing. + * @return Returns The total width of the typesetting border. + * @since 13 + * @version 1.0 + */ +double OH_Drawing_TextLineGetTypographicBounds(OH_Drawing_TextLine* line, double* ascent, double* descent, + double* leading); + +/** + * @brief Gets the text line image bounds. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param line Indicates the pointer to an OH_Drawing_TextLine object. + * @return Returns the pointer to the OH_Drawing_Rect struct created. + * @since 13 + * @version 1.0 + */ +OH_Drawing_Rect* OH_Drawing_TextLineGetImageBounds(OH_Drawing_TextLine* line); + +/** + * @brief Gets the tail space width. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param line Indicates the pointer to an OH_Drawing_TextLine object. + * @return Returns the tail space width. + * @since 13 + * @version 1.0 + */ +double OH_Drawing_TextLineGetTrailingSpaceWidth(OH_Drawing_TextLine* line); + +/** + * @brief Gets the index of the given character position. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param line Indicates the pointer to an OH_Drawing_TextLine object. + * @param point The given character position. + * @return Returns the character offset for a given index. + * @since 13 + * @version 1.0 + */ +int32_t OH_Drawing_TextLineGetIndexForCharacterPosition(OH_Drawing_TextLine* line, OH_Drawing_Point* point); + +/** + * @brief Gets the offset of the given character index. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param line Indicates the pointer to an OH_Drawing_TextLine object. + * @param index The given character index. + * @return Returns the character offset for a given index. + * @since 13 + * @version 1.0 + */ +double OH_Drawing_TextLineGetOffsetForCharacterIndex(OH_Drawing_TextLine* line, int32_t index); + +/** + * @brief User-defined callback functions for using offsets and indexes. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param offset Character offset is traversed as an argument to the callback function. + * @param index Character index is traversed as an argument to the callback function. + * @param leadingEdge Whether the current offset is at the character front, as an argument to the callback function. + * @return The return value of the user-defined callback function. + * If false is returned, the traversal continues. + * If true is returned, the traversal stops. + * @since 13 + * @version 1.0 + */ +typedef bool (*CustomCallback)(double offset, int32_t index, bool leadingEdge); + +/** + * @brief traversal character offset and index in text lines. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param line Indicates the pointer to an OH_Drawing_TextLine object. + * @param callback User-defined callback functions, see CustomCallback. + * @since 13 + * @version 1.0 + */ +void OH_Drawing_TextLineTraversalCharacterOffsetAndIndex(OH_Drawing_TextLine* line, CustomCallback callback); + +/** + * @brief Gets the text offset based on the given alignment factor and alignment width. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param line Indicates the pointer to an OH_Drawing_TextLine object. + * @param alignmentFactor The coefficients that text needs to be aligned. + * Less than or equal to 0 is left justified, 0.5 is center justified, + * and greater than or equal to 1 is right justified. + * @param alignmentWidth The width of the text to be aligned. + * Returns 0 if it is less than the actual width of the text. + * @return Returns the offset of the aligned text. + * @since 13 + * @version 1.0 + */ +double OH_Drawing_TextLineGetAlignmentOffset(OH_Drawing_TextLine* line, double alignmentFactor, double alignmentWidth); + +/** + * @brief Gets the run glyph indices. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Run Indicates the pointer to an OH_Drawing_Run object. + * @param start the run start position. + * @param end the run end position. + * @return Run of glyph indices array. + * @since 13 + * @version 1.0 + */ +OH_Drawing_Array* OH_Drawing_GetRunStringIndices(OH_Drawing_Run* run, uint32_t start, uint32_t end); + +/** + * @brief Gets the run glyph indices by index. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Array the run glyph indices array. + * @param index Run of glyph index. + * @return Run of glyph indices element. + * @since 13 + * @version 1.0 + */ +uint32_t OH_Drawing_GetRunStringIndicesElement(OH_Drawing_Array* StringIndices, size_t index); + +/** + * @brief Releases the memory run glyph indices. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param glyphIndices glyph indices the pointer. + * @since 13 + * @version 1.0 + */ +void OH_Drawing_DestroyRunStringIndices(OH_Drawing_Array* StringIndices); + +/** + * @brief Gets the range run glyph location and length. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Run Indicates the pointer to an OH_Drawing_Run object. + * @param location The run of glyph location. + * @param length The run of glyph length. + * @since 13 + * @version 1.0 + */ +void OH_Drawing_GetRunStringRange(OH_Drawing_Run* run, uint32_t* location, uint32_t* length); + +/** + * @brief Gets the run typographic bound. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * + * @param OH_Drawing_Run Indicates the pointer to an OH_Drawing_Run object. + * @param ascent the Run ascent. + * @param descent the Run descent. + * @param leading the Run leading. + * @return run typographic width. + * @since 13 + * @version 1.0 + */ +float OH_Drawing_GetRunTypographicBounds(OH_Drawing_Run* run, float* ascent, float* descent, float* leading); + +/** + * @brief Paints text on the canvas. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * + * @param OH_Drawing_Canvas Indicates the pointer to an OH_Drawing_Canvas object. + * @param OH_Drawing_Run Indicates the pointer to an OH_Drawing_Run object. + * @param x Indicates the x coordinate. + * @param y Indicates the y coordinate. + * @since 13 + * @version 1.0 + */ +void OH_Drawing_RunPaint(OH_Drawing_Canvas*, OH_Drawing_Run* run, double x, double y); + +/** + * @brief Gets the run bounds for glyph. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * + * @param OH_Drawing_Run Indicates the pointer to an OH_Drawing_Run object. + * @return The run rect bounds. + * @since 13 + * @version 1.0 + */ +OH_Drawing_Rect* OH_Drawing_GetRunImageBounds(OH_Drawing_Run* run); + + /** + * @brief Releases the memory run rect bounds pointer. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * + * @param OH_Drawing_Rect Run rect bounds pointer. + * @since 13 + * @version 1.0 + */ +void OH_Drawing_DestroyRunImageBounds(OH_Drawing_Rect* rect); + +/** + * @brief Gets the range glyph identifier for each character. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Run Indicates the pointer to an OH_Drawing_Run object. + * @param start the run start position. + * @param end the run end position. + * @return Run of Glyphs pointer. + * @since 13 + * @version 1.0 + */ +OH_Drawing_Array* OH_Drawing_GetRunGlyphs(OH_Drawing_Run* run, uint32_t start, uint32_t end); + +/** + * @brief Gets the glyph identifier by index. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param glyphs the run of glyphs pointer. + * @param index the run of index. + * @return Run of glyphs element. + * @since 13 + * @version 1.0 + */ +uint16_t OH_Drawing_GetRunGlyphsElement(OH_Drawing_Array* glyphs, size_t index); + +/** + * @brief Releases the memory run glyphs pointer. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param glyphs run glyphs pointer. + * @since 13 + * @version 1.0 + */ +void OH_Drawing_DestroyRunGlyphs(OH_Drawing_Array* glyphs); + +/** + * @brief Gets the range glyph positions array. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Run Indicates the pointer to an OH_Drawing_Run object. + * @param start the run start position. + * @param end the run end position. + * @return Run of positions pointer array. + * @since 13 + * @version 1.0 + */ +OH_Drawing_Array* OH_Drawing_GetRunPositions(OH_Drawing_Run* run, uint32_t start, uint32_t end); + +/** + * @brief Gets the glyph positions by index. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Array the run of positions size. + * @param index the run glyph index. + * @return Run of positions pointer. + * @since 13 + * @version 1.0 + */ +OH_Drawing_Point* OH_Drawing_GetRunPositionsElement(OH_Drawing_Array* positionsArr, size_t index); + +/** + * @brief Releases the memory run pointer. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Array OH_Drawing_Point pointer array. + * @since 13 + * @version 1.0 + */ + +void OH_Drawing_DestroyRunPositions(OH_Drawing_Array* positionsArr); +/** + * @brief Gets the number of glyph. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Run Indicates the pointer to an OH_Drawing_Run object. + * @return The number of glyph. + * @since 13 + * @version 1.0 + */ +uint32_t OH_Drawing_GetRunGlyphCount(OH_Drawing_Run* run); + +/** + * @brief Creates an OH_Drawing_LineTypography object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_TypographyCreate Indicates the pointer to an OH_Drawing_TypographyCreate object. + * @return Returns the pointer to the OH_Drawing_LineTypography object created. + * @since 13 + * @version 1.0 + */ +OH_Drawing_LineTypography* OH_Drawing_CreateLineTypography(OH_Drawing_TypographyCreate* handler); + +/** + * @brief Releases the memory occupied by an OH_Drawing_LineTypography object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_LineTypography Indicates the pointer to an OH_Drawing_LineTypography object. + * @since 13 + * @version 1.0 + */ +void OH_Drawing_DestroyLineTypography(OH_Drawing_LineTypography* lineTypography); + +/** + * @brief Calculate the line breakpoint based on the width provided. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_TypographyCreate Indicates the pointer to an OH_Drawing_TypographyCreate object. + * @param startIndex Indicates the starting point for the line-break calculations. + * @param width Indicates the requested line-break width. + * @return Returns the count of the characters from startIndex that would cause the line break. + * @since 13 + * @version 1.0 + */ +size_t OH_Drawing_LineTypographyGetLineBreak(OH_Drawing_LineTypography* lineTypography, + size_t startIndex, double width); + +/** + * @brief Creates a text line object based on the text range provided. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_LineTypography Indicates the pointer to an OH_Drawing_TypographyCreate object. + * @param startIndex Indicates the starting index of the text range. + * @param count Indicates the characters count of the text range. If the value is set to 0, return nullptr. + * @return Returns the pointer to the OH_Drawing_TextLine object created. + * @since 13 + * @version 1.0 + */ +OH_Drawing_TextLine* OH_Drawing_LineTypographyCreateLine(OH_Drawing_LineTypography* lineTypography, + size_t startIndex, size_t count); + +/** + * @brief Creates an OH_Drawing_TextTab object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @return Returns the pointer to the OH_Drawing_TextTab object created. + * @since 13 + * @version 1.0 + */ +OH_Drawing_TextTab* OH_Drawing_CreateTextTab(OH_Drawing_TextAlign textAlign, float location); + +/** + * @brief Releases the memory occupied by an OH_Drawing_TextTab object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_TextTab Indicates the pointer to an OH_Drawing_TextTab object. + * @since 13 + * @version 1.0 + */ +void OH_Drawing_DestroyTextTab(OH_Drawing_TextTab*); + +/** + * @brief Gets the text alignment of the tab. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_TextTab Indicates the pointer to an OH_Drawing_TextTab object. + * @return Returns the text alignment. + * @since 13 + * @version 1.0 + */ +OH_Drawing_TextAlign OH_Drawing_TextTabGetAlignment(OH_Drawing_TextTab*); + +/** + * @brief Gets the text location of the tab. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_TextTab Indicates the pointer to an OH_Drawing_TextTab object. + * @return Returns the text location. + * @since 13 + * @version 1.0 + */ +float OH_Drawing_TextTabGetLocation(OH_Drawing_TextTab*); + +/** + * @brief Sets the text tab of OH_Drawing_TypographyStyle object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_TypographyStyle Indicates the pointer to an OH_Drawing_TypographyStyle object. + * @param OH_Drawing_TextTab Indicates the pointer to an OH_Drawing_TextTab object. + * @since 13 + * @version 1.0 + */ +void OH_Drawing_SetTypographyTextTab(OH_Drawing_TypographyStyle*, OH_Drawing_TextTab* TextTab); + #ifdef __cplusplus } #endif diff --git a/graphic/graphic_2d/native_drawing/drawing_types.h b/graphic/graphic_2d/native_drawing/drawing_types.h index edcc71cb8345836bc9647825ebc47b6d0ff63173..2056c05daa252119219ed38ac812ea9ebab72b94 100644 --- a/graphic/graphic_2d/native_drawing/drawing_types.h +++ b/graphic/graphic_2d/native_drawing/drawing_types.h @@ -167,6 +167,14 @@ typedef struct OH_Drawing_PathEffect OH_Drawing_PathEffect; */ typedef struct OH_Drawing_Rect OH_Drawing_Rect; +/** + * @brief Defines an array object, which is used to store multiple NDK object. + * + * @since 13 + * @version 1.0 + */ +typedef struct OH_Drawing_Array OH_Drawing_Array; + /** * @brief Defines a roundRect, which is used to describe the round rectangle. * diff --git a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json index f0d6835c1e41a25d9e5b1d28eff675a8e46fb7f0..33193c4874834326d1799ccd317afd375f892d2a 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -902,6 +902,14 @@ "first_introduced": "12", "name": "OH_Drawing_DestroyFontDescriptor" }, + { + "first_introduced": "13", + "name": "OH_Drawing_MatchingFontDescriptors" + }, + { + "first_introduced": "13", + "name": "OH_Drawing_DestroyFontDescriptors" + }, { "first_introduced": "12", "name": "OH_Drawing_CreateFontParser" @@ -910,6 +918,22 @@ "first_introduced": "12", "name": "OH_Drawing_DestroyFontParser" }, + { + "first_introduced": "13", + "name": "OH_Drawing_GetFontDescriptorByName" + }, + { + "first_introduced": "13", + "name": "OH_Drawing_GetSystemFontListByType" + }, + { + "first_introduced": "13", + "name": "OH_Drawing_GetSystemFontListElement" + }, + { + "first_introduced": "13", + "name": "OH_Drawing_DestroySystemFontListByType" + }, { "first_introduced": "12", "name": "OH_Drawing_FontParserGetSystemFontList" @@ -1441,5 +1465,205 @@ { "first_introduced": "12", "name":"OH_Drawing_SetTextShadow" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_FontGetBounds" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_FontCreatePathForGlyph" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_FontGetTextPath" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_RectCreateArray" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_RectGetArraySize" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_RectGetArrayElement" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_RectDestroyArray" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_GetDrawingArraySize" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_TypographyGetTextLines" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_DestroyTextLines" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_DestroyTextLine" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_GetTextLinesIndex" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_TextLineGetGlyphCount" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_TextLineGetTextRange" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_TextLineGetGlyphRuns" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_DestroyRuns" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_GetRunsIndex" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_TextLinePaint" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_TextLineCreateJustifiedLine" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_TextLineGetTypographicBounds" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_TextLineGetImageBounds" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_TextLineGetTrailingSpaceWidth" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_TextLineGetIndexForCharacterPosition" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_TextLineGetOffsetForCharacterIndex" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_TextLineTraversalCharacterOffsetAndIndex" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_TextLineGetAlignmentOffset" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_GetRunStringIndices" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_GetRunStringIndicesElement" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_DestroyRunStringIndices" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_GetRunStringRange" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_GetRunTypographicBounds" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_RunPaint" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_GetRunImageBounds" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_DestroyRunImageBounds" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_GetRunGlyphs" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_GetRunGlyphsElement" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_DestroyRunGlyphs" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_GetRunPositions" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_GetRunPositionsElement" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_DestroyRunPositions" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_GetRunGlyphCount" + }, + { + "first_introduced": "13", + "name": "OH_Drawing_CreateLineTypography" + }, + { + "first_introduced": "13", + "name": "OH_Drawing_DestroyLineTypography" + }, + { + "first_introduced": "13", + "name": "OH_Drawing_LineTypographyGetLineBreak" + }, + { + "first_introduced": "13", + "name": "OH_Drawing_LineTypographyCreateLine" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_CreateTextTab" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_DestroyTextTab" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_TextTabGetAlignment" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_TextTabGetLocation" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_SetTypographyTextTab" } ] \ No newline at end of file