• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 ROSEN_MODULES_TEXGINE_EXPORT_TEXGINE_DYNAMIC_FILE_FONT_PROVIDER_H
17 #define ROSEN_MODULES_TEXGINE_EXPORT_TEXGINE_DYNAMIC_FILE_FONT_PROVIDER_H
18 
19 #include <map>
20 
21 #include "texgine/dynamic_font_provider.h"
22 
23 namespace OHOS {
24 namespace Rosen {
25 namespace TextEngine {
26 /*
27  * @brief FileFontProvider is a FontProvider that can load fonts dynamically.
28  *        FileFontProvider can accept font from file path.
29  */
30 class DynamicFileFontProvider : DynamicFontProvider, virtual public IFontProvider {
31 public:
32     /*
33      * @brief Create DynamicFileFontProvider instance.
34      */
35     static std::shared_ptr<DynamicFileFontProvider> Create() noexcept(true);
36 
37     /*
38      * @brief Load font from path.
39      * @param path        Path to the font file.
40      * @param familyName  The name of the font family you want.
41      * @return            0 if success else 1 means failed
42      */
43     int LoadFont(const std::string& familyName, const std::string& path) noexcept(true);
44 
45 private:
46     std::map<std::string, std::shared_ptr<VariantFontStyleSet>> fontStyleSetMap_;
47 };
48 } // namespace TextEngine
49 } // namespace Rosen
50 } // namespace OHOS
51 
52 #endif // ROSEN_MODULES_TEXGINE_EXPORT_TEXGINE_DYNAMIC_FILE_FONT_PROVIDER_H
53