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