17777dab0Sopenharmony_ci/* 27777dab0Sopenharmony_ci * Copyright (c) 2023-2024 Huawei Device Co., Ltd. 37777dab0Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 47777dab0Sopenharmony_ci * you may not use this file except in compliance with the License. 57777dab0Sopenharmony_ci * You may obtain a copy of the License at 67777dab0Sopenharmony_ci * 77777dab0Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 87777dab0Sopenharmony_ci * 97777dab0Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 107777dab0Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 117777dab0Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 127777dab0Sopenharmony_ci * See the License for the specific language governing permissions and 137777dab0Sopenharmony_ci * limitations under the License. 147777dab0Sopenharmony_ci */ 157777dab0Sopenharmony_ci 167777dab0Sopenharmony_ci#ifndef C_INCLUDE_DRAWING_FONT_H 177777dab0Sopenharmony_ci#define C_INCLUDE_DRAWING_FONT_H 187777dab0Sopenharmony_ci 197777dab0Sopenharmony_ci/** 207777dab0Sopenharmony_ci * @addtogroup Drawing 217777dab0Sopenharmony_ci * @{ 227777dab0Sopenharmony_ci * 237777dab0Sopenharmony_ci * @brief Provides functions such as 2D graphics rendering, text drawing, and image display. 247777dab0Sopenharmony_ci * 257777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 267777dab0Sopenharmony_ci * 277777dab0Sopenharmony_ci * @since 11 287777dab0Sopenharmony_ci * @version 1.0 297777dab0Sopenharmony_ci */ 307777dab0Sopenharmony_ci 317777dab0Sopenharmony_ci/** 327777dab0Sopenharmony_ci * @file drawing_font.h 337777dab0Sopenharmony_ci * 347777dab0Sopenharmony_ci * @brief Declares functions related to the <b>font</b> object in the drawing module. 357777dab0Sopenharmony_ci * 367777dab0Sopenharmony_ci * @kit ArkGraphics2D 377777dab0Sopenharmony_ci * @library libnative_drawing.so 387777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 397777dab0Sopenharmony_ci * @since 11 407777dab0Sopenharmony_ci * @version 1.0 417777dab0Sopenharmony_ci */ 427777dab0Sopenharmony_ci 437777dab0Sopenharmony_ci#include "drawing_error_code.h" 447777dab0Sopenharmony_ci#include "drawing_types.h" 457777dab0Sopenharmony_ci 467777dab0Sopenharmony_ci#ifdef __cplusplus 477777dab0Sopenharmony_ciextern "C" { 487777dab0Sopenharmony_ci#endif 497777dab0Sopenharmony_ci 507777dab0Sopenharmony_ci/** 517777dab0Sopenharmony_ci * @brief Creates an <b>OH_Drawing_Font</b> object. 527777dab0Sopenharmony_ci * 537777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 547777dab0Sopenharmony_ci * @return Returns the pointer to the <b>OH_Drawing_Font</b> object created. 557777dab0Sopenharmony_ci * @since 11 567777dab0Sopenharmony_ci * @version 1.0 577777dab0Sopenharmony_ci */ 587777dab0Sopenharmony_ciOH_Drawing_Font* OH_Drawing_FontCreate(void); 597777dab0Sopenharmony_ci 607777dab0Sopenharmony_ci/** 617777dab0Sopenharmony_ci * @brief Enumerates font hinting pattern. 627777dab0Sopenharmony_ci * 637777dab0Sopenharmony_ci * @since 12 647777dab0Sopenharmony_ci * @version 1.0 657777dab0Sopenharmony_ci */ 667777dab0Sopenharmony_citypedef enum { 677777dab0Sopenharmony_ci /** glyph outlines unchanged */ 687777dab0Sopenharmony_ci FONT_HINTING_NONE, 697777dab0Sopenharmony_ci /** minimal modification to improve contrast */ 707777dab0Sopenharmony_ci FONT_HINTING_SLIGHT, 717777dab0Sopenharmony_ci /** glyph outlines modified to improve contrast */ 727777dab0Sopenharmony_ci FONT_HINTING_NORMAL, 737777dab0Sopenharmony_ci /** modifies glyph outlines for maximum contrast */ 747777dab0Sopenharmony_ci FONT_HINTING_FULL, 757777dab0Sopenharmony_ci} OH_Drawing_FontHinting; 767777dab0Sopenharmony_ci 777777dab0Sopenharmony_ci/** 787777dab0Sopenharmony_ci * @brief Enumerates font edging effect. 797777dab0Sopenharmony_ci * 807777dab0Sopenharmony_ci * @since 12 817777dab0Sopenharmony_ci * @version 1.0 827777dab0Sopenharmony_ci */ 837777dab0Sopenharmony_citypedef enum { 847777dab0Sopenharmony_ci /** no transparent pixels on glyph edges */ 857777dab0Sopenharmony_ci FONT_EDGING_ALIAS, 867777dab0Sopenharmony_ci /** may have transparent pixels on glyph edges */ 877777dab0Sopenharmony_ci FONT_EDGING_ANTI_ALIAS, 887777dab0Sopenharmony_ci /** glyph positioned in pixel using transparency */ 897777dab0Sopenharmony_ci FONT_EDGING_SUBPIXEL_ANTI_ALIAS, 907777dab0Sopenharmony_ci} OH_Drawing_FontEdging; 917777dab0Sopenharmony_ci 927777dab0Sopenharmony_ci/** 937777dab0Sopenharmony_ci * @brief Sets whether the font baselines and pixels alignment when the transformation matrix is axis aligned. 947777dab0Sopenharmony_ci * 957777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 967777dab0Sopenharmony_ci * @param OH_Drawing_Font Indicates the pointer to an <b>OH_Drawing_Font</b> object. 977777dab0Sopenharmony_ci * @param baselineSnap Indicates whether the font baselines and pixels alignment. 987777dab0Sopenharmony_ci * @since 12 997777dab0Sopenharmony_ci * @version 1.0 1007777dab0Sopenharmony_ci */ 1017777dab0Sopenharmony_civoid OH_Drawing_FontSetBaselineSnap(OH_Drawing_Font*, bool baselineSnap); 1027777dab0Sopenharmony_ci 1037777dab0Sopenharmony_ci/** 1047777dab0Sopenharmony_ci * @brief Gets whether the font baselines and pixels alignment when the transformation matrix is axis aligned. 1057777dab0Sopenharmony_ci * 1067777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1077777dab0Sopenharmony_ci * @param OH_Drawing_Font Indicates the pointer to an <b>OH_Drawing_Font</b> object. 1087777dab0Sopenharmony_ci * @return Returns <b>true</b> if the font baselines and pixels alignment; returns <b>false</b> otherwise. 1097777dab0Sopenharmony_ci * @since 12 1107777dab0Sopenharmony_ci * @version 1.0 1117777dab0Sopenharmony_ci */ 1127777dab0Sopenharmony_cibool OH_Drawing_FontIsBaselineSnap(const OH_Drawing_Font*); 1137777dab0Sopenharmony_ci 1147777dab0Sopenharmony_ci/** 1157777dab0Sopenharmony_ci * @brief Sets whether the font uses sub-pixel rendering. 1167777dab0Sopenharmony_ci * 1177777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1187777dab0Sopenharmony_ci * @param OH_Drawing_Font Indicates the pointer to an <b>OH_Drawing_Font</b> object. 1197777dab0Sopenharmony_ci * @param isSubpixel Indicates whether the font uses sub-pixel rendering. 1207777dab0Sopenharmony_ci * @since 12 1217777dab0Sopenharmony_ci * @version 1.0 1227777dab0Sopenharmony_ci */ 1237777dab0Sopenharmony_civoid OH_Drawing_FontSetSubpixel(OH_Drawing_Font*, bool isSubpixel); 1247777dab0Sopenharmony_ci 1257777dab0Sopenharmony_ci/** 1267777dab0Sopenharmony_ci * @brief Gets whether the font uses sub-pixel rendering. 1277777dab0Sopenharmony_ci * 1287777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1297777dab0Sopenharmony_ci * @param OH_Drawing_Font Indicates the pointer to an <b>OH_Drawing_Font</b> object. 1307777dab0Sopenharmony_ci * @return Returns <b>true</b> if the font uses sub-pixel rendering; returns <b>false</b> otherwise. 1317777dab0Sopenharmony_ci * @since 12 1327777dab0Sopenharmony_ci * @version 1.0 1337777dab0Sopenharmony_ci */ 1347777dab0Sopenharmony_cibool OH_Drawing_FontIsSubpixel(const OH_Drawing_Font*); 1357777dab0Sopenharmony_ci 1367777dab0Sopenharmony_ci/** 1377777dab0Sopenharmony_ci * @brief Sets whether the font outline is automatically adjusted. 1387777dab0Sopenharmony_ci * 1397777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1407777dab0Sopenharmony_ci * @param OH_Drawing_Font Indicates the pointer to an <b>OH_Drawing_Font</b> object. 1417777dab0Sopenharmony_ci * @param isForceAutoHinting Indicates whether the font outline is automatically adjusted. 1427777dab0Sopenharmony_ci * @since 12 1437777dab0Sopenharmony_ci * @version 1.0 1447777dab0Sopenharmony_ci */ 1457777dab0Sopenharmony_civoid OH_Drawing_FontSetForceAutoHinting(OH_Drawing_Font*, bool isForceAutoHinting); 1467777dab0Sopenharmony_ci 1477777dab0Sopenharmony_ci/** 1487777dab0Sopenharmony_ci * @brief Gets whether the font outline is automatically adjusted. 1497777dab0Sopenharmony_ci * 1507777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1517777dab0Sopenharmony_ci * @param OH_Drawing_Font Indicates the pointer to an <b>OH_Drawing_Font</b> object. 1527777dab0Sopenharmony_ci * @return Returns <b>true</b> if the font outline is automatically adjusted; returns <b>false</b> otherwise. 1537777dab0Sopenharmony_ci * @since 12 1547777dab0Sopenharmony_ci * @version 1.0 1557777dab0Sopenharmony_ci */ 1567777dab0Sopenharmony_cibool OH_Drawing_FontIsForceAutoHinting(const OH_Drawing_Font*); 1577777dab0Sopenharmony_ci 1587777dab0Sopenharmony_ci/** 1597777dab0Sopenharmony_ci * @brief Sets an <b>OH_Drawing_Typeface</b> object for an <b>OH_Drawing_Font</b> object. 1607777dab0Sopenharmony_ci * 1617777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1627777dab0Sopenharmony_ci * @param OH_Drawing_Font Indicates the pointer to an <b>OH_Drawing_Font</b> object. 1637777dab0Sopenharmony_ci * @param OH_Drawing_Typeface Indicates the pointer to an <b>OH_Drawing_Typeface</b> object. 1647777dab0Sopenharmony_ci * @since 11 1657777dab0Sopenharmony_ci * @version 1.0 1667777dab0Sopenharmony_ci */ 1677777dab0Sopenharmony_civoid OH_Drawing_FontSetTypeface(OH_Drawing_Font*, OH_Drawing_Typeface*); 1687777dab0Sopenharmony_ci 1697777dab0Sopenharmony_ci/** 1707777dab0Sopenharmony_ci * @brief Gets an <b>OH_Drawing_Typeface</b> object from the <b>OH_Drawing_Typeface</b> object. 1717777dab0Sopenharmony_ci * 1727777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1737777dab0Sopenharmony_ci * @param OH_Drawing_Font Indicates the pointer to an <b>OH_Drawing_Font</b> object. 1747777dab0Sopenharmony_ci * @return OH_Drawing_Typeface Indicates the pointer to an <b>OH_Drawing_Typeface</b> object. 1757777dab0Sopenharmony_ci * @since 12 1767777dab0Sopenharmony_ci * @version 1.0 1777777dab0Sopenharmony_ci */ 1787777dab0Sopenharmony_ciOH_Drawing_Typeface* OH_Drawing_FontGetTypeface(OH_Drawing_Font*); 1797777dab0Sopenharmony_ci 1807777dab0Sopenharmony_ci/** 1817777dab0Sopenharmony_ci * @brief Sets text size for an <b>OH_Drawing_Font</b> object. 1827777dab0Sopenharmony_ci * 1837777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1847777dab0Sopenharmony_ci * @param OH_Drawing_Font Indicates the pointer to an <b>OH_Drawing_Font</b> object. 1857777dab0Sopenharmony_ci * @param textSize Indicates the text size. 1867777dab0Sopenharmony_ci * @since 11 1877777dab0Sopenharmony_ci * @version 1.0 1887777dab0Sopenharmony_ci */ 1897777dab0Sopenharmony_civoid OH_Drawing_FontSetTextSize(OH_Drawing_Font*, float textSize); 1907777dab0Sopenharmony_ci 1917777dab0Sopenharmony_ci/** 1927777dab0Sopenharmony_ci * @brief Gets text size for an <b>OH_Drawing_Font</b> object. 1937777dab0Sopenharmony_ci * 1947777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1957777dab0Sopenharmony_ci * @param OH_Drawing_Font Indicates the pointer to an <b>OH_Drawing_Font</b> object. 1967777dab0Sopenharmony_ci * @return Returns the size of text. 1977777dab0Sopenharmony_ci * @since 12 1987777dab0Sopenharmony_ci * @version 1.0 1997777dab0Sopenharmony_ci */ 2007777dab0Sopenharmony_cifloat OH_Drawing_FontGetTextSize(const OH_Drawing_Font*); 2017777dab0Sopenharmony_ci 2027777dab0Sopenharmony_ci/** 2037777dab0Sopenharmony_ci * @brief Calculate number of glyphs represented by text. 2047777dab0Sopenharmony_ci * 2057777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 2067777dab0Sopenharmony_ci * @param OH_Drawing_Font Indicates the pointer to an <b>OH_Drawing_Font</b> object. 2077777dab0Sopenharmony_ci * @param text Indicates the character storage encoded with text encoding. 2087777dab0Sopenharmony_ci * @param byteLength Indicates the text length in bytes. 2097777dab0Sopenharmony_ci * @param encoding Indicates the text encoding. 2107777dab0Sopenharmony_ci * @since 12 2117777dab0Sopenharmony_ci * @version 1.0 2127777dab0Sopenharmony_ci */ 2137777dab0Sopenharmony_ciint OH_Drawing_FontCountText(OH_Drawing_Font*, const void* text, size_t byteLength, 2147777dab0Sopenharmony_ci OH_Drawing_TextEncoding encoding); 2157777dab0Sopenharmony_ci 2167777dab0Sopenharmony_ci/** 2177777dab0Sopenharmony_ci * @brief Converts text into glyph indices. 2187777dab0Sopenharmony_ci * 2197777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 2207777dab0Sopenharmony_ci * @param OH_Drawing_Font Indicates the pointer to an <b>OH_Drawing_Font</b> object. 2217777dab0Sopenharmony_ci * @param text Indicates the character storage encoded with text encoding. 2227777dab0Sopenharmony_ci * @param byteLength Indicates the text length in bytes. 2237777dab0Sopenharmony_ci * @param encoding Indicates the text encoding. 2247777dab0Sopenharmony_ci * @param glyphs Indicates the storage for glyph indices. 2257777dab0Sopenharmony_ci * @param maxGlyphCount Indicates the storage capacity. 2267777dab0Sopenharmony_ci * @return Returns the number of glyph indices represented by text. 2277777dab0Sopenharmony_ci * @since 12 2287777dab0Sopenharmony_ci * @version 1.0 2297777dab0Sopenharmony_ci */ 2307777dab0Sopenharmony_ciuint32_t OH_Drawing_FontTextToGlyphs(const OH_Drawing_Font*, const void* text, uint32_t byteLength, 2317777dab0Sopenharmony_ci OH_Drawing_TextEncoding encoding, uint16_t* glyphs, int maxGlyphCount); 2327777dab0Sopenharmony_ci 2337777dab0Sopenharmony_ci/** 2347777dab0Sopenharmony_ci * @brief Retrieves the advance for each glyph in glyphs. 2357777dab0Sopenharmony_ci * 2367777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 2377777dab0Sopenharmony_ci * @param OH_Drawing_Font Indicates the pointer to an <b>OH_Drawing_Font</b> object. 2387777dab0Sopenharmony_ci * @param glyphs Indicates the array of glyph indices to be measured. 2397777dab0Sopenharmony_ci * @param count Indicates the number of glyphs. 2407777dab0Sopenharmony_ci * @param widths Indicates the text advances for each glyph returned to the caller. 2417777dab0Sopenharmony_ci * @since 12 2427777dab0Sopenharmony_ci * @version 1.0 2437777dab0Sopenharmony_ci */ 2447777dab0Sopenharmony_civoid OH_Drawing_FontGetWidths(const OH_Drawing_Font*, const uint16_t* glyphs, int count, float* widths); 2457777dab0Sopenharmony_ci 2467777dab0Sopenharmony_ci/** 2477777dab0Sopenharmony_ci * @brief Measures the width of a single character. 2487777dab0Sopenharmony_ci * 2497777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 2507777dab0Sopenharmony_ci * @param font Indicates the pointer to an <b>OH_Drawing_Font</b> object. 2517777dab0Sopenharmony_ci * @param str Indicates the single character encoded in UTF-8. 2527777dab0Sopenharmony_ci * @param textWidth Indicates the width of the single character. 2537777dab0Sopenharmony_ci * @return Returns the error code. 2547777dab0Sopenharmony_ci * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. 2557777dab0Sopenharmony_ci * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if any of font, str 2567777dab0Sopenharmony_ci * and textWidth is nullptr or strlen(str) is 0. 2577777dab0Sopenharmony_ci * @since 12 2587777dab0Sopenharmony_ci * @version 1.0 2597777dab0Sopenharmony_ci */ 2607777dab0Sopenharmony_ciOH_Drawing_ErrorCode OH_Drawing_FontMeasureSingleCharacter(const OH_Drawing_Font* font, const char* str, 2617777dab0Sopenharmony_ci float* textWidth); 2627777dab0Sopenharmony_ci 2637777dab0Sopenharmony_ci/** 2647777dab0Sopenharmony_ci * @brief Measures the width of text. 2657777dab0Sopenharmony_ci * 2667777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 2677777dab0Sopenharmony_ci * @param font Indicates the pointer to an <b>OH_Drawing_Font</b> object. 2687777dab0Sopenharmony_ci * @param text Indicates the character storage encoded with text encoding. 2697777dab0Sopenharmony_ci * @param byteLength Indicates the text length in bytes. 2707777dab0Sopenharmony_ci * @param encoding Indicates the text encoding. 2717777dab0Sopenharmony_ci * @param bounds Gets the bounding box relative to (0, 0) if not nullptr. 2727777dab0Sopenharmony_ci * @param textWidth Indicates the width of text. 2737777dab0Sopenharmony_ci * @return Returns the error code. 2747777dab0Sopenharmony_ci * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. 2757777dab0Sopenharmony_ci * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if any of font, text 2767777dab0Sopenharmony_ci * and textWidth is nullptr or byteLength is 0. 2777777dab0Sopenharmony_ci * @since 12 2787777dab0Sopenharmony_ci * @version 1.0 2797777dab0Sopenharmony_ci */ 2807777dab0Sopenharmony_ciOH_Drawing_ErrorCode OH_Drawing_FontMeasureText(const OH_Drawing_Font* font, const void* text, size_t byteLength, 2817777dab0Sopenharmony_ci OH_Drawing_TextEncoding encoding, OH_Drawing_Rect* bounds, float* textWidth); 2827777dab0Sopenharmony_ci 2837777dab0Sopenharmony_ci/** 2847777dab0Sopenharmony_ci * @brief Enables or disables linearly scalable font for an <b>OH_Drawing_Font</b> object. 2857777dab0Sopenharmony_ci * 2867777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 2877777dab0Sopenharmony_ci * @param OH_Drawing_Font Indicates the pointer to an <b>OH_Drawing_Font</b> object. 2887777dab0Sopenharmony_ci * @param isLinearText Indicates whether to enable linearly scalable font. 2897777dab0Sopenharmony_ci * @since 11 2907777dab0Sopenharmony_ci * @version 1.0 2917777dab0Sopenharmony_ci */ 2927777dab0Sopenharmony_civoid OH_Drawing_FontSetLinearText(OH_Drawing_Font*, bool isLinearText); 2937777dab0Sopenharmony_ci 2947777dab0Sopenharmony_ci/** 2957777dab0Sopenharmony_ci * @brief Gets whether the font is linearly scalable. 2967777dab0Sopenharmony_ci * 2977777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 2987777dab0Sopenharmony_ci * @param OH_Drawing_Font Indicates the pointer to an <b>OH_Drawing_Font</b> object. 2997777dab0Sopenharmony_ci * @return Returns <b>true</b> if the font is linearly scalable; returns <b>false</b> otherwise. 3007777dab0Sopenharmony_ci * @since 12 3017777dab0Sopenharmony_ci * @version 1.0 3027777dab0Sopenharmony_ci */ 3037777dab0Sopenharmony_cibool OH_Drawing_FontIsLinearText(const OH_Drawing_Font*); 3047777dab0Sopenharmony_ci 3057777dab0Sopenharmony_ci/** 3067777dab0Sopenharmony_ci * @brief Sets text skew on x-axis for an <b>OH_Drawing_Font</b> object. 3077777dab0Sopenharmony_ci * 3087777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 3097777dab0Sopenharmony_ci * @param OH_Drawing_Font Indicates the pointer to an <b>OH_Drawing_Font</b> object. 3107777dab0Sopenharmony_ci * @param skewX Indicates the additional shear on x-axis relative to y-axis. 3117777dab0Sopenharmony_ci * @since 11 3127777dab0Sopenharmony_ci * @version 1.0 3137777dab0Sopenharmony_ci */ 3147777dab0Sopenharmony_civoid OH_Drawing_FontSetTextSkewX(OH_Drawing_Font*, float skewX); 3157777dab0Sopenharmony_ci 3167777dab0Sopenharmony_ci/** 3177777dab0Sopenharmony_ci * @brief Gets text skew on x-axis for an <b>OH_Drawing_Font</b> object. 3187777dab0Sopenharmony_ci * 3197777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 3207777dab0Sopenharmony_ci * @param OH_Drawing_Font Indicates the pointer to an <b>OH_Drawing_Font</b> object. 3217777dab0Sopenharmony_ci * @return Returns additional skew on x-axis relative to y-axis. 3227777dab0Sopenharmony_ci * @since 12 3237777dab0Sopenharmony_ci * @version 1.0 3247777dab0Sopenharmony_ci */ 3257777dab0Sopenharmony_cifloat OH_Drawing_FontGetTextSkewX(const OH_Drawing_Font*); 3267777dab0Sopenharmony_ci 3277777dab0Sopenharmony_ci/** 3287777dab0Sopenharmony_ci * @brief Enables or disables to increase stroke width to approximate bold fonts for an <b>OH_Drawing_Font</b> object. 3297777dab0Sopenharmony_ci * 3307777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 3317777dab0Sopenharmony_ci * @param OH_Drawing_Font Indicates the pointer to an <b>OH_Drawing_Font</b> object. 3327777dab0Sopenharmony_ci * @param isFakeBoldText Indicates whether to enable to increase stroke width. 3337777dab0Sopenharmony_ci * @since 11 3347777dab0Sopenharmony_ci * @version 1.0 3357777dab0Sopenharmony_ci */ 3367777dab0Sopenharmony_civoid OH_Drawing_FontSetFakeBoldText(OH_Drawing_Font*, bool isFakeBoldText); 3377777dab0Sopenharmony_ci 3387777dab0Sopenharmony_ci/** 3397777dab0Sopenharmony_ci * @brief Gets whether to increase the stroke width to approximate bold fonts. 3407777dab0Sopenharmony_ci * 3417777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 3427777dab0Sopenharmony_ci * @param OH_Drawing_Font Indicates the pointer to an <b>OH_Drawing_Font</b> object. 3437777dab0Sopenharmony_ci * @return Returns <b>true</b> to increase the stroke width to approximate bold fonts; returns <b>false</b> otherwise. 3447777dab0Sopenharmony_ci * @since 12 3457777dab0Sopenharmony_ci * @version 1.0 3467777dab0Sopenharmony_ci */ 3477777dab0Sopenharmony_cibool OH_Drawing_FontIsFakeBoldText(const OH_Drawing_Font*); 3487777dab0Sopenharmony_ci 3497777dab0Sopenharmony_ci/** 3507777dab0Sopenharmony_ci * @brief Sets text scale on x-axis for an <b>OH_Drawing_Font</b> object. 3517777dab0Sopenharmony_ci * 3527777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 3537777dab0Sopenharmony_ci * @param OH_Drawing_Font Indicates the pointer to an <b>OH_Drawing_Font</b> object. 3547777dab0Sopenharmony_ci * @param scaleX Indicates the text horizontal scale. 3557777dab0Sopenharmony_ci * @since 12 3567777dab0Sopenharmony_ci * @version 1.0 3577777dab0Sopenharmony_ci */ 3587777dab0Sopenharmony_civoid OH_Drawing_FontSetScaleX(OH_Drawing_Font*, float scaleX); 3597777dab0Sopenharmony_ci 3607777dab0Sopenharmony_ci/** 3617777dab0Sopenharmony_ci * @brief Gets text scale on x-axis from an <b>OH_Drawing_Font</b> object. 3627777dab0Sopenharmony_ci * 3637777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 3647777dab0Sopenharmony_ci * @param OH_Drawing_Font Indicates the pointer to an <b>OH_Drawing_Font</b> object. 3657777dab0Sopenharmony_ci * @return Returns text horizontal scale on x-axis. 3667777dab0Sopenharmony_ci * @since 12 3677777dab0Sopenharmony_ci * @version 1.0 3687777dab0Sopenharmony_ci */ 3697777dab0Sopenharmony_cifloat OH_Drawing_FontGetScaleX(const OH_Drawing_Font*); 3707777dab0Sopenharmony_ci 3717777dab0Sopenharmony_ci/** 3727777dab0Sopenharmony_ci * @brief Sets hinting pattern for an <b>OH_Drawing_Font</b> object. 3737777dab0Sopenharmony_ci * 3747777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 3757777dab0Sopenharmony_ci * @param OH_Drawing_Font Indicates the pointer to an <b>OH_Drawing_Font</b> object. 3767777dab0Sopenharmony_ci * @param OH_Drawing_FontHinting Indicates the font hinting pattern. 3777777dab0Sopenharmony_ci * @since 12 3787777dab0Sopenharmony_ci * @version 1.0 3797777dab0Sopenharmony_ci */ 3807777dab0Sopenharmony_civoid OH_Drawing_FontSetHinting(OH_Drawing_Font*, OH_Drawing_FontHinting); 3817777dab0Sopenharmony_ci 3827777dab0Sopenharmony_ci/** 3837777dab0Sopenharmony_ci * @brief Gets hinting pattern from an <b>OH_Drawing_Font</b> object. 3847777dab0Sopenharmony_ci * 3857777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 3867777dab0Sopenharmony_ci * @param OH_Drawing_Font Indicates the pointer to an <b>OH_Drawing_Font</b> object. 3877777dab0Sopenharmony_ci * @return Returns the font hinting pattern. 3887777dab0Sopenharmony_ci * @since 12 3897777dab0Sopenharmony_ci * @version 1.0 3907777dab0Sopenharmony_ci */ 3917777dab0Sopenharmony_ciOH_Drawing_FontHinting OH_Drawing_FontGetHinting(const OH_Drawing_Font*); 3927777dab0Sopenharmony_ci 3937777dab0Sopenharmony_ci/** 3947777dab0Sopenharmony_ci * @brief Sets whether to use bitmaps instead of outlines in the <b>OH_Drawing_Font</b> object. 3957777dab0Sopenharmony_ci * 3967777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 3977777dab0Sopenharmony_ci * @param OH_Drawing_Font Indicates the pointer to an <b>OH_Drawing_Font</b> object. 3987777dab0Sopenharmony_ci * @param isEmbeddedBitmaps Indicates whether to use bitmaps instead of outlines. 3997777dab0Sopenharmony_ci * @since 12 4007777dab0Sopenharmony_ci * @version 1.0 4017777dab0Sopenharmony_ci */ 4027777dab0Sopenharmony_civoid OH_Drawing_FontSetEmbeddedBitmaps(OH_Drawing_Font*, bool isEmbeddedBitmaps); 4037777dab0Sopenharmony_ci 4047777dab0Sopenharmony_ci/** 4057777dab0Sopenharmony_ci * @brief Gets whether to use bitmaps instead of outlines in the <b>OH_Drawing_Font</b> object. 4067777dab0Sopenharmony_ci * 4077777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 4087777dab0Sopenharmony_ci * @param OH_Drawing_Font Indicates the pointer to an <b>OH_Drawing_Font</b> object. 4097777dab0Sopenharmony_ci * @return Returns <b>true</b> if using bitmaps instead of outlines; returns <b>false</b> otherwise. 4107777dab0Sopenharmony_ci * @since 12 4117777dab0Sopenharmony_ci * @version 1.0 4127777dab0Sopenharmony_ci */ 4137777dab0Sopenharmony_cibool OH_Drawing_FontIsEmbeddedBitmaps(const OH_Drawing_Font*); 4147777dab0Sopenharmony_ci 4157777dab0Sopenharmony_ci/** 4167777dab0Sopenharmony_ci * @brief Sets the font edging effect for an <b>OH_Drawing_Font</b> object. 4177777dab0Sopenharmony_ci * 4187777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 4197777dab0Sopenharmony_ci * @param OH_Drawing_Font Indicates the pointer to an <b>OH_Drawing_Font</b> object. 4207777dab0Sopenharmony_ci * @param OH_Drawing_FontEdging Indicates the font edging effect. 4217777dab0Sopenharmony_ci * @since 12 4227777dab0Sopenharmony_ci * @version 1.0 4237777dab0Sopenharmony_ci */ 4247777dab0Sopenharmony_civoid OH_Drawing_FontSetEdging(OH_Drawing_Font*, OH_Drawing_FontEdging); 4257777dab0Sopenharmony_ci 4267777dab0Sopenharmony_ci/** 4277777dab0Sopenharmony_ci * @brief Gets the font edging effect from an <b>OH_Drawing_Font</b> object. 4287777dab0Sopenharmony_ci * 4297777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 4307777dab0Sopenharmony_ci * @param OH_Drawing_Font Indicates the pointer to an <b>OH_Drawing_Font</b> object. 4317777dab0Sopenharmony_ci * @return Returns the font edging effect. 4327777dab0Sopenharmony_ci * @since 12 4337777dab0Sopenharmony_ci * @version 1.0 4347777dab0Sopenharmony_ci */ 4357777dab0Sopenharmony_ciOH_Drawing_FontEdging OH_Drawing_FontGetEdging(const OH_Drawing_Font*); 4367777dab0Sopenharmony_ci 4377777dab0Sopenharmony_ci/** 4387777dab0Sopenharmony_ci * @brief Destroys an <b>OH_Drawing_Font</b> object and reclaims the memory occupied by the object. 4397777dab0Sopenharmony_ci * 4407777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 4417777dab0Sopenharmony_ci * @param OH_Drawing_Font Indicates the pointer to an <b>OH_Drawing_Font</b> object. 4427777dab0Sopenharmony_ci * @since 11 4437777dab0Sopenharmony_ci * @version 1.0 4447777dab0Sopenharmony_ci */ 4457777dab0Sopenharmony_civoid OH_Drawing_FontDestroy(OH_Drawing_Font*); 4467777dab0Sopenharmony_ci 4477777dab0Sopenharmony_ci/** 4487777dab0Sopenharmony_ci * @brief Defines a run, supplies storage for the metrics of an <b>OH_Drawing_Font</b>. 4497777dab0Sopenharmony_ci * 4507777dab0Sopenharmony_ci * @since 12 4517777dab0Sopenharmony_ci * @version 1.0 4527777dab0Sopenharmony_ci */ 4537777dab0Sopenharmony_citypedef struct OH_Drawing_Font_Metrics { 4547777dab0Sopenharmony_ci /** Indicating which metrics are valid */ 4557777dab0Sopenharmony_ci uint32_t flags; 4567777dab0Sopenharmony_ci /** storage for top in font metrics */ 4577777dab0Sopenharmony_ci float top; 4587777dab0Sopenharmony_ci /** storage for ascent in font metrics */ 4597777dab0Sopenharmony_ci float ascent; 4607777dab0Sopenharmony_ci /** storage for descent in font metrics */ 4617777dab0Sopenharmony_ci float descent; 4627777dab0Sopenharmony_ci /** storage for bottom in font metrics */ 4637777dab0Sopenharmony_ci float bottom; 4647777dab0Sopenharmony_ci /** storage for leading in font metrics */ 4657777dab0Sopenharmony_ci float leading; 4667777dab0Sopenharmony_ci /** Average character width, zero if unknown */ 4677777dab0Sopenharmony_ci float avgCharWidth; 4687777dab0Sopenharmony_ci /** Maximum character width, zero if unknown */ 4697777dab0Sopenharmony_ci float maxCharWidth; 4707777dab0Sopenharmony_ci /** Greatest extent to left of origin of any glyph bounding box, typically negative; deprecated with variable fonts */ 4717777dab0Sopenharmony_ci float xMin; 4727777dab0Sopenharmony_ci /** Greatest extent to right of origin of any glyph bounding box, typically positive; deprecated with variable fonts */ 4737777dab0Sopenharmony_ci float xMax; 4747777dab0Sopenharmony_ci /** Height of lower-case letter, zero if unknown, typically negative */ 4757777dab0Sopenharmony_ci float xHeight; 4767777dab0Sopenharmony_ci /** Height of an upper-case letter, zero if unknown, typically negative */ 4777777dab0Sopenharmony_ci float capHeight; 4787777dab0Sopenharmony_ci /** @brief Underline thickness */ 4797777dab0Sopenharmony_ci float underlineThickness; 4807777dab0Sopenharmony_ci /** Distance from baseline to top of stroke, typically positive */ 4817777dab0Sopenharmony_ci float underlinePosition; 4827777dab0Sopenharmony_ci /** Strikeout thickness */ 4837777dab0Sopenharmony_ci float strikeoutThickness; 4847777dab0Sopenharmony_ci /** Distance from baseline to bottom of stroke, typically negative */ 4857777dab0Sopenharmony_ci float strikeoutPosition; 4867777dab0Sopenharmony_ci} OH_Drawing_Font_Metrics; 4877777dab0Sopenharmony_ci 4887777dab0Sopenharmony_ci/** 4897777dab0Sopenharmony_ci * @brief Obtains the metrics of a font. 4907777dab0Sopenharmony_ci * 4917777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 4927777dab0Sopenharmony_ci * @param OH_Drawing_Font Indicates the pointer to an <b>OH_Drawing_Font</b> object. 4937777dab0Sopenharmony_ci * @param OH_Drawing_Font_Metrics Indicates the pointer to an <b>OH_Drawing_Font_Metrics</b> object. 4947777dab0Sopenharmony_ci * @return Returns a float variable that recommended spacing between lines. 4957777dab0Sopenharmony_ci * @since 12 4967777dab0Sopenharmony_ci * @version 1.0 4977777dab0Sopenharmony_ci */ 4987777dab0Sopenharmony_cifloat OH_Drawing_FontGetMetrics(OH_Drawing_Font*, OH_Drawing_Font_Metrics*); 4997777dab0Sopenharmony_ci 5007777dab0Sopenharmony_ci/** 5017777dab0Sopenharmony_ci * @brief Retrieves the bound rect for each glyph in glyph array. 5027777dab0Sopenharmony_ci * 5037777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 5047777dab0Sopenharmony_ci * @param font Indicates the pointer to an <b>OH_Drawing_Font</b> object. 5057777dab0Sopenharmony_ci * @param glyphs Indicates the array of glyph indices to be measured. 5067777dab0Sopenharmony_ci * @param count Indicates the number of glyphs. 5077777dab0Sopenharmony_ci * @param bounds The bound rect array for each glyph, returned to the caller. 5087777dab0Sopenharmony_ci * @return Returns the error code. 5097777dab0Sopenharmony_ci * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. 5107777dab0Sopenharmony_ci * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if any of font, glyphs 5117777dab0Sopenharmony_ci * and bounds is nullptr or count is 0. 5127777dab0Sopenharmony_ci * @since 14 5137777dab0Sopenharmony_ci * @version 1.0 5147777dab0Sopenharmony_ci */ 5157777dab0Sopenharmony_ciOH_Drawing_ErrorCode OH_Drawing_FontGetBounds(const OH_Drawing_Font* font, const uint16_t* glyphs, uint32_t count, 5167777dab0Sopenharmony_ci OH_Drawing_Array* bounds); 5177777dab0Sopenharmony_ci 5187777dab0Sopenharmony_ci/** 5197777dab0Sopenharmony_ci * @brief Retrieves the path for specified Glyph. 5207777dab0Sopenharmony_ci * 5217777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 5227777dab0Sopenharmony_ci * @param font Indicates the pointer to an <b>OH_Drawing_Font</b> object. 5237777dab0Sopenharmony_ci * @param glyph glyph index to be obtained. 5247777dab0Sopenharmony_ci * @param path The path object, returned to the caller. 5257777dab0Sopenharmony_ci * @return Returns the error code. 5267777dab0Sopenharmony_ci * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. 5277777dab0Sopenharmony_ci * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if any of font, path 5287777dab0Sopenharmony_ci * is nullptr or glyph not exist. 5297777dab0Sopenharmony_ci * @since 14 5307777dab0Sopenharmony_ci * @version 1.0 5317777dab0Sopenharmony_ci */ 5327777dab0Sopenharmony_ciOH_Drawing_ErrorCode OH_Drawing_FontGetPathForGlyph(const OH_Drawing_Font* font, uint16_t glyph, 5337777dab0Sopenharmony_ci OH_Drawing_Path* path); 5347777dab0Sopenharmony_ci 5357777dab0Sopenharmony_ci/** 5367777dab0Sopenharmony_ci * @brief Get the text outline path. 5377777dab0Sopenharmony_ci * 5387777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 5397777dab0Sopenharmony_ci * @param font Indicates the pointer to an <b>OH_Drawing_Font</b> object. 5407777dab0Sopenharmony_ci * @param text Indicates the character storage encoded with text encoding. 5417777dab0Sopenharmony_ci * @param byteLength Indicates the text length in bytes. 5427777dab0Sopenharmony_ci * @param encoding <b>OH_Drawing_TextEncoding</b> Indicates the text encoding. 5437777dab0Sopenharmony_ci * @param x Indicates x coordinates of the text. 5447777dab0Sopenharmony_ci * @param y Indicates y coordinates of the text. 5457777dab0Sopenharmony_ci * @param path <b>OH_Drawing_Path</b> The path object, returned to the caller. 5467777dab0Sopenharmony_ci * @return Returns the error code. 5477777dab0Sopenharmony_ci * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. 5487777dab0Sopenharmony_ci * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if any of font, text or path is nullptr. 5497777dab0Sopenharmony_ci * @since 14 5507777dab0Sopenharmony_ci */ 5517777dab0Sopenharmony_ciOH_Drawing_ErrorCode OH_Drawing_FontGetTextPath(const OH_Drawing_Font* font, const void* text, size_t byteLength, 5527777dab0Sopenharmony_ci OH_Drawing_TextEncoding encoding, float x, float y, OH_Drawing_Path* path); 5537777dab0Sopenharmony_ci 5547777dab0Sopenharmony_ci#ifdef __cplusplus 5557777dab0Sopenharmony_ci} 5567777dab0Sopenharmony_ci#endif 5577777dab0Sopenharmony_ci/** @} */ 5587777dab0Sopenharmony_ci#endif 559