• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.. All rights reserved.
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 TEXT_LINE_BASE_DEFINED
17 #define TEXT_LINE_BASE_DEFINED
18 
19 #ifdef ENABLE_TEXT_ENHANCE
20 #include <stddef.h>
21 
22 #include "modules/skparagraph/include/DartTypes.h"
23 #include "RunBase.h"
24 
25 namespace skia {
26 namespace textlayout {
27 
28 class TextLineBase {
29 public:
30     virtual ~TextLineBase() = default;
31     virtual size_t getGlyphCount() const = 0;
32     virtual std::vector<std::unique_ptr<RunBase>> getGlyphRuns() const = 0;
33     virtual SkRange<size_t> getTextRange() const = 0;
34     virtual void paint(ParagraphPainter* painter, SkScalar x, SkScalar y) = 0;
35 
36     virtual std::unique_ptr<TextLineBase> createTruncatedLine(double width, EllipsisModal ellipsisMode,
37         const std::string& ellipsisStr) = 0;
38     virtual double getTypographicBounds(double* ascent, double* descent, double* leading) const = 0;
39     virtual RSRect getImageBounds() const = 0;
40     virtual double getTrailingSpaceWidth() const = 0;
41     virtual int32_t getStringIndexForPosition(SkPoint point) const = 0;
42     virtual double getOffsetForStringIndex(int32_t index) const = 0;
43     virtual std::map<int32_t, double> getIndexAndOffsets(bool& isHardBreak) const = 0;
44     virtual double getAlignmentOffset(double alignmentFactor, double alignmentWidth) const = 0;
45 };
46 }  // namespace textlayout
47 }  // namespace skia
48 
49 #endif // ENABLE_TEXT_ENHANCE
50 #endif  // TEXT_LINE_BASE_DEFINED