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#include <stddef.h>
20
21#include "modules/skparagraph/include/DartTypes.h"
22#include "RunBase.h"
23
24namespace skia {
25namespace textlayout {
26
27class TextLineBase {
28public:
29    virtual ~TextLineBase() = default;
30    virtual size_t getGlyphCount() const = 0;
31    virtual std::vector<std::unique_ptr<RunBase>> getGlyphRuns() const = 0;
32    virtual SkRange<size_t> getTextRange() const = 0;
33    virtual void paint(ParagraphPainter* painter, SkScalar x, SkScalar y) = 0;
34
35#ifdef OHOS_SUPPORT
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#endif
46};
47}  // namespace textlayout
48}  // namespace skia
49
50#endif  // TEXT_LINE_BASE_DEFINED