1cb93a386Sopenharmony_ci/* 2cb93a386Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd.. All rights reserved. 3cb93a386Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4cb93a386Sopenharmony_ci * you may not use this file except in compliance with the License. 5cb93a386Sopenharmony_ci * You may obtain a copy of the License at 6cb93a386Sopenharmony_ci * 7cb93a386Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8cb93a386Sopenharmony_ci * 9cb93a386Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10cb93a386Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11cb93a386Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12cb93a386Sopenharmony_ci * See the License for the specific language governing permissions and 13cb93a386Sopenharmony_ci * limitations under the License. 14cb93a386Sopenharmony_ci */ 15cb93a386Sopenharmony_ci 16cb93a386Sopenharmony_ci#ifndef TEXT_LINE_BASE_DEFINED 17cb93a386Sopenharmony_ci#define TEXT_LINE_BASE_DEFINED 18cb93a386Sopenharmony_ci 19cb93a386Sopenharmony_ci#include <stddef.h> 20cb93a386Sopenharmony_ci 21cb93a386Sopenharmony_ci#include "modules/skparagraph/include/DartTypes.h" 22cb93a386Sopenharmony_ci#include "RunBase.h" 23cb93a386Sopenharmony_ci 24cb93a386Sopenharmony_cinamespace skia { 25cb93a386Sopenharmony_cinamespace textlayout { 26cb93a386Sopenharmony_ci 27cb93a386Sopenharmony_ciclass TextLineBase { 28cb93a386Sopenharmony_cipublic: 29cb93a386Sopenharmony_ci virtual ~TextLineBase() = default; 30cb93a386Sopenharmony_ci virtual size_t getGlyphCount() const = 0; 31cb93a386Sopenharmony_ci virtual std::vector<std::unique_ptr<RunBase>> getGlyphRuns() const = 0; 32cb93a386Sopenharmony_ci virtual SkRange<size_t> getTextRange() const = 0; 33cb93a386Sopenharmony_ci virtual void paint(ParagraphPainter* painter, SkScalar x, SkScalar y) = 0; 34cb93a386Sopenharmony_ci 35cb93a386Sopenharmony_ci#ifdef OHOS_SUPPORT 36cb93a386Sopenharmony_ci virtual std::unique_ptr<TextLineBase> createTruncatedLine(double width, EllipsisModal ellipsisMode, 37cb93a386Sopenharmony_ci const std::string& ellipsisStr) = 0; 38cb93a386Sopenharmony_ci virtual double getTypographicBounds(double* ascent, double* descent, double* leading) const = 0; 39cb93a386Sopenharmony_ci virtual RSRect getImageBounds() const = 0; 40cb93a386Sopenharmony_ci virtual double getTrailingSpaceWidth() const = 0; 41cb93a386Sopenharmony_ci virtual int32_t getStringIndexForPosition(SkPoint point) const = 0; 42cb93a386Sopenharmony_ci virtual double getOffsetForStringIndex(int32_t index) const = 0; 43cb93a386Sopenharmony_ci virtual std::map<int32_t, double> getIndexAndOffsets(bool& isHardBreak) const = 0; 44cb93a386Sopenharmony_ci virtual double getAlignmentOffset(double alignmentFactor, double alignmentWidth) const = 0; 45cb93a386Sopenharmony_ci#endif 46cb93a386Sopenharmony_ci}; 47cb93a386Sopenharmony_ci} // namespace textlayout 48cb93a386Sopenharmony_ci} // namespace skia 49cb93a386Sopenharmony_ci 50cb93a386Sopenharmony_ci#endif // TEXT_LINE_BASE_DEFINED