1 /* 2 * Copyright (c) 2025 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 #ifndef TEXT_FONT_UTILS 16 #define TEXT_FONT_UTILS 17 18 #include <vector> 19 #include <string> 20 #include <algorithm> 21 22 #include "modules/skparagraph/include/TextStyle.h" 23 #include "text_types.h" 24 #include "txt/text_style.h" 25 #include "text/font_style.h" 26 #include "SkFontArguments.h" 27 28 namespace OHOS { 29 namespace Rosen { 30 namespace SPText { 31 namespace skt = skia::textlayout; 32 33 class TextFontUtils { 34 public: 35 static FontWeight GetTxtFontWeight(int fontWeight); 36 37 static FontStyle GetTxtFontStyle(RSFontStyle::Slant slant); 38 39 static RSFontStyle::Weight GetSkiaFontWeight(FontWeight spFontWeight); 40 41 static RSFontStyle::Slant GetSkiaFontSlant(FontStyle spSlant); 42 43 static RSFontStyle::Width GetSkiaFontWidth(FontWidth spFontWidth); 44 45 static std::vector<SkString> GetSkiaFontfamilies(const std::vector<std::string>& spFontFamiles); 46 47 static void MakeFontArguments(skt::TextStyle& skStyle, const FontVariations& fontVariations); 48 49 static skt::TextShadow MakeTextShadow(const TextShadow& txtShadow); 50 51 static RSFontStyle::Slant ConvertToRSFontSlant(FontStyle fontStyle); 52 53 static int ConvertToSkFontWeight(FontWeight fontWeight); 54 55 static RSFontStyle MakeFontStyle(FontWeight fontWeight, FontWidth fontWidth, FontStyle fontStyle); 56 }; 57 } // namespace SPText 58 } // namespace Rosen 59 } // namespace OHOS 60 61 #endif // SKIA_UTILS_H