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
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
| Type | Description |
|---|---|
| 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
| Name | Description |
|---|---|
| OH_Drawing_FontMgr* drawingFontMgr | Pointer 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
| Name | Description |
|---|---|
| OH_Drawing_FontMgr* drawingFontMgr | Pointer to an OH_Drawing_FontMgr object, which is obtained from OH_Drawing_FontMgrCreate. |
Return value
| Type | Description |
|---|---|
| int | Returns 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
| Name | Description |
|---|---|
| OH_Drawing_FontMgr* drawingFontMgr | Pointer to an OH_Drawing_FontMgr object, which is obtained from OH_Drawing_FontMgrCreate. |
| int index | Index of the font family name. |
Return value
| Type | Description |
|---|---|
| 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
| Name | Description |
|---|---|
| char* familyName | Pointer 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
| Name | Description |
|---|---|
| OH_Drawing_FontMgr* drawingFontMgr | Pointer to an OH_Drawing_FontMgr object, which is obtained from OH_Drawing_FontMgrCreate. |
| int index | Index of the font style set. |
Return value
| Type | Description |
|---|---|
| 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
| Name | Description |
|---|---|
| OH_Drawing_FontStyleSet* drawingFontStyleSet | Pointer 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
| Name | Description |
|---|---|
| OH_Drawing_FontMgr* drawingFontMgr | Pointer to an OH_Drawing_FontMgr object, which is obtained from OH_Drawing_FontMgrCreate. |
| const char* familyName | Pointer to a font family name. |
Return value
| Type | Description |
|---|---|
| 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
| Name | Description |
|---|---|
| OH_Drawing_FontMgr* drawingFontMgr | Pointer to an OH_Drawing_FontMgr object, which is obtained from OH_Drawing_FontMgrCreate. |
| const char* familyName | Pointer to a font family name. |
| OH_Drawing_FontStyleStruct fontStyle | Font style, including the font weight, width, and slant. |
Return value
| Type | Description |
|---|---|
| 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
| Name | Description |
|---|---|
| OH_Drawing_FontMgr* drawingFontMgr | Pointer to an OH_Drawing_FontMgr object, which is obtained from OH_Drawing_FontMgrCreate. |
| const char* familyName | Pointer to a font family name. |
| OH_Drawing_FontStyleStruct fontStyle | Font style, including the font weight, width, and slant. |
| bcp47 | Pointer to the character language code array, which is a combination of ISO 639, 15924, and 3166-1 language codes. |
| int bcp47Count | Size of the character language code array. |
| int32_t character | UTF8 character used for matching. |
Return value
| Type | Description |
|---|---|
| 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
| Name | Description |
|---|---|
| OH_Drawing_FontStyleSet* fontStyleSet | Pointer to an OH_Drawing_FontStyleSet object. |
| int index | Index of the typeface. |
Return value
| Type | Description |
|---|---|
| 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
| Name | Description |
|---|---|
| OH_Drawing_FontStyleSet* fontStyleSet | Pointer to an OH_Drawing_FontStyleSet object. |
| int32_t index | Index of the font style. |
| char** styleName | String 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
| Type | Description |
|---|---|
| OH_Drawing_FontStyleStruct | Returns 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
| Name | Description |
|---|---|
| char** styleName | Double 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
| Name | Description |
|---|---|
| OH_Drawing_FontStyleSet* fontStyleSet | Pointer to an OH_Drawing_FontStyleSet object. |
| OH_Drawing_FontStyleStruct fontStyleStruct | Font style, including the font weight, width, and slant. |
Return value
| Type | Description |
|---|---|
| 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
| Name | Description |
|---|---|
| OH_Drawing_FontStyleSet* fontStyleSet | Pointer to an OH_Drawing_FontStyleSet object. |
Return value
| Type | Description |
|---|---|
| int | Returns 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