1 /* 2 * Copyright (c) 2022 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 ROSEN_TEXT_UI_TYPOGRAPHY_CREATE_H_ 17 #define ROSEN_TEXT_UI_TYPOGRAPHY_CREATE_H_ 18 19 #include <memory> 20 #include <string> 21 #include "rosen_text/properties/typography_create_base.h" 22 #include "rosen_text/ui/font_collection.h" 23 #include "rosen_text/ui/typography.h" 24 #include "rosen_text/properties/placeholder_run.h" 25 #include "rosen_text/properties/text_style.h" 26 #include "rosen_text/properties/typography_style.h" 27 28 namespace rosen { 29 class DRAWING_API TypographyCreate { 30 public: 31 static std::unique_ptr<TypographyCreate> CreateRosenBuilder( 32 const TypographyStyle& style, 33 std::shared_ptr<FontCollection> font_collection); 34 TypographyCreate(const TypographyStyle& style, std::shared_ptr<FontCollection> font_collection); 35 virtual ~TypographyCreate() = default; 36 void PushStyle(const TextStyle& style); 37 void Pop(); 38 void AddText(const std::u16string& text); 39 void AddPlaceholder(PlaceholderRun& span); 40 std::unique_ptr<Typography> Build(); 41 private: 42 TypographyCreate& operator=(const TypographyCreate&) = delete; 43 std::shared_ptr<TypographyCreateBase> TypographyCreateBase_; 44 }; 45 } // namespace rosen 46 #endif // ROSEN_TEXT_UI_TYPOGRAPHY_CREATE_H_ 47