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 FONT_IMPL_H 17 #define FONT_IMPL_H 18 19 #include <cstdint> 20 21 #include "impl_interface/base_impl.h" 22 #include "text/font_metrics.h" 23 #include "text/font_types.h" 24 #include "text/typeface.h" 25 #include "utils/rect.h" 26 #include "utils/scalar.h" 27 28 namespace OHOS { 29 namespace Rosen { 30 namespace Drawing { 31 enum class FontEdging; 32 33 class FontImpl : public BaseImpl { 34 public: 35 ~FontImpl() override = default; 36 37 virtual void SetEdging(FontEdging edging) = 0; 38 virtual void SetSubpixel(bool isSubpixel) = 0; 39 virtual void SetHinting(FontHinting hintingLevel) = 0; 40 virtual void SetTypeface(std::shared_ptr<Typeface> typeface) = 0; 41 virtual void SetSize(scalar textSize) = 0; 42 virtual void SetEmbolden(bool isEmbolden) = 0; 43 virtual void SetScaleX(scalar scaleX) = 0; 44 virtual void SetSkewX(scalar skewX) = 0; 45 virtual void SetLinearMetrics(bool isLinearMetrics) = 0; 46 47 virtual scalar GetMetrics(FontMetrics* metrics) const = 0; 48 virtual void GetWidths(const uint16_t glyphs[], int count, scalar widths[]) const = 0; 49 virtual void GetWidths(const uint16_t glyphs[], int count, scalar widths[], Rect bounds[]) const = 0; 50 virtual scalar GetSize() const = 0; 51 virtual std::shared_ptr<Typeface> GetTypeface() = 0; 52 53 virtual scalar MeasureText(const void* text, size_t byteLength, TextEncoding encoding) = 0; 54 55 protected: 56 FontImpl() noexcept = default; 57 }; 58 } // namespace Drawing 59 } // namespace Rosen 60 } // namespace OHOS 61 #endif