From ab4b8f899baba7d2e1a37202a050896ae4838956 Mon Sep 17 00:00:00 2001 From: changleipeng Date: Sat, 23 Mar 2024 09:28:23 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E6=96=87=E6=9C=AC=E6=A0=B7=E5=BC=8F=E5=8D=A0?= =?UTF-8?q?=E4=BD=8D=E7=AC=A6NDK=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: changleipeng --- .../native_drawing/drawing_text_typography.h | 132 ++++++++++++++++++ .../native_drawing/libnative_drawing.ndk.json | 48 +++++++ 2 files changed, 180 insertions(+) diff --git a/graphic/graphic_2d/native_drawing/drawing_text_typography.h b/graphic/graphic_2d/native_drawing/drawing_text_typography.h index 6899fed8896..6e1772fecf2 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_typography.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_typography.h @@ -353,6 +353,33 @@ typedef struct OH_Drawing_LineMetrics { OH_Drawing_Font_Metrics firstCharMetrics; } OH_Drawing_LineMetrics; +/** + * @brief Enumerates text style type. + * + * @since 12 + * @version 1.0 + */ +typedef enum { + /** None style */ + None, + /** All attributes style */ + AllAttributes, + /** Font style */ + Font, + /** Foreground style */ + Foreground, + /** Background style */ + Background, + /** Shadow style */ + Shadow, + /** Decorations style */ + Decorations, + /** Letter spacing style */ + LetterSpacing, + /** Word spacing style */ + WordSpacing +}OH_Drawing_TextStyleType; + /** * @brief Creates an OH_Drawing_TypographyStyle object. * @@ -1684,6 +1711,111 @@ float OH_Drawing_TypographyGetIndentsWithIndex(OH_Drawing_Typography*, int); */ void OH_Drawing_DestroyTextShadows(OH_Drawing_TextShadow*); +/** + * @brief Gets whether the two TextStyle objects are equal. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param style Indicates source of comparison OH_Drawing_TextStyle object. + * @param comparedStyle Indicates comparison OH_Drawing_TextStyle object. + * @return Compare result. + * @since 12 + * @version 1.0 + */ +bool OH_Drawing_TextStyleIsEquals(const OH_Drawing_TextStyle* style, const OH_Drawing_TextStyle* comparedStyle); + +/** + * @brief Gets whether the font properties of two TextStyle objects are equal. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param style Indicates source of comparison OH_Drawing_TextStyle object. + * @param comparedStyle Indicates comparison OH_Drawing_TextStyle object. + * @return Compare result. + * @since 12 + * @version 1.0 + */ +bool OH_Drawing_TextStyleIsEqualsByFonts(const OH_Drawing_TextStyle* style, const OH_Drawing_TextStyle* comparedStyle); + +/** + * @brief Gets whether two TextStyle objects match attributes + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param textStyleType Indicates enumerates of text style type. + * @param style Indicates source of comparison OH_Drawing_TextStyle object. + * @param comparedStyle Indicates comparison OH_Drawing_TextStyle object. + * @return Match attributes result. + * @since 12 + * @version 1.0 + */ +bool OH_Drawing_TextStyleIsMatchOneAttribute(OH_Drawing_TextStyleType textStyleType, + const OH_Drawing_TextStyle* style, const OH_Drawing_TextStyle* comparedStyle); + +/** + * @brief Set placeholder of TextStyle. + * + * @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_TextStyleSetPlaceholder(OH_Drawing_TextStyle* style); + +/** + * @brief Gets placeholder. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_TextStyle Indicates the pointer to an OH_Drawing_TextStyle object. + * @return Returns placeholder. + * @since 12 + * @version 1.0 + */ +bool OH_Drawing_TextStyleIsPlaceholder(OH_Drawing_TextStyle* style); + +/** + * @brief Gets text alignment mode. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_TypographyStyle Indicates the pointer to an OH_Drawing_TypographyStyle object. + * @return Returns text alignment mode. + * @since 12 + * @version 1.0 + */ +OH_Drawing_TextAlign OH_Drawing_TypographyStyleGetEffectiveAlignment(OH_Drawing_TypographyStyle* style); + +/** + * @brief Gets whether the hinting is enabled. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_TypographyStyle Indicates the pointer to an OH_Drawing_TypographyStyle object. + * @return True, if the hinting takes effect; false if the hinting does not take effect. + * @since 12 + * @version 1.0 + */ +bool OH_Drawing_TypographyStyleIsHintingEnabled(OH_Drawing_TypographyStyle* style); + +/** + * @brief Getting all font metrics from target row. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Typography Indicates a pointer to a typesetting object. + * @param lineNumber Indicates specifies the number of rows. + * @param fontMetricsSize Indicates the return size of font metrics struct from current line. + * @return Returns all character measures for the current row. + * @since 12 + * @version 1.0 + */ +OH_Drawing_Font_Metrics* OH_Drawing_TypographyGetLineFontMetrics(OH_Drawing_Typography*, + size_t lineNumber, size_t* fontMetricsSize); + +/** + * @brief Free up all the space taken up by the lineFontMetric. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Font_Metrics Indicates the first address of the lineFontMetric gather to be destroyed. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_TypographyDestroyLineFontMetrics(OH_Drawing_Font_Metrics*); + #ifdef __cplusplus } #endif diff --git a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json index 165a808afee..2bffcb34f85 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -577,6 +577,54 @@ { "first_introduced": "12", "name": "OH_Drawing_CreateSharedFontCollection" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_TextStyleIsEquals" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_TextStyleIsEqualsByFonts" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_TextStyleIsMatchOneAttribute" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_TextStyleSetPlaceholder" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_TextStyleIsPlaceholder" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_TypographyStyleGetEffectiveAlignment" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_TypographyStyleIsHintingEnabled" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_FontStyleSetCreateTypeface" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_FontStyleSetGetStyle" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_FontStyleSetMatchStyle" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_FontStyleSetCount" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_FontStyleSetCreateEmpty" } ] \ No newline at end of file -- Gitee From 301886ecfeb07a8b2bf1496895406f037d41fddc Mon Sep 17 00:00:00 2001 From: changleipeng Date: Thu, 28 Mar 2024 07:33:59 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0drawing=5Ffont=5Fmgr.h?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: changleipeng --- .../native_drawing/drawing_font_mgr.h | 230 ++++++++++++++++++ .../native_drawing/libnative_drawing.ndk.json | 4 + 2 files changed, 234 insertions(+) create mode 100755 graphic/graphic_2d/native_drawing/drawing_font_mgr.h diff --git a/graphic/graphic_2d/native_drawing/drawing_font_mgr.h b/graphic/graphic_2d/native_drawing/drawing_font_mgr.h new file mode 100755 index 00000000000..12e9589dc29 --- /dev/null +++ b/graphic/graphic_2d/native_drawing/drawing_font_mgr.h @@ -0,0 +1,230 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef C_INCLUDE_DRAWING_FONT_MGR_H +#define C_INCLUDE_DRAWING_FONT_MGR_H + +/** + * @addtogroup Drawing + * @{ + * + * @brief Provides functions such as 2D graphics rendering, text drawing, and image display. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * + * @since 12 + * @version 1.0 + */ + +/** + * @file drawing_font_mgr.h + * + * @brief Declares functions related to the fontmgr object in the drawing module. + * + * @since 12 + * @version 1.0 + */ + +#include "drawing_types.h" +#include "drawing_text_typography.h" +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Creates an OH_Drawing_FontMgr object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @return Returns the pointer to the OH_Drawing_FontMgr object created. + * @since 12 + * @version 1.0 + */ +OH_Drawing_FontMgr* OH_Drawing_FontMgrCreate(void); + +/** + * @brief Releases the memory occupied by an OH_Drawing_FontMgr object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_FontMgr Indicates the pointer to an OH_Drawing_FontMgr object. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_FontMgrDestroy(OH_Drawing_FontMgr*); + +/** + * @brief Gets the count of font families. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_FontMgr Indicates the pointer to an OH_Drawing_FontMgr object. + * @return Returns the count of font families. + * @since 12 + * @version 1.0 + */ +int OH_Drawing_FontMgrGetFamilyCount(OH_Drawing_FontMgr*); + +/** + * @brief Gets the font family name by the index. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_FontMgr Indicates the pointer to an OH_Drawing_FontMgr object. + * @param index Indicates the index to get the font family name. + * @return Returns the font family name corresponding to the index value. + * @since 12 + * @version 1.0 + */ +char* OH_Drawing_FontMgrGetFamilyName(OH_Drawing_FontMgr*, int index); + +/** + * @brief Releases the memory occupied by font family name. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param familyName Indicates the font family name. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_FontMgrDestroyFamilyName(char* familyName); + +/** + * @brief Creates an OH_Drawing_FontStyleSet object by OH_Drawing_FontMgr object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_FontMgr Indicates the pointer to an OH_Drawing_FontMgr object. + * @param index Indicates the index used to get the font style set object from the font manager object. + * @return Returns the pointer to the OH_Drawing_FontStyleSet object created. + * @since 12 + * @version 1.0 + */ +OH_Drawing_FontStyleSet* OH_Drawing_FontMgrCreateFontStyleSet(OH_Drawing_FontMgr*, int index); + +/** + * @brief Releases the memory occupied by an OH_Drawing_FontStyleSet object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_FontStyleSet Indicates the pointer to an OH_Drawing_FontStyleSet object. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_FontMgrDestroyFontStyleSet(OH_Drawing_FontStyleSet*); + +/** + * @brief Get the pointer to an OH_Drawing_FontStyleSet object for the given font style set family name. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_FontMgr Indicates the pointer to an OH_Drawing_FontMgr object. + * @param familyName Indicates the family name of a font style set to be matched. + * @return Returns the pointer to the OH_Drawing_FontStyleSet object matched. + * @since 12 + * @version 1.0 + */ +OH_Drawing_FontStyleSet* OH_Drawing_FontMgrMatchFamily(OH_Drawing_FontMgr*, const char* familyName); + +/** + * @brief Get the pointer to an OH_Drawing_Typeface object based on the given font style and family name. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_FontMgr Indicates the pointer to an OH_Drawing_FontMgr object. + * @param familyName Indicates the family name of a font style set to be matched. + * @param OH_Drawing_FontStyleStruct Indicates the pointer to an OH_Drawing_FontStyleStruct object. + * @return Returns the pointer to the OH_Drawing_Typeface object matched. + * @since 12 + * @version 1.0 + */ +OH_Drawing_Typeface* OH_Drawing_FontMgrMatchFamilyStyle(OH_Drawing_FontMgr*, + const char* familyName, OH_Drawing_FontStyleStruct*); + +/** + * @brief Get the pointer to an OH_Drawing_Typeface object for the given character. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_FontMgr Indicates the pointer to an OH_Drawing_FontMgr object. + * @param familyName Indicates the family name of a font style set to be matched. + * @param OH_Drawing_FontStyleStruct Indicates the pointer to an OH_Drawing_FontStyleStruct object. + * @param bcp47 Indicates an array of languages which indicate the language of character. + * @param bcp47Count Indicates the array size of bcp47. + * @param character Indicates a UTF8 value to be matched. + * @return Returns the pointer to the OH_Drawing_Typeface object matched. + * @since 12 + * @version 1.0 + */ +OH_Drawing_Typeface* OH_Drawing_FontMgrMatchFamilyStyleCharacter(OH_Drawing_FontMgr*, const char* familyName, + OH_Drawing_FontStyleStruct*, const char* bcp47[], int bcp47Count, int32_t character); + +/** + * @brief Create a typeface for the given index. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_FontStyleSet Indicates the pointer to an OH_Drawing_FontStyleSet object. + * @param index Indicates the index of the typeface in this fontStyleSet. + * @return If successful, return a pointer to OH_Drawing_Typeface object; if failed, return nullptr. + * @since 12 + * @version 1.0 + */ +OH_Drawing_Typeface* OH_Drawing_FontStyleSetCreateTypeface(OH_Drawing_FontStyleSet*, int index); + + /** + * @brief Get font style for the specified typeface. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_FontStyleSet Indicates the pointer to an OH_Drawing_FontStyleSet object. + * @param index Indicates the index of the typeface in this fontStyleSet. + * @param styleName Indicates the style name returned. + * @return Return the OH_Drawing_FontStyleStruct structure. + * @since 12 + * @version 1.0 + */ +OH_Drawing_FontStyleStruct OH_Drawing_FontStyleSetGetStyle(OH_Drawing_FontStyleSet*, int32_t index, + char** styleName); + + /** + * @brief Releases the memory styleName string. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param styleName Indicates the pointer to a string type. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_FontStyleSetFreeStyleName(char** styleName); + +/** + * @brief Get the closest matching typeface. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_FontStyleSet Indicates the pointer to an OH_Drawing_FontStyleSet object. + * @param fontStyleStruct Indicates the OH_Drawing_FontStyleStruct structure. + * @return A pointer to matched OH_Drawing_Typeface. + * @since 12 + * @version 1.0 + */ +OH_Drawing_Typeface* OH_Drawing_FontStyleSetMatchStyle(OH_Drawing_FontStyleSet*, + OH_Drawing_FontStyleStruct fontStyleStruct); + +/** + * @brief Get the count of typeface. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_FontStyleSet Indicates the pointer to an OH_Drawing_FontStyleSet object. + * @return The count of typeface in this font style set. + * @since 12 + * @version 1.0 + */ +int OH_Drawing_FontStyleSetCount(OH_Drawing_FontStyleSet*); + +#ifdef __cplusplus +} +#endif +/** @} */ +#endif \ No newline at end of file diff --git a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json index a9f8f9017e3..1c47a287412 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -934,6 +934,10 @@ "first_introduced": "12", "name": "OH_Drawing_FontStyleSetGetStyle" }, + { + "first_introduced": "12", + "name": "OH_Drawing_FontStyleSetFreeStyleName" + }, { "first_introduced": "12", "name": "OH_Drawing_FontStyleSetMatchStyle" -- Gitee