harmony 鸿蒙drawing_font.h

  • 2025-06-12
  • 浏览 (5)

drawing_font.h

Overview

The drawing_font.h file declares the functions related to the font in the drawing module.

File to include: <native_drawing/drawing_font.h>

Library: libnative_drawing.so

Since: 11

Related module: Drawing

Summary

Structs

Name Description
struct OH_Drawing_Font_Metrics Describes the measurement information about a font.

Types

Name Description
typedef enum OH_Drawing_FontEdging OH_Drawing_FontEdging Defines an enum for the font edging types.
typedef enum OH_Drawing_FontHinting OH_Drawing_FontHinting Defines an enum for the font hinting types.
typedef struct OH_Drawing_Font_Metrics OH_Drawing_Font_Metrics Defines a struct for the measurement information about a font.

Enums

Name Description
OH_Drawing_FontEdging { FONT_EDGING_ALIAS, FONT_EDGING_ANTI_ALIAS, FONT_EDGING_SUBPIXEL_ANTI_ALIAS } Enumerates the font edging types.
OH_Drawing_FontHinting { FONT_HINTING_NONE, FONT_HINTING_SLIGHT, FONT_HINTING_NORMAL, FONT_HINTING_FULL } Enumerates the font hinting types.

Functions

Name Description
OH_Drawing_ErrorCode OH_Drawing_FontSetThemeFontFollowed (OH_Drawing_Font *font, bool followed) Sets whether to follow the theme font. When followed is set to true, the theme font is used if it is enabled by the system and no typeface is set.
OH_Drawing_ErrorCode OH_Drawing_FontIsThemeFontFollowed (const OH_Drawing_Font *font, bool *followed) Checks whether the font follows the theme font. By default, the theme font is not followed.
OH_Drawing_ErrorCode OH_Drawing_FontGetBounds (const OH_Drawing_Font *font, const uint16_t *glyphs, uint32_t count, OH_Drawing_Array *bounds) Obtains the rectangular bounding box for each glyph in the glyph array.
OH_Drawing_ErrorCode OH_Drawing_FontGetPathForGlyph (const OH_Drawing_Font *font, uint16_t glyph, OH_Drawing_Path *path) Obtains the path of a glyph.
OH_Drawing_ErrorCode OH_Drawing_FontGetTextPath (const OH_Drawing_Font *font, const void *text, size_t byteLength, OH_Drawing_TextEncoding encoding, float x, float y, OH_Drawing_Path *path) Obtains the text outline path.
OH_Drawing_ErrorCode OH_Drawing_FontMeasureSingleCharacter (const OH_Drawing_Font *font, const char *str, float *textWidth) Measures the width of a single character. If the typeface of the current font does not support the character to measure, the system typeface is used to measure the character width.
OH_Drawing_ErrorCode OH_Drawing_FontMeasureText (const OH_Drawing_Font *font, const void *text, size_t byteLength, OH_Drawing_TextEncoding encoding, OH_Drawing_Rect *bounds, float *textWidth) Obtains the text width and bounding box.
void OH_Drawing_FontSetBaselineSnap (OH_Drawing_Font *, bool baselineSnap) Sets whether to request that baselines be snapped to pixels when the current canvas matrix is axis aligned.
bool OH_Drawing_FontIsBaselineSnap (const OH_Drawing_Font *) Checks whether baselines are requested to be snapped to pixels when the current canvas matrix is axis aligned.
void OH_Drawing_FontSetEdging (OH_Drawing_Font *, OH_Drawing_FontEdging) Sets a font edging effect.
OH_Drawing_FontEdging OH_Drawing_FontGetEdging (const OH_Drawing_Font *) Obtains the font edging effect.
void OH_Drawing_FontSetForceAutoHinting (OH_Drawing_Font *, bool isForceAutoHinting) Sets whether to forcibly use auto hinting, that is, whether to always hint glyphs.
bool OH_Drawing_FontIsForceAutoHinting (const OH_Drawing_Font *) Checks whether auto hinting is forcibly used.
void OH_Drawing_FontSetSubpixel (OH_Drawing_Font *, bool isSubpixel) Sets whether to use sub-pixel rendering for a font.
bool OH_Drawing_FontIsSubpixel (const OH_Drawing_Font *) Checks whether sub-pixel rendering is used for a font.
OH_Drawing_Font * OH_Drawing_FontCreate (void) Creates an OH_Drawing_Font object.
void OH_Drawing_FontSetTypeface (OH_Drawing_Font *, OH_Drawing_Typeface *) Sets a typeface for a font.
OH_Drawing_Typeface * OH_Drawing_FontGetTypeface (OH_Drawing_Font *) Obtains the typeface of a font.
void OH_Drawing_FontSetTextSize (OH_Drawing_Font *, float textSize) Sets the text size for a font.
float OH_Drawing_FontGetTextSize (const OH_Drawing_Font *) Obtains the text size.
int OH_Drawing_FontCountText (OH_Drawing_Font *, const void *text, size_t byteLength, OH_Drawing_TextEncoding encoding) Obtains the number of glyphs represented by text.
uint32_t OH_Drawing_FontTextToGlyphs (const OH_Drawing_Font *, const void *text, uint32_t byteLength, OH_Drawing_TextEncoding encoding, uint16_t *glyphs, int maxGlyphCount) Converts text into glyph indices.
void OH_Drawing_FontGetWidths (const OH_Drawing_Font *, const uint16_t *glyphs, int count, float *widths) Obtains the width of each glyph in a string.
void OH_Drawing_FontSetLinearText (OH_Drawing_Font *, bool isLinearText) Sets linear scaling for a font.
bool OH_Drawing_FontIsLinearText (const OH_Drawing_Font *) Checks whether linear scaling is used for a font.
void OH_Drawing_FontSetTextSkewX (OH_Drawing_Font *, float skewX) Sets a horizontal skew factor for a font.
float OH_Drawing_FontGetTextSkewX (const OH_Drawing_Font *) Obtains the horizontal skew factor of a font.
void OH_Drawing_FontSetFakeBoldText (OH_Drawing_Font *, bool isFakeBoldText) Sets fake bold for a font by increasing the stroke width.
bool OH_Drawing_FontIsFakeBoldText (const OH_Drawing_Font *) Checks whether fake bold is used for a font.
void OH_Drawing_FontSetScaleX (OH_Drawing_Font *, float scaleX) Sets a horizontal scale factor for a font.
float OH_Drawing_FontGetScaleX (const OH_Drawing_Font *) Obtains the horizontal scale factor of a font.
void OH_Drawing_FontSetHinting (OH_Drawing_Font *, OH_Drawing_FontHinting) Sets a font hinting effect.
OH_Drawing_FontHinting OH_Drawing_FontGetHinting (const OH_Drawing_Font *) Obtains the font hinting effect.
void OH_Drawing_FontSetEmbeddedBitmaps (OH_Drawing_Font *, bool isEmbeddedBitmaps) Sets whether to use bitmaps in a font.
bool OH_Drawing_FontIsEmbeddedBitmaps (const OH_Drawing_Font *) Checks whether bitmaps are used in a font.
void OH_Drawing_FontDestroy (OH_Drawing_Font *) Destroys an OH_Drawing_Font object and reclaims the memory occupied by the object.
float OH_Drawing_FontGetMetrics (OH_Drawing_Font *, OH_Drawing_Font_Metrics *) Obtains the measurement information about a font.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙ArkGraphics 2D

harmony 鸿蒙BufferHandle

harmony 鸿蒙ColorSpacePrimaries

harmony 鸿蒙DisplaySoloist_ExpectedRateRange

harmony 鸿蒙_drawing

harmony 鸿蒙NativeColorSpaceManager

harmony 鸿蒙NativeDisplaySoloist

harmony 鸿蒙NativeVsync

harmony 鸿蒙NativeWindow

harmony 鸿蒙OH_Drawing_BitmapFormat

0  赞