1 /* 2 * Copyright (c) 2025 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 OHOS_DRAWING_TEXT_ADAPTER_IMPL_H 17 #define OHOS_DRAWING_TEXT_ADAPTER_IMPL_H 18 19 #include "ohos_drawing_text_adapter.h" 20 21 namespace OHOS::NWeb { 22 class OhosDrawingTextFontAdapterImpl : public OhosDrawingTextFontAdapter { 23 public: 24 static OhosDrawingTextFontAdapter& GetInstance(); 25 /** 26 * @brief Construct a new OhosDrawingTextFontAdapterImpl object. 27 */ 28 OhosDrawingTextFontAdapterImpl() = default; 29 30 /** 31 * @brief Destroy the OhosDrawingTextFontAdapterImpl object. 32 */ 33 ~OhosDrawingTextFontAdapterImpl() override; 34 35 /** 36 * @brief Get OH_Drawing_Array by OH_Drawing_GetSystemFontFullNamesByType. 37 * 38 * @param systemFontType Indicates enumerates of system font type object <b>OH_Drawing_SystemFontType</b>. 39 * @param drawingArray the pointer to full name array object <b>OH_Drawing_Array</b>. 40 * @return ErrCode, -1 mean fail and other mean success. 41 */ 42 int GetSystemFontFullNamesByType(int32_t systemFontType, void** drawingArray) override; 43 44 /** 45 * @brief Get OH_Drawing_FontDescriptor by OH_Drawing_GetFontDescriptorByFullName 46 * 47 * @param drawingString Indicates the full name object <b>OH_Drawing_String</b>. 48 * @param systemFontType Indicates enumerates of system font type object <b>OH_Drawing_SystemFontType</b>. 49 * @param drawingFontDescriptor the pointer to a font descriptor object <b>OH_Drawing_FontDescriptor</b>. 50 * @return ErrCode, -1 mean fail and other mean success. 51 */ 52 int GetFontDescriptorByFullName(void* drawingString, int32_t systemFontType, void** drawingFontDescriptor) override; 53 54 /** 55 * @brief Get OH_Drawing_String by OH_Drawing_GetSystemFontFullNameByIndex 56 * 57 * @param drawingArray Indicates an array of full name object <b>OH_Drawing_Array</b>. 58 * @param indexOfFullName The index of full name. 59 * @param drawingString The full name object <b>OH_Drawing_String</b>. 60 * @return ErrCode, -1 mean fail and other mean success. 61 */ 62 int GetSystemFontFullNameByIndex(void* drawingArray, int32_t indexOfFullName, const void** drawingString) override; 63 64 /** 65 * @brief Releases the memory occupied by an array of font full names. 66 * 67 * @param drawingArray Indicates an array of full name object <b>OH_Drawing_Array</b>. 68 */ 69 void DestroySystemFontFullNames(void* drawingArray) override; 70 71 /** 72 * @brief Releases the memory occupied by descriptor. 73 * 74 * @param descriptor Indicates the pointer to an <b>OH_Drawing_FontDescriptor</b> object. 75 */ 76 void DestroyFontDescriptor(void* descriptor) override; 77 }; 78 79 class OhosDrawingTextTypographyAdapterImpl : public OhosDrawingTextTypographyAdapter { 80 public: 81 static OhosDrawingTextTypographyAdapter& GetInstance(); 82 /** 83 * @brief Construct a new OhosDrawingTextFontAdapterImpl object. 84 */ 85 OhosDrawingTextTypographyAdapterImpl() = default; 86 87 /** 88 * @brief Destroy the OhosDrawingTextTypographyAdapterImpl object. 89 */ 90 ~OhosDrawingTextTypographyAdapterImpl() override; 91 92 /** 93 * @brief get OH_Drawing_FontConfigInfo by OH_Drawing_GetSystemFontConfigInfo. 94 * 95 * @param fontConfigInfoErrorCode Indicates error code returned, based on the error code to 96 * release the memory of system font configuration information. 97 * @param fontConfigInfo The pointer to system font configuration information. 98 * Indicates the pointer to an <b>OH_Drawing_FontConfigInfo</b> object. 99 * @return ErrCode, -1 mean fail and other mean success. 100 */ 101 int GetSystemFontConfigInfo(void* fontConfigInfoErrorCode, void** fontConfigInfo) override; 102 103 /** 104 * @brief get size of Array by OH_Drawing_GetDrawingArraySize. 105 * 106 * @param drawingArray Indicates the pointer to the array object <b>OH_Drawing_Array</b>. 107 * @param sizeOfArray Size of array., the result of OH_Drawing_GetDrawingArraySize. 108 * @return ErrCode, -1 mean fail and other mean success. 109 */ 110 int GetDrawingArraySize(void* drawingArray, int32_t& sizeOfArray) override; 111 112 /** 113 * @brief Releases the memory occupied by system font configuration information. 114 * 115 * @param fontConfigInfo Indicates the pointer to an <b>OH_Drawing_FontConfigInfo</b> object. 116 */ 117 void DestroySystemFontConfigInfo(void* fontConfigInfo) override; 118 }; 119 } // namespace OHOS::NWeb 120 121 #endif // OHOS_DRAWING_TEXT_FONT_ADAPTER_IMPL_H