From 80a623a283278026c613b15e3e3e08c48c2510e0 Mon Sep 17 00:00:00 2001 From: changleipeng Date: Thu, 14 Mar 2024 08:22:34 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=E8=A7=A3=E6=9E=90=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: changleipeng Change-Id: I0fec9fc3b79bb43a61992ddc5576feeaf34c9f7e --- .../native_drawing/drawing_text_typography.h | 147 +++++++++++++++++- .../native_drawing/libnative_drawing.ndk.json | 8 + 2 files changed, 153 insertions(+), 2 deletions(-) diff --git a/graphic/graphic_2d/native_drawing/drawing_text_typography.h b/graphic/graphic_2d/native_drawing/drawing_text_typography.h index 6899fed88..6bd902d44 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_typography.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_typography.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-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 @@ -287,6 +287,23 @@ typedef enum { RECT_WIDTH_STYLE_MAX, } OH_Drawing_RectWidthStyle; +/** + * @brief Gets system font configuration information list result enum. + * + * @since 12 + * @version 1.0 + */ +enum OH_Drawing_FontConfigJsonInfoCode { + /** Failed to get a list of system font file paths */ + FONT_DIR_SET_ERROR = 0, + /** The system font file path list was successfully obtained */ + FONT_DIR_SET_SUC = 1, + /** The list of system font file paths and the list of generic font sets were successfully obtained */ + FONT_DIR_GENERIC_SET_SUC = 2, + /** The list of system font configuration information was successfully obtained */ + FONT_CONFIG_JSON_INFO_SUC = 3, +}; + /** * @brief Describes the font information. * @@ -353,6 +370,107 @@ typedef struct OH_Drawing_LineMetrics { OH_Drawing_Font_Metrics firstCharMetrics; } OH_Drawing_LineMetrics; +/** + * @brief Fallback font information. + * + * @since 12 + * @version 1.0 + */ +typedef struct OH_Drawing_FallbackInfo { + /** The type of language supported by the font set. The language format is bcp47 */ + char* language; + /** Font family name */ + char* familyName; +} OH_Drawing_FallbackInfo; + +/** + * @brief Fallback font group. + * + * @since 12 + * @version 1.0 + */ +typedef struct OH_Drawing_FallbackGroup { + /** + * The name of the font set corresponding to the fallback font set. If the value is null, + * all fonts can be set using the fallback font set list + */ + char* groupName; + /** Fallback font Info Size */ + size_t fallbackInfoSize; + /** A list of font sets for fallback fonts */ + OH_Drawing_FallbackInfo** fallbackInfo; +} OH_Drawing_FallbackGroup; + +/** + * @brief Font weight mapping information. + * + * @since 12 + * @version 1.0 + */ +typedef struct OH_Drawing_AdjustInfo { + /** The font's original weight value */ + int weight; + /** The font weight displayed in the application */ + int to; +} OH_Drawing_AdjustInfo; + +/** + * @brief Alias font information. + * + * @since 12 + * @version 1.0 + */ +typedef struct OH_Drawing_AliasInfo { + /** Font family name */ + char* familyName; + /** + * Font weight value. When the weight value is greater than 0, + * the font set contains only fonts with the specified weight. + * When the weight value is equal to 0, the font set contains all fonts + */ + int weight; +} OH_Drawing_AliasInfo; + +/** + * @brief General font set information supported by the system. + * + * @since 12 + * @version 1.0 + */ +typedef struct OH_Drawing_FontGenericInfo { + /** Font family name */ + char* familyName; + /** The size of alias font lists */ + size_t aliasInfoSize; + /** The size of font weight mapping information lists */ + size_t adjustInfoSize; + /** List of alias fonts */ + OH_Drawing_AliasInfo** aliasInfoSet; + /** Font weight mapping information lists */ + OH_Drawing_AdjustInfo** adjustInfoSet; +} OH_Drawing_FontGenericInfo; + +/** + * @brief System font configuration information. + * + * @since 12 + * @version 1.0 + */ +typedef struct OH_Drawing_FontConfigJsonInfo { + /** Count of system font file paths */ + size_t fontDirSize; + /** List size of generic font sets */ + size_t fontGenericInfoSize; + /** Count of fallback font set lists */ + size_t fallbackGroupSize; + /** List of system font file paths */ + char** fontDirSet; + /** List of generic font sets */ + OH_Drawing_FontGenericInfo** fontGenericInfoSet; + /** List of fallback font sets */ + OH_Drawing_FallbackGroup** fallbackGroupSet; +} OH_Drawing_FontConfigJsonInfo; + /** * @brief Creates an OH_Drawing_TypographyStyle object. * @@ -1518,7 +1636,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 +1802,31 @@ float OH_Drawing_TypographyGetIndentsWithIndex(OH_Drawing_Typography*, int); */ void OH_Drawing_DestroyTextShadows(OH_Drawing_TextShadow*); +/** + * @brief Gets system font configuration information. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_FontConfigJsonInfoCode Error code, based on the error code to + * release the memory of system font configuration information, + * For details, see the enum OH_Drawing_FontConfigJsonInfoCode. + * @return Returns a pointer to system font configuration information. + * Indicates the pointer to an OH_Drawing_CreateFontConfigJsonInfo object. + * @since 12 + * @version 1.0 + */ +OH_Drawing_FontConfigJsonInfo* OH_Drawing_CreateFontConfigJsonInfo(OH_Drawing_FontConfigJsonInfoCode*); + +/** + * @brief Releases the memory occupied by system font configuration information. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_FontConfigJsonInfo Indicates the pointer to an OH_Drawing_CreateFontConfigJsonInfo object. + * @param OH_Drawing_FontConfigJsonInfoCode Error code, based on the error code to release the memory of + * system font configuration information, For details, see the enum OH_Drawing_FontConfigJsonInfoCode. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_DestroyFontConfigJsonInfo(OH_Drawing_FontConfigJsonInfo**, OH_Drawing_FontConfigJsonInfoCode*); #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 d8586b349..4bb306c53 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -585,6 +585,14 @@ { "first_introduced": "12", "name": "OH_Drawing_CreateSharedFontCollection" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_CreateFontConfigJsonInfo" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_DestroyFontConfigJsonInfo" } ] \ No newline at end of file -- Gitee From 721b341a347a4f9127deb5b84751d70a301f8dfe Mon Sep 17 00:00:00 2001 From: changleipeng Date: Sat, 16 Mar 2024 08:17:33 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: changleipeng Change-Id: I1c919031206acbe483e4cec7fa5e86ca22b75a4f --- .../native_drawing/drawing_text_typography.h | 68 +++++++++---------- .../native_drawing/libnative_drawing.ndk.json | 4 +- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/graphic/graphic_2d/native_drawing/drawing_text_typography.h b/graphic/graphic_2d/native_drawing/drawing_text_typography.h index 6bd902d44..4ce4b4be6 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_typography.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_typography.h @@ -293,15 +293,17 @@ typedef enum { * @since 12 * @version 1.0 */ -enum OH_Drawing_FontConfigJsonInfoCode { - /** Failed to get a list of system font file paths */ - FONT_DIR_SET_ERROR = 0, - /** The system font file path list was successfully obtained */ - FONT_DIR_SET_SUC = 1, - /** The list of system font file paths and the list of generic font sets were successfully obtained */ - FONT_DIR_GENERIC_SET_SUC = 2, +enum OH_Drawing_FontConfigInfoErrorCode { /** The list of system font configuration information was successfully obtained */ - FONT_CONFIG_JSON_INFO_SUC = 3, + SUCCESS = 0, + /** Unknown error */ + ERROR_UNKNOWN = 1, + /** Parse system config file error */ + ERROR_PARSE_FILE = 2, + /** Alloc memory error */ + ERROR_ALLOC_MEMORY = 3, + /** Copy string data error */ + ERROR_COPY_STRING_DATA = 4, }; /** @@ -376,12 +378,12 @@ typedef struct OH_Drawing_LineMetrics { * @since 12 * @version 1.0 */ -typedef struct OH_Drawing_FallbackInfo { +typedef struct OH_Drawing_FontFallbackInfo { /** The type of language supported by the font set. The language format is bcp47 */ char* language; /** Font family name */ char* familyName; -} OH_Drawing_FallbackInfo; +} OH_Drawing_FontFallbackInfo; /** * @brief Fallback font group. @@ -389,17 +391,17 @@ typedef struct OH_Drawing_FallbackInfo { * @since 12 * @version 1.0 */ -typedef struct OH_Drawing_FallbackGroup { +typedef struct OH_Drawing_FontFallbackGroup { /** * The name of the font set corresponding to the fallback font set. If the value is null, - * all fonts can be set using the fallback font set list + * all fonts can be set using the fallback font set list. */ char* groupName; /** Fallback font Info Size */ size_t fallbackInfoSize; /** A list of font sets for fallback fonts */ - OH_Drawing_FallbackInfo** fallbackInfo; -} OH_Drawing_FallbackGroup; + OH_Drawing_FontFallbackInfo* fallbackInfoSet; +} OH_Drawing_FontFallbackGroup; /** * @brief Font weight mapping information. @@ -407,12 +409,12 @@ typedef struct OH_Drawing_FallbackGroup { * @since 12 * @version 1.0 */ -typedef struct OH_Drawing_AdjustInfo { +typedef struct OH_Drawing_FontAdjustInfo { /** The font's original weight value */ int weight; /** The font weight displayed in the application */ int to; -} OH_Drawing_AdjustInfo; +} OH_Drawing_FontAdjustInfo; /** * @brief Alias font information. @@ -420,16 +422,16 @@ typedef struct OH_Drawing_AdjustInfo { * @since 12 * @version 1.0 */ -typedef struct OH_Drawing_AliasInfo { +typedef struct OH_Drawing_FontAliasInfo { /** Font family name */ char* familyName; /** * Font weight value. When the weight value is greater than 0, * the font set contains only fonts with the specified weight. - * When the weight value is equal to 0, the font set contains all fonts + * When the weight value is equal to 0, the font set contains all fonts. */ int weight; -} OH_Drawing_AliasInfo; +} OH_Drawing_FontAliasInfo; /** * @brief General font set information supported by the system. @@ -445,9 +447,9 @@ typedef struct OH_Drawing_FontGenericInfo { /** The size of font weight mapping information lists */ size_t adjustInfoSize; /** List of alias fonts */ - OH_Drawing_AliasInfo** aliasInfoSet; + OH_Drawing_FontAliasInfo* aliasInfoSet; /** Font weight mapping information lists */ - OH_Drawing_AdjustInfo** adjustInfoSet; + OH_Drawing_FontAdjustInfo* adjustInfoSet; } OH_Drawing_FontGenericInfo; /** @@ -456,7 +458,7 @@ typedef struct OH_Drawing_FontGenericInfo { * @since 12 * @version 1.0 */ -typedef struct OH_Drawing_FontConfigJsonInfo { +typedef struct OH_Drawing_FontConfigInfo { /** Count of system font file paths */ size_t fontDirSize; /** List size of generic font sets */ @@ -466,10 +468,10 @@ typedef struct OH_Drawing_FontConfigJsonInfo { /** List of system font file paths */ char** fontDirSet; /** List of generic font sets */ - OH_Drawing_FontGenericInfo** fontGenericInfoSet; + OH_Drawing_FontGenericInfo* fontGenericInfoSet; /** List of fallback font sets */ - OH_Drawing_FallbackGroup** fallbackGroupSet; -} OH_Drawing_FontConfigJsonInfo; + OH_Drawing_FontFallbackGroup* fallbackGroupSet; +} OH_Drawing_FontConfigInfo; /** * @brief Creates an OH_Drawing_TypographyStyle object. @@ -1806,27 +1808,25 @@ void OH_Drawing_DestroyTextShadows(OH_Drawing_TextShadow*); * @brief Gets system font configuration information. * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing - * @param OH_Drawing_FontConfigJsonInfoCode Error code, based on the error code to - * release the memory of system font configuration information, - * For details, see the enum OH_Drawing_FontConfigJsonInfoCode. + * @param OH_Drawing_FontConfigInfoErrorCode Indicates error code returned, based on the error code to + * release the memory of system font configuration information. + * For details, see the enum OH_Drawing_FontConfigInfoErrorCode. * @return Returns a pointer to system font configuration information. - * Indicates the pointer to an OH_Drawing_CreateFontConfigJsonInfo object. + * Indicates the pointer to an OH_Drawing_FontConfigInfo object. * @since 12 * @version 1.0 */ -OH_Drawing_FontConfigJsonInfo* OH_Drawing_CreateFontConfigJsonInfo(OH_Drawing_FontConfigJsonInfoCode*); +OH_Drawing_FontConfigInfo* OH_Drawing_GetSystemFontConfigInfo(OH_Drawing_FontConfigInfoErrorCode*); /** * @brief Releases the memory occupied by system font configuration information. * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing - * @param OH_Drawing_FontConfigJsonInfo Indicates the pointer to an OH_Drawing_CreateFontConfigJsonInfo object. - * @param OH_Drawing_FontConfigJsonInfoCode Error code, based on the error code to release the memory of - * system font configuration information, For details, see the enum OH_Drawing_FontConfigJsonInfoCode. + * @param OH_Drawing_FontConfigInfo Indicates the pointer to an OH_Drawing_FontConfigInfo object. * @since 12 * @version 1.0 */ -void OH_Drawing_DestroyFontConfigJsonInfo(OH_Drawing_FontConfigJsonInfo**, OH_Drawing_FontConfigJsonInfoCode*); +void OH_Drawing_DestroySystemFontConfigInfo(OH_Drawing_FontConfigInfo*); #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 4bb306c53..488fa9220 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -588,11 +588,11 @@ }, { "first_introduced": "12", - "name": "OH_Drawing_CreateFontConfigJsonInfo" + "name": "OH_Drawing_GetSystemFontConfigInfo" }, { "first_introduced": "12", - "name": "OH_Drawing_DestroyFontConfigJsonInfo" + "name": "OH_Drawing_DestroySystemFontConfigInfo" } ] \ No newline at end of file -- Gitee