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_OPENTYPE_PARSER_CMAP_PARSER_H 17 #define ROSEN_MODULES_TEXGINE_SRC_OPENTYPE_PARSER_CMAP_PARSER_H 18 19 #include <cstdint> 20 #include <string> 21 22 #include "ranges.h" 23 24 namespace OHOS { 25 namespace Rosen { 26 namespace TextEngine { 27 struct CmapSubtable; 28 class CmapParser { 29 public: 30 static constexpr int32_t INVALID_GLYPH_ID = Ranges::INVALID_GLYPH_ID; 31 32 /* 33 * @brief Parse the cmap data 34 * @param data The data stream of cmap table 35 * @param size The size of data 36 */ 37 int Parse(const char *data, int32_t size); 38 39 /* 40 * @brief Return the glyph id of the codepoint in cmap table 41 */ 42 int32_t GetGlyphId(int32_t codepoint) const; 43 44 /* 45 * @brief Print the dump info of cmap parse 46 */ 47 void Dump() const; 48 49 private: 50 friend void ReportMemoryUsage(const std::string &member, const CmapParser &that, bool needThis); 51 52 int ParseFormat4(const CmapSubtable &subtable, const std::size_t size); 53 int ParseFormat12(const CmapSubtable &subtable, const std::size_t size); 54 void ParseFormat4NoOffset(int32_t delta, uint32_t start, uint32_t end); 55 56 Ranges ranges_; 57 }; 58 } // namespace TextEngine 59 } // namespace Rosen 60 } // namespace OHOS 61 62 #endif // ROSEN_MODULES_TEXGINE_SRC_OPENTYPE_PARSER_CMAP_PARSER_H 63