• 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_SRC_TYPEFACE_H
17 #define ROSEN_MODULES_TEXGINE_SRC_TYPEFACE_H
18 
19 #include <iostream>
20 #include <memory>
21 
22 #include "opentype_parser/cmap_parser.h"
23 #include "texgine_string.h"
24 #include "texgine_typeface.h"
25 
26 struct hb_blob_t;
27 
28 namespace OHOS {
29 namespace Rosen {
30 namespace TextEngine {
31 class Typeface {
32 public:
33     static std::unique_ptr<Typeface> MakeFromFile(const std::string &filename);
34 
35     Typeface(std::shared_ptr<TexgineTypeface> tf);
36     ~Typeface();
37 
38     std::string GetName();
39     bool Has(uint32_t ch);
Get()40     std::shared_ptr<TexgineTypeface> Get() const { return typeface_; }
41 
42 private:
43     friend void ReportMemoryUsage(const std::string &member, const Typeface &str, bool needThis);
44 
45     bool ParseCmap(const std::shared_ptr<CmapParser> &parser);
46 
47     std::shared_ptr<TexgineTypeface> typeface_ = nullptr;
48     TexgineString name_;
49     hb_blob_t *hblob_ = nullptr;
50     std::shared_ptr<CmapParser> cmapParser_ = nullptr;
51     std::unique_ptr<char[]> cmapData_ = nullptr;
52 
53     static inline std::map<std::string, std::shared_ptr<CmapParser>> cmapCache_;
54 };
55 } // namespace TextEngine
56 } // namespace Rosen
57 } // namespace OHOS
58 
59 #endif // ROSEN_MODULES_TEXGINE_SRC_TYPEFACE_H
60