• 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_LINE_BREAKER_H
17 #define ROSEN_MODULES_TEXGINE_SRC_LINE_BREAKER_H
18 
19 #include <vector>
20 
21 #include "line_metrics.h"
22 #include "texgine/typography_types.h"
23 
24 namespace OHOS {
25 namespace Rosen {
26 namespace TextEngine {
27 struct ScoredSpan {
28     VariantSpan span;
29     double preBreak;
30     double postBreak;
31     double score;
32     int32_t prev;
33 };
34 
35 class LineBreaker {
36 public:
37     static std::vector<LineMetrics> BreakLines(std::vector<VariantSpan> &spans,
38         const TypographyStyle &tstyle, const double widthLimit) noexcept(false);
39     static std::vector<struct ScoredSpan> GenerateScoreSpans(const std::vector<VariantSpan> &spans) noexcept(false);
40     static void DoBreakLines(std::vector<struct ScoredSpan> &scoredSpans, const double widthLimit,
41         const TypographyStyle &tstyle) noexcept(false);
42     static std::vector<int32_t> GenerateBreaks(const std::vector<struct ScoredSpan> &scoredSpans) noexcept(false);
43     static std::vector<LineMetrics> GenerateLineMetrics(std::vector<VariantSpan> &spans,
44         std::vector<int32_t> &breaks) noexcept(false);
45 };
46 } // namespace TextEngine
47 } // namespace Rosen
48 } // namespace OHOS
49 
50 #endif // ROSEN_MODULES_TEXGINE_SRC_LINE_BREAKER_H
51