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_RANGES_H 17 #define ROSEN_MODULES_TEXGINE_SRC_OPENTYPE_PARSER_RANGES_H 18 19 #include <cstdint> 20 #include <map> 21 #include <string> 22 #include <vector> 23 24 namespace OHOS { 25 namespace Rosen { 26 namespace TextEngine { 27 class Ranges { 28 public: 29 struct Range { 30 uint32_t start; 31 uint32_t end; 32 int32_t gid; 33 }; 34 static constexpr int32_t INVALID_GLYPH_ID = -1; 35 36 /* 37 * @brief Add a new range 38 */ 39 void AddRange(const struct Range &range); 40 41 /* 42 * @brief Return the glyph id of the codepoint in ranges_ 43 */ 44 int32_t GetGlyphId(uint32_t codepoint) const; 45 46 /* 47 * @brief Print the dump info 48 */ 49 void Dump() const; 50 51 private: 52 friend void ReportMemoryUsage(const std::string &member, const Ranges &that, bool needThis); 53 54 std::vector<struct Range> ranges_; 55 std::map<uint32_t, int32_t> singles_; 56 }; 57 } // namespace TextEngine 58 } // namespace Rosen 59 } // namespace OHOS 60 61 #endif // ROSEN_MODULES_TEXGINE_SRC_OPENTYPE_PARSER_RANGES_H 62