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_TEXT_BREAKER_H 17 #define ROSEN_MODULES_TEXGINE_SRC_TEXT_BREAKER_H 18 19 #include <vector> 20 21 #include "variant_span.h" 22 #include "word_breaker.h" 23 24 namespace OHOS { 25 namespace Rosen { 26 namespace TextEngine { 27 class TextBreaker { 28 public: 29 int WordBreak(std::vector<VariantSpan> &spans, const TypographyStyle &ys, 30 const std::shared_ptr<FontProviders> &fontProviders); 31 32 std::shared_ptr<FontCollection> GenerateFontCollection(const TypographyStyle &ys, 33 const TextStyle &xs, const std::shared_ptr<FontProviders> &fontProviders) noexcept(false); 34 35 static int Measure(const TextStyle &xs, const std::vector<uint16_t> &u16vect, 36 const FontCollection &fontCollection, CharGroups &cgs, std::vector<Boundary> &boundaries) noexcept(false); 37 38 void BreakWord(const CharGroups &wordcgs, const TypographyStyle &ys, 39 const TextStyle &xs, std::vector<VariantSpan> &spans) noexcept(false); 40 41 void GenerateSpan(const CharGroups ¤tCgs, const TypographyStyle &ys, 42 const TextStyle &xs, std::vector<VariantSpan> &spans) noexcept(false); 43 44 double preBreak_ = 0; 45 double postBreak_ = 0; 46 }; 47 } // namespace TextEngine 48 } // namespace Rosen 49 } // namespace OHOS 50 51 #endif // ROSEN_MODULES_TEXGINE_SRC_TEXT_BREAKER_H 52