diff --git a/graphic/graphic_2d/native_drawing/drawing_text_typography.h b/graphic/graphic_2d/native_drawing/drawing_text_typography.h index 90c0ebb964acfeefceb261dc2d170995ffbbd781..40d7266cfca348cf0185b2f487ed4ca487c2bd8b 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,25 @@ 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_FontConfigInfoErrorCode { + /** The list of system font configuration information was successfully obtained */ + 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, +}; + /** * @brief Describes the font information. * @@ -366,6 +385,107 @@ typedef struct { int value; } OH_Drawing_FontFeature; +/** + * @brief Fallback font information. + * + * @since 12 + * @version 1.0 + */ +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_FontFallbackInfo; + +/** + * @brief Fallback font group. + * + * @since 12 + * @version 1.0 + */ +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. + */ + char* groupName; + /** Fallback font Info Size */ + size_t fallbackInfoSize; + /** A list of font sets for fallback fonts */ + OH_Drawing_FontFallbackInfo* fallbackInfoSet; +} OH_Drawing_FontFallbackGroup; + +/** + * @brief Font weight mapping information. + * + * @since 12 + * @version 1.0 + */ +typedef struct OH_Drawing_FontAdjustInfo { + /** The font's original weight value */ + int weight; + /** The font weight displayed in the application */ + int to; +} OH_Drawing_FontAdjustInfo; + +/** + * @brief Alias font information. + * + * @since 12 + * @version 1.0 + */ +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. + */ + int weight; +} OH_Drawing_FontAliasInfo; + +/** + * @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_FontAliasInfo* aliasInfoSet; + /** Font weight mapping information lists */ + OH_Drawing_FontAdjustInfo* adjustInfoSet; +} OH_Drawing_FontGenericInfo; + +/** + * @brief System font configuration information. + * + * @since 12 + * @version 1.0 + */ +typedef struct OH_Drawing_FontConfigInfo { + /** 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_FontFallbackGroup* fallbackGroupSet; +} OH_Drawing_FontConfigInfo; + /** * @brief Creates an OH_Drawing_TypographyStyle object. * @@ -1943,6 +2063,30 @@ bool OH_Drawing_TextStyleGetHalfLeading(OH_Drawing_TextStyle*); */ const char* OH_Drawing_TextStyleGetLocale(OH_Drawing_TextStyle*); +/** + * @brief Gets system font configuration information. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @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_FontConfigInfo object. + * @since 12 + * @version 1.0 + */ +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_FontConfigInfo Indicates the pointer to an OH_Drawing_FontConfigInfo object. + * @since 12 + * @version 1.0 + */ +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 b0ed71fce71647195f16c80b7b7b71d7bbb9ffe2..48e04546ef676f91361851282a3eb30cc6082079 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -897,5 +897,13 @@ { "first_introduced": "12", "name": "OH_Drawing_TextStyleGetLocale" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_GetSystemFontConfigInfo" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_DestroySystemFontConfigInfo" } ] \ No newline at end of file