• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.. All rights reserved.
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_SPTEXT_PLATFORM_H
17 #define ROSEN_MODULES_SPTEXT_PLATFORM_H
18 
19 #include <shared_mutex>
20 #include <string>
21 #include <vector>
22 
23 #include "utils.h"
24 
25 #include "text/font_mgr.h"
26 
27 #ifndef TEXTING_API
28 #ifdef _WIN32
29 #define TEXTING_EXPORT __attribute__((dllexport))
30 #define TEXTING_IMPORT __attribute__((dllimport))
31 #else
32 #define TEXTING_EXPORT __attribute__((visibility("default")))
33 #define TEXTING_IMPORT __attribute__((visibility("default")))
34 #endif
35 #ifdef MODULE_TEXTING
36 #define TEXTING_API TEXTING_EXPORT
37 #else
38 #define TEXTING_API TEXTING_IMPORT
39 #endif
40 #endif
41 
42 namespace OHOS {
43 namespace Rosen {
44 namespace SPText {
45 constexpr const char* OHOS_THEME_FONT = "OhosThemeFont";
46 constexpr const char* OHOS_THEME_FONT_LOW = "ohosthemefont";
47 class TEXTING_API DefaultFamilyNameMgr {
48 public:
49     static DefaultFamilyNameMgr& GetInstance();
50     std::vector<std::string> GetDefaultFontFamilies() const;
51     std::vector<std::string> GetThemeFontFamilies() const;
52     void ModifyThemeFontFamilies(size_t index);
53     static std::string GenerateThemeFamilyName(size_t index);
54     static bool IsThemeFontFamily(std::string familyName);
55 
56 private:
57     DefaultFamilyNameMgr();
58     DefaultFamilyNameMgr(const DefaultFamilyNameMgr&) = delete;
59     const DefaultFamilyNameMgr& operator=(const DefaultFamilyNameMgr&) = delete;
60     std::vector<std::string> themeFamilies_;
61     std::vector<std::string> defaultFamilies_;
62     mutable std::shared_mutex lock_;
63 };
64 
65 std::shared_ptr<Drawing::FontMgr> GetDefaultFontManager();
66 } // namespace SPText
67 } // namespace Rosen
68 } // namespace OHOS
69 
70 #endif // ROSEN_MODULES_SPTEXT_PLATFORM_H
71