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 /** 17 * @addtogroup Drawing 18 * @{ 19 * 20 * @brief Provides functions such as 2D graphics rendering, text drawing, and image display. 21 * 22 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 23 * 24 * @since 12 25 * @version 1.0 26 */ 27 28 /** 29 * @file drawing_font_mgr.h 30 * 31 * @brief Declares functions related to the <b>fontmgr</b> object in the drawing module. 32 * 33 * @kit ArkGraphics2D 34 * @library libnative_drawing.so 35 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 36 * @since 12 37 * @version 1.0 38 */ 39 40 #ifndef C_INCLUDE_DRAWING_FONT_MGR_H 41 #define C_INCLUDE_DRAWING_FONT_MGR_H 42 43 #include "drawing_types.h" 44 #include "drawing_text_typography.h" 45 #include <stdint.h> 46 47 #ifdef __cplusplus 48 extern "C" { 49 #endif 50 51 /** 52 * @brief Creates an <b>OH_Drawing_FontMgr</b> object. 53 * 54 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 55 * @return Returns the pointer to the <b>OH_Drawing_FontMgr</b> object created. 56 * @since 12 57 * @version 1.0 58 */ 59 OH_Drawing_FontMgr* OH_Drawing_FontMgrCreate(void); 60 61 /** 62 * @brief Releases the memory occupied by an <b>OH_Drawing_FontMgr</b> object. 63 * 64 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 65 * @param drawingFontMgr Indicates the pointer to an <b>OH_Drawing_FontMgr</b> object. 66 * @since 12 67 * @version 1.0 68 */ 69 void OH_Drawing_FontMgrDestroy(OH_Drawing_FontMgr* drawingFontMgr); 70 71 /** 72 * @brief Gets the count of font families. 73 * 74 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 75 * @param drawingFontMgr Indicates the pointer to an <b>OH_Drawing_FontMgr</b> object. 76 * @return Returns the count of font families. 77 * @since 12 78 * @version 1.0 79 */ 80 int OH_Drawing_FontMgrGetFamilyCount(OH_Drawing_FontMgr* drawingFontMgr); 81 82 /** 83 * @brief Gets the font family name by the index. 84 * 85 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 86 * @param drawingFontMgr Indicates the pointer to an <b>OH_Drawing_FontMgr</b> object. 87 * @param index Indicates the index to get the font family name. 88 * @return Returns the font family name corresponding to the index value. 89 * @since 12 90 * @version 1.0 91 */ 92 char* OH_Drawing_FontMgrGetFamilyName(OH_Drawing_FontMgr* drawingFontMgr, int index); 93 94 /** 95 * @brief Releases the memory occupied by font family name. 96 * 97 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 98 * @param familyName Indicates the font family name. 99 * @since 12 100 * @version 1.0 101 */ 102 void OH_Drawing_FontMgrDestroyFamilyName(char* familyName); 103 104 /** 105 * @brief Creates an <b>OH_Drawing_FontStyleSet</b> object by <b>OH_Drawing_FontMgr</b> object. 106 * 107 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 108 * @param drawingFontMgr Indicates the pointer to an <b>OH_Drawing_FontMgr</b> object. 109 * @param index Indicates the index used to get the font style set object from the font manager object. 110 * @return Returns the pointer to the <b>OH_Drawing_FontStyleSet</b> object created. 111 * @since 12 112 * @version 1.0 113 */ 114 OH_Drawing_FontStyleSet* OH_Drawing_FontMgrCreateFontStyleSet(OH_Drawing_FontMgr* drawingFontMgr, int index); 115 116 /** 117 * @brief Releases the memory occupied by an <b>OH_Drawing_FontStyleSet</b> object. 118 * 119 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 120 * @param drawingFontStyleSet Indicates the pointer to an <b>OH_Drawing_FontStyleSet</b> object. 121 * @since 12 122 * @version 1.0 123 */ 124 void OH_Drawing_FontMgrDestroyFontStyleSet(OH_Drawing_FontStyleSet* drawingFontStyleSet); 125 126 /** 127 * @brief Get the pointer to an <b>OH_Drawing_FontStyleSet</b> object for the given font style set family name. 128 * 129 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 130 * @param drawingFontMgr Indicates the pointer to an <b>OH_Drawing_FontMgr</b> object. 131 * @param familyName Indicates the family name of a font style set to be matched. 132 * @return Returns the pointer to the <b>OH_Drawing_FontStyleSet</b> object matched. 133 * @since 12 134 * @version 1.0 135 */ 136 OH_Drawing_FontStyleSet* OH_Drawing_FontMgrMatchFamily(OH_Drawing_FontMgr* drawingFontMgr, const char* familyName); 137 138 /** 139 * @brief Get the pointer to an <b>OH_Drawing_Typeface</b> object based on the given font style and family name. 140 * 141 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 142 * @param drawingFontMgr Indicates the pointer to an <b>OH_Drawing_FontMgr</b> object. 143 * @param familyName Indicates the family name of a font style set to be matched. 144 * @param fontStyle Indicates an <b>OH_Drawing_FontStyleStruct</b> object. 145 * @return Returns the pointer to the <b>OH_Drawing_Typeface</b> object matched. 146 * @since 12 147 * @version 1.0 148 */ 149 OH_Drawing_Typeface* OH_Drawing_FontMgrMatchFamilyStyle(OH_Drawing_FontMgr* drawingFontMgr, 150 const char* familyName, OH_Drawing_FontStyleStruct fontStyle); 151 152 /** 153 * @brief Get the pointer to an <b>OH_Drawing_Typeface</b> object for the given character. 154 * 155 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 156 * @param drawingFontMgr Indicates the pointer to an <b>OH_Drawing_FontMgr</b> object. 157 * @param familyName Indicates the family name of a font style set to be matched. 158 * @param fontStyle Indicates an <b>OH_Drawing_FontStyleStruct</b> object. 159 * @param bcp47 Indicates an array of languages which indicate the language of character. 160 * @param bcp47Count Indicates the array size of bcp47. 161 * @param character Indicates a UTF8 value to be matched. 162 * @return Returns the pointer to the <b>OH_Drawing_Typeface</b> object matched. 163 * @since 12 164 * @version 1.0 165 */ 166 OH_Drawing_Typeface* OH_Drawing_FontMgrMatchFamilyStyleCharacter(OH_Drawing_FontMgr* drawingFontMgr, 167 const char* familyName, OH_Drawing_FontStyleStruct fontStyle, 168 const char* bcp47[], int bcp47Count, int32_t character); 169 170 /** 171 * @brief Create a typeface for the given index. 172 * 173 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 174 * @param fontStyleSet Indicates the pointer to an <b>OH_Drawing_FontStyleSet</b> object. 175 * @param index Indicates the index of the typeface in this fontStyleSet. 176 * @return If successful, return a pointer to <b>OH_Drawing_Typeface</b> object; if failed, return nullptr. 177 * @since 12 178 * @version 1.0 179 */ 180 OH_Drawing_Typeface* OH_Drawing_FontStyleSetCreateTypeface(OH_Drawing_FontStyleSet* fontStyleSet, int index); 181 182 /** 183 * @brief Get font style for the specified typeface. 184 * 185 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 186 * @param fontStyleSet Indicates the pointer to an <b>OH_Drawing_FontStyleSet</b> object. 187 * @param index Indicates the index of the typeface in this fontStyleSet. 188 * @param styleName Indicates the style name returned. 189 * @return Return the <b>OH_Drawing_FontStyleStruct<b> structure. 190 * @since 12 191 * @version 1.0 192 */ 193 OH_Drawing_FontStyleStruct OH_Drawing_FontStyleSetGetStyle(OH_Drawing_FontStyleSet* fontStyleSet, int32_t index, 194 char** styleName); 195 196 /** 197 * @brief Releases the memory styleName string. 198 * 199 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 200 * @param styleName Indicates the pointer to a string type. 201 * @since 12 202 * @version 1.0 203 */ 204 void OH_Drawing_FontStyleSetFreeStyleName(char** styleName); 205 206 /** 207 * @brief Get the closest matching typeface. 208 * 209 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 210 * @param fontStyleSet Indicates the pointer to an <b>OH_Drawing_FontStyleSet</b> object. 211 * @param fontStyleStruct Indicates the <b>OH_Drawing_FontStyleStruct</b> structure. 212 * @return A pointer to matched <b>OH_Drawing_Typeface</b>. 213 * @since 12 214 * @version 1.0 215 */ 216 OH_Drawing_Typeface* OH_Drawing_FontStyleSetMatchStyle(OH_Drawing_FontStyleSet* fontStyleSet, 217 OH_Drawing_FontStyleStruct fontStyleStruct); 218 219 /** 220 * @brief Get the count of typeface. 221 * 222 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 223 * @param fontStyleSet Indicates the pointer to an <b>OH_Drawing_FontStyleSet</b> object. 224 * @return The count of typeface in this font style set. 225 * @since 12 226 * @version 1.0 227 */ 228 int OH_Drawing_FontStyleSetCount(OH_Drawing_FontStyleSet* fontStyleSet); 229 230 #ifdef __cplusplus 231 } 232 #endif 233 /** @} */ 234 #endif