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 OHOS_ROSEN_FONT_DESCRIPTOR_MGR_H
17 #define OHOS_ROSEN_FONT_DESCRIPTOR_MGR_H
18 
19 #ifdef BUILD_NON_SDK_VER
20 #include <nocopyable.h>
21 #endif
22 
23 #include <mutex>
24 
25 #include "font_descriptor_cache.h"
26 #include "font_parser.h"
27 
28 namespace OHOS::Rosen {
29 using FontDescSharedPtr = std::shared_ptr<TextEngine::FontParser::FontDescriptor>;
30 
31 class FontDescriptorMgr {
32 public:
33     static FontDescriptorMgr& GetInstance();
34     virtual ~FontDescriptorMgr();
35 
36 #ifdef BUILD_NON_SDK_VER
37     DISALLOW_COPY_AND_MOVE(FontDescriptorMgr);
38 #endif
39 
40     void ParseAllFontSource();
41     void GetFontDescSharedPtrByFullName(const std::string& fullName,
42         const int32_t& systemFontType, FontDescSharedPtr& result);
43     void GetSystemFontFullNamesByType(const int32_t& systemFontType, std::unordered_set<std::string>& fontList);
44     void ClearFontFileCache();
45 
46 private:
47     FontDescriptorMgr();
48 
49     FontDescriptorCache descCache_;
50     std::mutex parserMtx_;
51 };
52 } // namespace OHOS::Rosen
53 #define FontDescriptorMgrInstance OHOS::Rosen::FontDescriptorMgr::GetInstance()
54 #endif // OHOS_ROSEN_FONT_DESCRIPTOR_MGR_H