1 /* 2 * Copyright (c) 2021 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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_TEXT_ROSEN_RENDER_TEXT_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_TEXT_ROSEN_RENDER_TEXT_H 18 19 #include "core/components/text/render_text.h" 20 #include "core/components/text_span/render_text_span.h" 21 22 namespace OHOS::Ace { 23 24 class RosenRenderText final : public RenderText { 25 DECLARE_ACE_TYPE(RosenRenderText, RenderText); 26 27 public: 28 RosenRenderText() = default; 29 ~RosenRenderText() override = default; 30 31 void Update(const RefPtr<Component>& component) override; 32 void Paint(RenderContext& context, const Offset& offset) override; 33 double GetBaselineDistance(TextBaseline textBaseline) override; 34 double GetTextWidth() override; 35 36 protected: 37 bool MaybeRelease() override; 38 void ClearRenderObject() override; 39 Offset GetHandleOffset(int32_t extend) override; 40 41 private: 42 Size Measure() override; 43 uint32_t GetTextLines() override; 44 int32_t GetTouchPosition(const Offset& offset) override; 45 bool UpdateParagraph(); 46 bool UpdateParagraphAndLayout(double paragraphMaxWidth); 47 Size GetSize(); 48 bool NeedPaint(); 49 bool AdaptTextSize(double paragraphMaxWidth); 50 bool AdaptMinTextSize(double paragraphMaxWidth); 51 bool AdaptPreferTextSize(double paragraphMaxWidth); 52 bool AdaptPreferTextSizeGroup(double paragraphMaxWidth); 53 bool CheckMeasureFlag(); 54 bool DidExceedMaxLines(double paragraphMaxWidth); 55 bool IsCompatibleVersion(); 56 void EffectAutoMaxLines(); 57 // Change text direction accroding to first strong direction letter when developer set direction auto. 58 bool ChangeDirectionIfNeeded(const std::string& data); 59 std::string ApplyWhiteSpace(); 60 void ApplyIndents(double width); 61 62 double paragraphNewWidth_ = 0.0; 63 double lastLayoutMaxWidth_ = 0.0; 64 double lastLayoutMinWidth_ = 0.0; 65 double lastLayoutMaxHeight_ = 0.0; 66 double lastLayoutMinHeight_ = 0.0; 67 }; 68 69 } // namespace OHOS::Ace 70 71 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_TEXT_ROSEN_RENDER_TEXT_H 72