1 /* 2 * Copyright (c) 2023 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_MODULES_TEXGINE_SRC_TEXGINE_DRAWING_TEXGINE_FONT_H 17 #define ROSEN_MODULES_TEXGINE_SRC_TEXGINE_DRAWING_TEXGINE_FONT_H 18 19 #include <memory> 20 21 #include <include/core/SkFont.h> 22 23 #include "texgine_font_metrics.h" 24 #include "texgine_typeface.h" 25 26 namespace OHOS { 27 namespace Rosen { 28 namespace TextEngine { 29 class TexgineFont { 30 public: 31 std::shared_ptr<SkFont> GetFont() const; 32 33 /* 34 * @brief Set typeface to SkFont 35 */ 36 void SetTypeface(const std::shared_ptr<TexgineTypeface> tf); 37 38 /* 39 * @brief Set font size 40 */ 41 void SetSize(float textSize); 42 43 /* 44 * @brief Get metrics of the font 45 */ 46 float GetMetrics(TexgineFontMetrics *metrics) const; 47 48 private: 49 std::shared_ptr<SkFont> font_ = std::make_shared<SkFont>(); 50 }; 51 } // namespace TextEngine 52 } // namespace Rosen 53 } // namespace OHOS 54 55 #endif // ROSEN_MODULES_TEXGINE_SRC_TEXGINE_DRAWING_TEXGINE_FONT_H 56