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 GLOBAL_FONT_MANAGER_FONT_ADDON_H 17 #define GLOBAL_FONT_MANAGER_FONT_ADDON_H 18 19 #include "napi/native_api.h" 20 #include "napi/native_node_api.h" 21 #include "font_napi_callback.h" 22 23 namespace OHOS { 24 namespace Global { 25 namespace FontManager { 26 class FontManagerAddon { 27 public: 28 FontManagerAddon(); 29 ~FontManagerAddon(); 30 static napi_value Init(napi_env env, napi_value exports); 31 static napi_value InstallFont(napi_env env, napi_callback_info info); 32 static napi_value UninstallFont(napi_env env, napi_callback_info info); 33 34 private: 35 static napi_value ProcessFontByValue( 36 napi_env env, napi_callback_info info, const std::string &name, napi_async_execute_callback execute); 37 static std::string GetResNameOrPath(napi_env env, size_t argc, napi_value *argv); 38 static void Complete(napi_env env, napi_status status, void* data); 39 static void ProcessPromiseResult(napi_env env, FontNapiCallback *callback, napi_value (&result)[2]); 40 static void ProcessCallbackResult(napi_env env, FontNapiCallback *callback, napi_value (&result)[2]); 41 static napi_value GetResult(napi_env env, std::unique_ptr<FontNapiCallback> &callback, 42 const std::string &name, napi_async_execute_callback execute); 43 }; 44 } // namespace FontManager 45 } // namespace Global 46 } // namespace OHOS 47 #endif // GLOBAL_FONT_MANAGER_FONT_ADDON_H 48