1 /* 2 * Copyright (c) 2024 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_TEXT_ADAPTER_TXT_CONVERT_H 17 #define ROSEN_TEXT_ADAPTER_TXT_CONVERT_H 18 19 #include "font_collection.h" 20 #include "rosen_text/typography_create.h" 21 #include "rosen_text/typography.h" 22 #include "rosen_text/typography_style.h" 23 #include "rosen_text/typography_types.h" 24 #include "txt/paragraph.h" 25 #include "txt/placeholder_run.h" 26 27 namespace OHOS { 28 namespace Rosen { 29 namespace AdapterTxt { 30 #define DEFINE_CONVERT_FUNC(from, to) to Convert(const from &) 31 32 #define FONT_COLLECTION_RET std::shared_ptr<OHOS::Rosen::AdapterTxt::FontCollection> 33 // from interface to adapter txt 34 DEFINE_CONVERT_FUNC(std::shared_ptr<OHOS::Rosen::FontCollection>, FONT_COLLECTION_RET); 35 #undef FONT_COLLECTION_RET 36 37 // from txt to rosen_text 38 DEFINE_CONVERT_FUNC(SPText::PositionWithAffinity, IndexAndAffinity); 39 DEFINE_CONVERT_FUNC(SPText::Range<size_t>, Boundary); 40 DEFINE_CONVERT_FUNC(SPText::TextBox, TextRect); 41 DEFINE_CONVERT_FUNC(SPText::TextStyle, TextStyle); 42 43 // from rosen_text to txt 44 DEFINE_CONVERT_FUNC(TextRectHeightStyle, SPText::RectHeightStyle); 45 DEFINE_CONVERT_FUNC(TextRectWidthStyle, SPText::RectWidthStyle); 46 DEFINE_CONVERT_FUNC(TypographyStyle, SPText::ParagraphStyle); 47 DEFINE_CONVERT_FUNC(PlaceholderSpan, SPText::PlaceholderRun); 48 DEFINE_CONVERT_FUNC(TextStyle, SPText::TextStyle); 49 DEFINE_CONVERT_FUNC(TextTab, SPText::TextTab); 50 51 #undef DEFINE_CONVERT_FUNC 52 } // namespace AdapterTxt 53 } // namespace Rosen 54 } // namespace OHOS 55 56 #endif // ROSEN_TEXT_ADAPTER_TXT_CONVERT_H 57