1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef DRAWING_TEXT_FONT_DESCRIPTOR_H 17 #define DRAWING_TEXT_FONT_DESCRIPTOR_H 18 19 /** 20 * @addtogroup Drawing 21 * @{ 22 * 23 * @brief Provides the font descriptor capability. 24 * 25 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 26 * 27 * @since 14 28 * @version 1.0 29 */ 30 31 /** 32 * @file drawing_text_font_descriptor.h 33 * 34 * @brief Provide the ability to provide <b>OH_Drawing_FontDescriptor</b>. 35 * 36 * @kit ArkGraphics2D 37 * @library libnative_drawing.so 38 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 39 * @since 14 40 * @version 1.0 41 */ 42 43 #include "drawing_text_typography.h" 44 #include "drawing_types.h" 45 46 #ifdef __cplusplus 47 extern "C" { 48 #endif 49 50 /** 51 * @brief An enumeration of system font types. 52 * 53 * @since 14 54 * @version 1.0 55 */ 56 typedef enum { 57 /** All font types */ 58 ALL = 1 << 0, 59 /** System generic font type */ 60 GENERIC = 1 << 1, 61 /** Stylish font type */ 62 STYLISH = 1 << 2, 63 /** Installed font types */ 64 INSTALLED = 1 << 3, 65 } OH_Drawing_SystemFontType; 66 67 /** 68 * @brief Obtain all system font descriptive symbols that match the specified font descriptor. Where the 'path' and 69 * 'size' fields are not considered as valid matching values, It takes effect when the remaining fields are not 70 * default values, If all the fields of the parameters <b>OH_Drawing_FontDescriptor</b> are default, obtain all system 71 * font descriptors. If the match fails, return nullptr. 72 * 73 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 74 * @param OH_Drawing_FontDescriptor The pointer to the <b>OH_Drawing_FontDescriptor</b> object. It is recommended to 75 * use <b>OH_Drawing_CreateFontDescriptor</b> to obtain a valid <b>OH_Drawing_FontDescriptor</b> instance. 76 * If you create your own <b>OH_Drawing_FontDescriptor</b> object, ensure that fields not intended for matching are 77 * set to their default values. 78 * @param size_t Indicates the count of obtained <b>OH_Drawing_FontDescriptor</b>. 79 * @return Returns an array of <b>OH_Drawing_FontDescriptor</b>. 80 * @since 14 81 * @version 1.0 82 */ 83 OH_Drawing_FontDescriptor* OH_Drawing_MatchFontDescriptors(OH_Drawing_FontDescriptor*, size_t*); 84 85 /** 86 * @brief Releases the <b>OH_Drawing_FontDescriptor</b> array. 87 * 88 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 89 * @param OH_Drawing_FontDescriptor Pointer to <b>OH_Drawing_FontDescriptor</b> array. 90 * @param size_t Represents the number of members of the <b>OH_Drawing_FontDescriptor</b> array. 91 * @since 14 92 * @version 1.0 93 */ 94 void OH_Drawing_DestroyFontDescriptors(OH_Drawing_FontDescriptor*, size_t); 95 96 /** 97 * @brief Get the <b>OH_Drawing_FontDescriptor</b> object by the font full name and the font type, supporting generic 98 * fonts, stylish fonts, and installed fonts. 99 * 100 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 101 * @param OH_Drawing_String Indicates the full name object <b>OH_Drawing_String</b>. 102 * @param OH_Drawing_SystemFontType Indicates enumerates of system font type object <b>OH_Drawing_SystemFontType</b>. 103 * @return Returns the pointer to a font descriptor object <b>OH_Drawing_FontDescriptor</b>. 104 * @since 14 105 * @version 1.0 106 */ 107 OH_Drawing_FontDescriptor* OH_Drawing_GetFontDescriptorByFullName(const OH_Drawing_String*, OH_Drawing_SystemFontType); 108 109 /** 110 * @brief Obtain the corresponding font full name array by the font type. 111 * 112 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 113 * @param OH_Drawing_SystemFontType Indicates enumerates of system font type object <b>OH_Drawing_SystemFontType</b>. 114 * @return Returns the pointer to full name array object <b>OH_Drawing_Array</b>. 115 * @since 14 116 * @version 1.0 117 */ 118 OH_Drawing_Array* OH_Drawing_GetSystemFontFullNamesByType(OH_Drawing_SystemFontType); 119 120 /** 121 * @brief Get the specified full name object <b>OH_Drawing_String</b> by index from the 122 * <b>OH_Drawing_Array</b> object. 123 * 124 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 125 * @param OH_Drawing_Array Indicates an array of full name object <b>OH_Drawing_Array</b>. 126 * @param size_t The index of full name. 127 * @return Returns a full name object <b>OH_Drawing_String</b>. 128 * @since 14 129 * @version 1.0 130 */ 131 const OH_Drawing_String* OH_Drawing_GetSystemFontFullNameByIndex(OH_Drawing_Array*, size_t); 132 133 /** 134 * @brief Releases the memory occupied by an array of font full names. 135 * 136 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 137 * @param OH_Drawing_Array Indicates an array of full name object <b>OH_Drawing_Array</b>. 138 * @since 14 139 * @version 1.0 140 */ 141 void OH_Drawing_DestroySystemFontFullNames(OH_Drawing_Array*); 142 143 #ifdef __cplusplus 144 } 145 #endif 146 /** @} */ 147 #endif