/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef C_INCLUDE_DRAWING_FONT_H
#define C_INCLUDE_DRAWING_FONT_H
/**
* @addtogroup Drawing
* @{
*
* @brief Provides functions such as 2D graphics rendering, text drawing, and image display.
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
*
* @since 11
* @version 1.0
*/
/**
* @file drawing_font.h
*
* @brief Declares functions related to the font object in the drawing module.
*
* @since 11
* @version 1.0
*/
#include "drawing_types.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Creates an OH_Drawing_Font object.
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
* @return Returns the pointer to the OH_Drawing_Font object created.
* @since 11
* @version 1.0
*/
OH_Drawing_Font* OH_Drawing_FontCreate(void);
/**
* @brief Sets an OH_Drawing_Typeface object for an OH_Drawing_Font object.
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
* @param OH_Drawing_Font Indicates the pointer to an OH_Drawing_Font object.
* @param OH_Drawing_Typeface Indicates the pointer to an OH_Drawing_Typeface object.
* @since 11
* @version 1.0
*/
void OH_Drawing_FontSetTypeface(OH_Drawing_Font*, OH_Drawing_Typeface*);
/**
* @brief Gets an OH_Drawing_Typeface object from the OH_Drawing_Typeface object.
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
* @param OH_Drawing_Font Indicates the pointer to an OH_Drawing_Font object.
* @return OH_Drawing_Typeface Indicates the pointer to an OH_Drawing_Typeface object.
* @since 12
* @version 1.0
*/
OH_Drawing_Typeface* OH_Drawing_FontGetTypeface(OH_Drawing_Font*);
/**
* @brief Set Font and glyph metrics should ignore hinting and rounding.
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
* @param OH_Drawing_Font Indicates the pointer to an OH_Drawing_Font object.
* @param bool Should ignore hinting and rounding.
* @since 12
* @version 1.0
*/
void OH_Drawing_FontSetLinearMetrics(OH_Drawing_Font*, bool);
/**
* @brief Sets text size for an OH_Drawing_Font object.
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
* @param OH_Drawing_Font Indicates the pointer to an OH_Drawing_Font object.
* @param textSize Indicates the text size.
* @since 11
* @version 1.0
*/
void OH_Drawing_FontSetTextSize(OH_Drawing_Font*, float textSize);
/**
* @brief Enables or disables linearly scalable font for an OH_Drawing_Font object.
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
* @param OH_Drawing_Font Indicates the pointer to an OH_Drawing_Font object.
* @param isLinearText Indicates whether to enable linearly scalable font.
* @since 11
* @version 1.0
*/
void OH_Drawing_FontSetLinearText(OH_Drawing_Font*, bool isLinearText);
/**
* @brief Sets text skew on x-axis for an OH_Drawing_Font object.
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
* @param OH_Drawing_Font Indicates the pointer to an OH_Drawing_Font object.
* @param skewX Indicates the additional shear on x-axis relative to y-axis.
* @since 11
* @version 1.0
*/
void OH_Drawing_FontSetTextSkewX(OH_Drawing_Font*, float skewX);
/**
* @brief Enables or disables to increase stroke width to approximate bold fonts for an OH_Drawing_Font object.
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
* @param OH_Drawing_Font Indicates the pointer to an OH_Drawing_Font object.
* @param isFakeBoldText Indicates whether to enable to increase stroke width.
* @since 11
* @version 1.0
*/
void OH_Drawing_FontSetFakeBoldText(OH_Drawing_Font*, bool isFakeBoldText);
/**
* @brief Destroys an OH_Drawing_Font object and reclaims the memory occupied by the object.
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
* @param OH_Drawing_Font Indicates the pointer to an OH_Drawing_Font object.
* @since 11
* @version 1.0
*/
void OH_Drawing_FontDestroy(OH_Drawing_Font*);
/**
* @brief Defines a run, supplies storage for the metrics of an SkFont.
*
* @since 12
* @version 1.0
*/
typedef struct {
/** storage for top in font metrics */
float top;
/** storage for ascent in font metrics */
float ascent;
/** storage for descent in font metrics */
float descent;
/** storage for bottom in font metrics */
float bottom;
/** storage for leading in font metrics */
float leading;
} OH_Drawing_Font_Metrics;
/**
* @brief Obtains the metrics of a font.
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
* @param OH_Drawing_Font Indicates the pointer to an OH_Drawing_Font object.
* @param OH_Drawing_Font_Metrics Indicates the pointer to an OH_Drawing_Font_Metrics object.
* @return Returns a float variable that recommended spacing between lines.
* Returns -1 if OH_Drawing_Font or OH_Drawing_Font_Metrics is nullptr.
* @since 12
* @version 1.0
*/
float OH_Drawing_FontGetMetrics(OH_Drawing_Font*, OH_Drawing_Font_Metrics*);
#ifdef __cplusplus
}
#endif
/** @} */
#endif