openharmony 鸿蒙 capi-drawing-font-mgr-h

2026-08-25 浏览 (1)

drawing_font_mgr.h

Overview

This file declares the functions related to font management in the drawing module. The functions can be used to load fonts and match available fonts in the system.

File to include: <native_drawing/drawing_font_mgr.h>

Library: libnative_drawing.so

Since: 12

Related module: Drawing

Summary

Functions

NameDescription
OH_Drawing_FontMgr* OH_Drawing_FontMgrCreate(void)Creates an OH_Drawing_FontMgr object, which can be used only to manage system fonts.
void OH_Drawing_FontMgrDestroy(OH_Drawing_FontMgr* drawingFontMgr)Destroys an OH_Drawing_FontMgr object and reclaims the memory occupied by the object.
int OH_Drawing_FontMgrGetFamilyCount(OH_Drawing_FontMgr* drawingFontMgr)Obtains the number of font families.
char* OH_Drawing_FontMgrGetFamilyName(OH_Drawing_FontMgr* drawingFontMgr, int index)Obtains the font family name based on an index.
void OH_Drawing_FontMgrDestroyFamilyName(char* familyName)Reclaims the memory occupied by a font family name.
OH_Drawing_FontStyleSet* OH_Drawing_FontMgrCreateFontStyleSet(OH_Drawing_FontMgr* drawingFontMgr, int index)Creates a font style set from an OH_Drawing_FontMgr object.
void OH_Drawing_FontMgrDestroyFontStyleSet(OH_Drawing_FontStyleSet* drawingFontStyleSet)Reclaims the memory occupied by a font style set.
OH_Drawing_FontStyleSet* OH_Drawing_FontMgrMatchFamily(OH_Drawing_FontMgr* drawingFontMgr, const char* familyName)Obtains a font style set based on a font family name.
OH_Drawing_Typeface* OH_Drawing_FontMgrMatchFamilyStyle(OH_Drawing_FontMgr* drawingFontMgr,const char* familyName, OH_Drawing_FontStyleStruct fontStyle)Obtains a typeface based on the font style information and font family name.
OH_Drawing_Typeface* OH_Drawing_FontMgrMatchFamilyStyleCharacter(OH_Drawing_FontMgr* drawingFontMgr,const char* familyName, OH_Drawing_FontStyleStruct fontStyle,const char* bcp47[], int bcp47Count, int32_t character)Obtains a typeface for the specified character. A null pointer is returned only when no typeface corresponding to the input UTF-8 character is found in the OH_Drawing_FontMgr object.
OH_Drawing_Typeface* OH_Drawing_FontStyleSetCreateTypeface(OH_Drawing_FontStyleSet* fontStyleSet, int index)Creates a typeface for the specified index.
OH_Drawing_FontStyleStruct OH_Drawing_FontStyleSetGetStyle(OH_Drawing_FontStyleSet* fontStyleSet, int32_t index,char** styleName)Obtains the font style. Call OH_Drawing_FontStyleSetFreeStyleName to release styleName when it is no longer needed, freeing up the allocated memory.
void OH_Drawing_FontStyleSetFreeStyleName(char** styleName)Frees the memory occupied by a font style.
OH_Drawing_Typeface* OH_Drawing_FontStyleSetMatchStyle(OH_Drawing_FontStyleSet* fontStyleSet,OH_Drawing_FontStyleStruct fontStyleStruct)Obtains the typeface closest to the font style.
int OH_Drawing_FontStyleSetCount(OH_Drawing_FontStyleSet* fontStyleSet)Obtains the number of fonts in the font style set.

Function Description

OH_Drawing_FontMgrCreate()

OH_Drawing_FontMgr* OH_Drawing_FontMgrCreate(void)

Description

Creates an OH_Drawing_FontMgr object, which can be used only to manage system fonts.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Return value

TypeDescription
OH_Drawing_FontMgr*Pointer to the OH_Drawing_FontMgr object created.

OH_Drawing_FontMgrDestroy()

void OH_Drawing_FontMgrDestroy(OH_Drawing_FontMgr* drawingFontMgr)

Description

Destroys an OH_Drawing_FontMgr object and reclaims the memory occupied by the object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_FontMgr* drawingFontMgrPointer to an OH_Drawing_FontMgr object, which is obtained from OH_Drawing_FontMgrCreate.

OH_Drawing_FontMgrGetFamilyCount()

int OH_Drawing_FontMgrGetFamilyCount(OH_Drawing_FontMgr* drawingFontMgr)

Description

Obtains the number of font families.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_FontMgr* drawingFontMgrPointer to an OH_Drawing_FontMgr object, which is obtained from OH_Drawing_FontMgrCreate.

Return value

TypeDescription
intReturns the number of font families.

OH_Drawing_FontMgrGetFamilyName()

char* OH_Drawing_FontMgrGetFamilyName(OH_Drawing_FontMgr* drawingFontMgr, int index)

Description

Obtains the font family name based on an index.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_FontMgr* drawingFontMgrPointer to an OH_Drawing_FontMgr object, which is obtained from OH_Drawing_FontMgrCreate.
int indexIndex of the font family name.

Return value

TypeDescription
char*Returns the font family name. When the font family name is no longer required, call OH_Drawing_FontMgrDestroyFamilyName to release the pointer to the object.

OH_Drawing_FontMgrDestroyFamilyName()

void OH_Drawing_FontMgrDestroyFamilyName(char* familyName)

Description

Reclaims the memory occupied by a font family name.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
char* familyNamePointer to a font family name.

OH_Drawing_FontMgrCreateFontStyleSet()

OH_Drawing_FontStyleSet* OH_Drawing_FontMgrCreateFontStyleSet(OH_Drawing_FontMgr* drawingFontMgr, int index)

Description

Creates a font style set from an OH_Drawing_FontMgr object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_FontMgr* drawingFontMgrPointer to an OH_Drawing_FontMgr object, which is obtained from OH_Drawing_FontMgrCreate.
int indexIndex of the font style set.

Return value

TypeDescription
OH_Drawing_FontStyleSet*Returns a pointer to the OH_Drawing_FontStyleSet object created.

OH_Drawing_FontMgrDestroyFontStyleSet()

void OH_Drawing_FontMgrDestroyFontStyleSet(OH_Drawing_FontStyleSet* drawingFontStyleSet)

Description

Reclaims the memory occupied by a font style set.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_FontStyleSet* drawingFontStyleSetPointer to an OH_Drawing_FontStyleSet object.

OH_Drawing_FontMgrMatchFamily()

OH_Drawing_FontStyleSet* OH_Drawing_FontMgrMatchFamily(OH_Drawing_FontMgr* drawingFontMgr, const char* familyName)

Description

Obtains a font style set based on a font family name.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_FontMgr* drawingFontMgrPointer to an OH_Drawing_FontMgr object, which is obtained from OH_Drawing_FontMgrCreate.
const char* familyNamePointer to a font family name.

Return value

TypeDescription
OH_Drawing_FontStyleSet*Returns a pointer to an OH_Drawing_FontStyleSet object. Call OH_Drawing_FontMgrDestroyFontStyleSet to release this pointer when it is no longer needed.

OH_Drawing_FontMgrMatchFamilyStyle()

OH_Drawing_Typeface* OH_Drawing_FontMgrMatchFamilyStyle(OH_Drawing_FontMgr* drawingFontMgr,const char* familyName, OH_Drawing_FontStyleStruct fontStyle)

Description

Obtains a typeface based on the font style information and font family name.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_FontMgr* drawingFontMgrPointer to an OH_Drawing_FontMgr object, which is obtained from OH_Drawing_FontMgrCreate.
const char* familyNamePointer to a font family name.
OH_Drawing_FontStyleStruct fontStyleFont style, including the font weight, width, and slant.

Return value

TypeDescription
OH_Drawing_Typeface*Returns a pointer to an OH_Drawing_Typeface object. Call OH_Drawing_TypefaceDestroy to release this pointer when it is no longer needed.

OH_Drawing_FontMgrMatchFamilyStyleCharacter()

OH_Drawing_Typeface* OH_Drawing_FontMgrMatchFamilyStyleCharacter(OH_Drawing_FontMgr* drawingFontMgr,const char* familyName, OH_Drawing_FontStyleStruct fontStyle,const char* bcp47[], int bcp47Count, int32_t character)

Description

Obtains a typeface for the specified character. A null pointer is returned only when no typeface corresponding to the input UTF-8 character is found in the OH_Drawing_FontMgr object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_FontMgr* drawingFontMgrPointer to an OH_Drawing_FontMgr object, which is obtained from OH_Drawing_FontMgrCreate.
const char* familyNamePointer to a font family name.
OH_Drawing_FontStyleStruct fontStyleFont style, including the font weight, width, and slant.
bcp47Pointer to the character language code array, which is a combination of ISO 639, 15924, and 3166-1 language codes.
int bcp47CountSize of the character language code array.
int32_t characterUTF8 character used for matching.

Return value

TypeDescription
OH_Drawing_Typeface*Returns a typeface object, which is OH_Drawing_Typeface.

OH_Drawing_FontStyleSetCreateTypeface()

OH_Drawing_Typeface* OH_Drawing_FontStyleSetCreateTypeface(OH_Drawing_FontStyleSet* fontStyleSet, int index)

Description

Creates a typeface for the specified index.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_FontStyleSet* fontStyleSetPointer to an OH_Drawing_FontStyleSet object.
int indexIndex of the typeface.

Return value

TypeDescription
OH_Drawing_Typeface*Returns the pointer to the OH_Drawing_Typeface object created if the operation is successful; returns a null pointer otherwise.

OH_Drawing_FontStyleSetGetStyle()

OH_Drawing_FontStyleStruct OH_Drawing_FontStyleSetGetStyle(OH_Drawing_FontStyleSet* fontStyleSet, int32_t index,char** styleName)

Description

Obtains the font style. Call OH_Drawing_FontStyleSetFreeStyleName to release styleName when it is no longer needed, freeing up the allocated memory.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_FontStyleSet* fontStyleSetPointer to an OH_Drawing_FontStyleSet object.
int32_t indexIndex of the font style.
char** styleNameString specifying the font style name. Call OH_Drawing_FontStyleSetFreeStyleName to release it when it is no longer needed, freeing up the allocated memory.

Return value

TypeDescription
OH_Drawing_FontStyleStructReturns the font style.

OH_Drawing_FontStyleSetFreeStyleName()

void OH_Drawing_FontStyleSetFreeStyleName(char** styleName)

Description

Frees the memory occupied by a font style.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
char** styleNameDouble pointer to the string that specifies the font style name.

OH_Drawing_FontStyleSetMatchStyle()

OH_Drawing_Typeface* OH_Drawing_FontStyleSetMatchStyle(OH_Drawing_FontStyleSet* fontStyleSet,OH_Drawing_FontStyleStruct fontStyleStruct)

Description

Obtains the typeface closest to the font style.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_FontStyleSet* fontStyleSetPointer to an OH_Drawing_FontStyleSet object.
OH_Drawing_FontStyleStruct fontStyleStructFont style, including the font weight, width, and slant.

Return value

TypeDescription
OH_Drawing_Typeface*Returns a typeface object, which is OH_Drawing_Typeface.

OH_Drawing_FontStyleSetCount()

int OH_Drawing_FontStyleSetCount(OH_Drawing_FontStyleSet* fontStyleSet)

Description

Obtains the number of fonts in the font style set.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_FontStyleSet* fontStyleSetPointer to an OH_Drawing_FontStyleSet object.

Return value

TypeDescription
intReturns the number of fonts.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 capi-drawing-gpu-context-h

openharmony 鸿蒙 capi-drawing-nativepixelmap-

openharmony 鸿蒙 capi-nativevsync-oh-nativevsync-expectedraterange

openharmony 鸿蒙 capi-drawing-oh-drawing-brush

openharmony 鸿蒙 capi-drawing-oh-drawing-image-info

openharmony 鸿蒙 capi-drawing-text-linetypography-h

openharmony 鸿蒙 capi-oh-nativeimage-oh-nativeimage

openharmony 鸿蒙 capi-drawing-typeface-h

openharmony 鸿蒙 capi-drawing-brush-h

openharmony 鸿蒙 capi-nativewindow

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/iHqnP6I4