openharmony 鸿蒙 capi-drawing-text-font-descriptor-h

2026-08-25 浏览 (1)

drawing_text_font_descriptor.h

Overview

This file declares the capabilities of font information, such as obtaining font information and searching for a font.

File to include: <native_drawing/drawing_text_font_descriptor.h>

Library: libnative_drawing.so

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 14

Related module: Drawing

Summary

Enumerated value

Nametypedef KeywordDescription
OH_Drawing_SystemFontTypeOH_Drawing_SystemFontTypeDefines an enum for the system font types.
OH_Drawing_FontFullDescriptorAttributeIdOH_Drawing_FontFullDescriptorAttributeIdEnumerates font descriptor attributes. You can use the corresponding APIs to obtain the attributes of different font descriptor types. For example, if the font descriptor attribute FULL_DESCRIPTOR_ATTR_I_WEIGHT is of the int type, use the OH_Drawing_GetFontFullDescriptorAttributeInt API to obtain the attribute value.
OH_Drawing_FontVariationAxisAttributeIdOH_Drawing_FontVariationAxisAttributeIdEnumerates font variable axis attributes.
OH_Drawing_FontVariationInstanceAttributeIdOH_Drawing_FontVariationInstanceAttributeIdEnumerates font variable instance attributes.

Functions

NameDescription
OH_Drawing_FontDescriptor* OH_Drawing_MatchFontDescriptors(OH_Drawing_FontDescriptor* desc, size_t* num)Obtains all system font descriptors that match a font descriptor. In the OH_Drawing_FontDescriptor struct, the path field is not used for matching, and other fields are valid only when they are not set to their default values.
If all fields in desc are set to their default values, all system font descriptors are returned.
If no matching is found, NULL is returned. Call OH_Drawing_DestroyFontDescriptors to release this pointer when the object is no longer needed.
void OH_Drawing_DestroyFontDescriptors(OH_Drawing_FontDescriptor* descriptors, size_t num)Releases an array of OH_Drawing_FontDescriptor objects.
OH_Drawing_FontDescriptor* OH_Drawing_GetFontDescriptorByFullName(const OH_Drawing_String* fullName,OH_Drawing_SystemFontType fontType)Obtains a font descriptor based on the font name and type. System fonts, style fonts, and user-installed fonts are supported.
A font descriptor is a data structure that describes font features. It contains details of the font appearance and properties.
OH_Drawing_Array* OH_Drawing_GetSystemFontFullNamesByType(OH_Drawing_SystemFontType fontType)Obtains an array of font names by font type.
const OH_Drawing_String* OH_Drawing_GetSystemFontFullNameByIndex(OH_Drawing_Array* fullNameArray, size_t index)Obtains the font name with the specified index in the font name array.
void OH_Drawing_DestroySystemFontFullNames(OH_Drawing_Array* fullNameArray)Releases the memory occupied by the font name array obtained by font type.
OH_Drawing_Array* OH_Drawing_GetFontFullDescriptorsFromStream(const void* data, size_t size)Obtains the font descriptor array based on the original binary data.
OH_Drawing_Array* OH_Drawing_GetFontFullDescriptorsFromPath(const char* path)Obtains an array of font descriptors based on the font file path.
const OH_Drawing_FontFullDescriptor* OH_Drawing_GetFontFullDescriptorByIndex(OH_Drawing_Array* descriptorArray, size_t index)Obtains the font descriptor from the font descriptor array based on the index.
void OH_Drawing_DestroyFontFullDescriptors(OH_Drawing_Array* descriptorArray)Releases the memory occupied by the font descriptor array.
void OH_Drawing_DestroyFontFullDescriptor(const OH_Drawing_FontFullDescriptor* descriptor)Releases the memory occupied by the font descriptor pointer. This function can be used to release the font descriptor pointer obtained by calling OH_Drawing_GetFontFullDescriptorByFullName.
OH_Drawing_ErrorCode OH_Drawing_GetFontFullDescriptorAttributeInt(const OH_Drawing_FontFullDescriptor* descriptor, OH_Drawing_FontFullDescriptorAttributeId id, int* value)Obtains the attributes of a font descriptor of the int type.
OH_Drawing_ErrorCode OH_Drawing_GetFontFullDescriptorAttributeBool(const OH_Drawing_FontFullDescriptor* descriptor, OH_Drawing_FontFullDescriptorAttributeId id, bool* value)Obtains the attributes of the font descriptor of the bool type.
OH_Drawing_ErrorCode OH_Drawing_GetFontFullDescriptorAttributeString(const OH_Drawing_FontFullDescriptor* descriptor, OH_Drawing_FontFullDescriptorAttributeId id, OH_Drawing_String* str)Obtains the attributes of the font descriptor of the OH_Drawing_String type.
OH_Drawing_ErrorCode OH_Drawing_GetFontUnicodeArrayFromFile(const char* fontSrc, uint32_t index, int32_t** unicodeArray, int32_t* arrayLength)Obtains a Unicode array from a font file.
OH_Drawing_ErrorCode OH_Drawing_GetFontUnicodeArrayFromBuffer(uint8_t* fontBuffer, size_t length, uint32_t index, int32_t** unicodeArray, int32_t* arrayLength)Obtains a Unicode array from a font buffer.
uint32_t OH_Drawing_GetFontCountFromFile(const char* fontSrc)Obtains the number of fonts contained in a font file.
uint32_t OH_Drawing_GetFontCountFromBuffer(uint8_t* fontBuffer, size_t length)Obtains the number of fonts contained in a font buffer.
OH_Drawing_String* OH_Drawing_GetFontPathsByType(OH_Drawing_SystemFontType fontType, size_t* pathCount)Obtains all font file paths of the specified font type.
OH_Drawing_Array* OH_Drawing_GetFontFullDescriptorAttributeArray(const OH_Drawing_FontFullDescriptor* descriptor, OH_Drawing_FontFullDescriptorAttributeId id)Obtains the object array attributes of the font descriptor.
OH_Drawing_FontVariationAxis* OH_Drawing_GetFontVariationAxisByIndex(OH_Drawing_Array* array, size_t index)Obtains the corresponding font variable axis from the font variable axis array by index.
void OH_Drawing_DestroyFontVariationAxis(OH_Drawing_Array* fontVariaAxisArray)Releases the memory occupied by the font variable axis array.
OH_Drawing_ErrorCode OH_Drawing_GetFontVariationAxisAttributeDouble(OH_Drawing_FontVariationAxis* variationAxis, OH_Drawing_FontVariationAxisAttributeId id, double *value)Obtains the font variable axis attributes of the double type.
OH_Drawing_ErrorCode OH_Drawing_GetFontVariationAxisAttributeInt(OH_Drawing_FontVariationAxis* variationAxis, OH_Drawing_FontVariationAxisAttributeId id, int *value)Obtains the font variable axis attributes of the int type.
OH_Drawing_ErrorCode OH_Drawing_GetFontVariationAxisAttributeStr(OH_Drawing_FontVariationAxis* variationAxis, OH_Drawing_FontVariationAxisAttributeId id, OH_Drawing_String *str)Obtains the font variable axis attributes of the OH_Drawing_String type.
OH_Drawing_FontVariationInstance* OH_Drawing_GetFontVariationInstanceByIndex(OH_Drawing_Array* array, size_t index)Obtains the corresponding font variable instance from the font variable instance array by index.
void OH_Drawing_DestroyFontVariationInstance(OH_Drawing_Array* fontVariaAxisInstance)Releases the memory occupied by the font variable instance array.
OH_Drawing_ErrorCode OH_Drawing_GetFontVariationInstanceAttributeStr(OH_Drawing_FontVariationInstance* variationInstance, OH_Drawing_FontVariationInstanceAttributeId id, OH_Drawing_String* str)Obtains the font variable instance attributes of the OH_Drawing_String type.
OH_Drawing_FontVariationInstanceCoordinate* OH_Drawing_GetFontVariationInstanceCoordinate(OH_Drawing_FontVariationInstance* variationInstance, size_t* arrayLength)Obtains the variable font attribute object of the font variable instance.
const OH_Drawing_FontFullDescriptor* OH_Drawing_GetFontFullDescriptorByFullName(const OH_Drawing_String* fullName, OH_Drawing_SystemFontType fontType)Obtains the complete font descriptor object based on the font name and type.

Enum Description

OH_Drawing_SystemFontType

enum OH_Drawing_SystemFontType

Description

Defines an enum for the system font types.

Since: 14

ValueDescription
ALL = 1 << 0All font types.
GENERIC = 1 << 1System font type.
STYLISH = 1 << 2Style font type.
INSTALLED = 1 << 3User-installed font type.
CUSTOMIZED = 1 << 4Custom font type.
Since: 18

OH_Drawing_FontFullDescriptorAttributeId

enum OH_Drawing_FontFullDescriptorAttributeId

Description

Enumerates font descriptor attributes. You can use the corresponding APIs to obtain the attributes of different font descriptor types. For example, if FULL_DESCRIPTOR_ATTR_I_WEIGHT is of the int type, use the OH_Drawing_GetFontFullDescriptorAttributeInt API to obtain its attribute value.

Since: 22

ValueDescription
FULL_DESCRIPTOR_ATTR_S_PATH = 0Font file path, of the OH_Drawing_String type.
FULL_DESCRIPTOR_ATTR_S_POSTSCRIPT_NAME = 1Postscript font name, of the OH_Drawing_String type.
FULL_DESCRIPTOR_ATTR_S_FULL_NAME = 2Font name, of the OH_Drawing_String type.
FULL_DESCRIPTOR_ATTR_S_FAMILY_NAME = 3Font family name, of the OH_Drawing_String type.
FULL_DESCRIPTOR_ATTR_S_SUB_FAMILY_NAME = 4Font subfamily name, of the OH_Drawing_String type.
FULL_DESCRIPTOR_ATTR_I_WEIGHT = 5Font weight, of the int type.
FULL_DESCRIPTOR_ATTR_I_WIDTH = 6Font width style, of the int type.
FULL_DESCRIPTOR_ATTR_I_ITALIC = 7Whether the font is italic, of the int type. 1 means that the font is italic; 0 otherwise.
FULL_DESCRIPTOR_ATTR_B_MONO = 8Whether the font is compact, of the bool type. true means yes; false otherwise.
FULL_DESCRIPTOR_ATTR_B_SYMBOLIC = 9Whether the font supports the symbol font, of the bool type. true means yes; false otherwise.
FULL_DESCRIPTOR_ATTR_S_LOCAL_POSTSCRIPT_NAME = 10Extracts the postscript name of the font based on the system language configuration.
Since: 23
FULL_DESCRIPTOR_ATTR_S_LOCAL_FULL_NAME = 11Extracts the full name of the font based on the system language configuration.
Since: 23
FULL_DESCRIPTOR_ATTR_S_LOCAL_FAMILY_NAME = 12Extracts the font family name based on the system language configuration.
Since: 23
FULL_DESCRIPTOR_ATTR_S_LOCAL_SUB_FAMILY_NAME = 13Extracts the font subfamily name based on the system language configuration.
Since: 23
FULL_DESCRIPTOR_ATTR_S_VERSION = 14Font version.
Since: 23
FULL_DESCRIPTOR_ATTR_S_MANUFACTURE = 15Font manufacturer information.
Since: 23
FULL_DESCRIPTOR_ATTR_S_COPYRIGHT = 16Font copyright information.
Since: 23
FULL_DESCRIPTOR_ATTR_S_TRADEMARK = 17Font trademark information.
Since: 23
FULL_DESCRIPTOR_ATTR_S_LICENSE = 18Font license information.
Since: 23
FULL_DESCRIPTOR_ATTR_O_VARIATION_AXIS = 19Font variable axis array.
Since: 24
FULL_DESCRIPTOR_ATTR_O_VARIATION_INSTANCE = 20Font variable instance array.
Since: 24
FULL_DESCRIPTOR_ATTR_I_INDEX = 21Font index.
Since: 23

OH_Drawing_FontVariationAxisAttributeId

enum OH_Drawing_FontVariationAxisAttributeId

Description

Enumerates font variable axis attributes.

Since: 24

ValueDescription
FONT_VARIATION_AXIS_ATTR_S_KEY = 0Keyword identifier of the font variable axis.
FONT_VARIATION_AXIS_ATTR_D_MIN_VALUE = 1Minimum value of the font variable axis.
FONT_VARIATION_AXIS_ATTR_D_MAX_VALUE = 2Maximum value of the font variable axis.
FONT_VARIATION_AXIS_ATTR_D_DEFAULT_VALUE = 3Default value of the font variable axis.
FONT_VARIATION_AXIS_ATTR_I_FLAGS = 4Flag of the font variable axis. The value 0 indicates that the axis is visible to users, and the value 1 indicates that the axis should be hidden.
FONT_VARIATION_AXIS_ATTR_S_NAME = 5English name of the font variable axis.
FONT_VARIATION_AXIS_ATTR_S_LOCAL_NAME = 6Localized name of the font variable axis.

OH_Drawing_FontVariationInstanceAttributeId

enum OH_Drawing_FontVariationInstanceAttributeId

Description

Enumerates font variable instance attributes.

Since: 24

ValueDescription
FONT_VARIATION_INSTANCE_ATTR_S_NAME = 0English name of the font variable instance.
FONT_VARIATION_INSTANCE_ATTR_S_LOCAL_NAME = 1Localized name of the font variable instance.

Function Description

OH_Drawing_MatchFontDescriptors()

OH_Drawing_FontDescriptor* OH_Drawing_MatchFontDescriptors(OH_Drawing_FontDescriptor* desc, size_t* num)

Description

Obtains all system font descriptors that match a font descriptor. In the OH_Drawing_FontDescriptor struct, the path field is not used for matching, and other fields are valid only when they are not set to their default values.
If all fields in desc are set to their default values, all system font descriptors are returned.
If no matching is found, NULL is returned. Call OH_Drawing_DestroyFontDescriptors to release this pointer when the object is no longer needed.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 18

Parameters

NameDescription
OH_Drawing_FontDescriptor* descPointer.
You are advised to use OH_Drawing_CreateFontDescriptor to obtain a valid OH_Drawing_FontDescriptor instance.
For an OH_Drawing_FontDescriptor instance created by yourself, ensure that the fields that are not used for matching are set to default values.
size_t* numPointer to the number of elements in the array.

Returns

TypeDescription
OH_Drawing_FontDescriptor*An array of OH_Drawing_FontDescriptor objects. Use OH_Drawing_DestroyFontDescriptors to release the array.

OH_Drawing_DestroyFontDescriptors()

void OH_Drawing_DestroyFontDescriptors(OH_Drawing_FontDescriptor* descriptors, size_t num)

Description

Releases an array of OH_Drawing_FontDescriptor objects.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 18

Parameters

NameDescription
OH_Drawing_FontDescriptor* descriptorsArray.
size_t numNumber of members in an array of OH_Drawing_FontDescriptor objects.

OH_Drawing_GetFontDescriptorByFullName()

OH_Drawing_FontDescriptor* OH_Drawing_GetFontDescriptorByFullName(const OH_Drawing_String* fullName,OH_Drawing_SystemFontType fontType)

Description

Obtains a font descriptor based on the font name and type. System fonts, style fonts, and user-installed fonts are supported.
A font descriptor is a data structure that describes font features. It contains details of the font appearance and properties.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 14

Parameters

NameDescription
const OH_Drawing_String* fullNamePointer to the font name, which is OH_Drawing_String.
OH_Drawing_SystemFontType fontTypeEnum for the system font types, which is OH_Drawing_SystemFontType.

Returns

TypeDescription
OH_Drawing_FontDescriptor*Pointer to an OH_Drawing_FontDescriptor object. Call OH_Drawing_DestroyFontDescriptor to release this pointer when the object is no longer needed.

OH_Drawing_GetSystemFontFullNamesByType()

OH_Drawing_Array* OH_Drawing_GetSystemFontFullNamesByType(OH_Drawing_SystemFontType fontType)

Description

Obtains an array of font names by font type.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 14

Parameters

NameDescription
OH_Drawing_SystemFontType fontTypeEnum for the system font types, which is OH_Drawing_SystemFontType.

Returns

TypeDescription
OH_Drawing_Array*Returns the pointer to the OH_Drawing_Array object of the corresponding font type. Call OH_Drawing_DestroySystemFontFullNames to release this pointer when the object is no longer needed.

OH_Drawing_GetSystemFontFullNameByIndex()

const OH_Drawing_String* OH_Drawing_GetSystemFontFullNameByIndex(OH_Drawing_Array* fullNameArray, size_t index)

Description

Obtains the font name with the specified index in the font name array.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 14

Parameters

NameDescription
OH_Drawing_Array* fullNameArrayPointer to an OH_Drawing_Array object.
size_t indexIndex of the font in the array.

Returns

TypeDescription
const OH_Drawing_String*Returns the pointer to the font name, which is an OH_Drawing_String object.

OH_Drawing_DestroySystemFontFullNames()

void OH_Drawing_DestroySystemFontFullNames(OH_Drawing_Array* fullNameArray)

Description

Releases the memory occupied by the font name array obtained by font type.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 14

Parameters

NameDescription
OH_Drawing_Array* fullNameArrayPointer to an OH_Drawing_Array object.

OH_Drawing_GetFontFullDescriptorsFromStream()

OH_Drawing_Array* OH_Drawing_GetFontFullDescriptorsFromStream(const void* data, size_t size)

Description

Obtains the font descriptor array based on the original binary data.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 22

Parameters

NameDescription
const void* dataPointer to the raw binary font data buffer.
size_t sizeSize of the font data buffer, in bytes.

Returns

TypeDescription
OH_Drawing_Array*Returns the pointer to the OH_Drawing_Array array of the font descriptor corresponding to the font file. Call OH_Drawing_DestroyFontFullDescriptors to release the pointer when the OH_Drawing_Array object is no longer needed.
Returns NULL if the operation fails due to an invalid data format or parsing error.

OH_Drawing_GetFontFullDescriptorsFromPath()

OH_Drawing_Array* OH_Drawing_GetFontFullDescriptorsFromPath(const char* path)

Description

Obtains an array of font descriptors based on the font file path.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 22

Parameters

NameDescription
const char* pathPath of the font file to be queried.

Returns

TypeDescription
OH_Drawing_Array*Returns the pointer to the OH_Drawing_Array array of the font descriptor corresponding to the font file. Call OH_Drawing_DestroyFontFullDescriptors to release the pointer when the OH_Drawing_Array object is no longer needed.
Returns NULL if the font file is not found, the font file path is invalid, the font file does not have the required permission, or the file is not in the font format.

OH_Drawing_GetFontFullDescriptorByIndex()

const OH_Drawing_FontFullDescriptor* OH_Drawing_GetFontFullDescriptorByIndex(OH_Drawing_Array* descriptorArray, size_t index)

Description

Obtains the font descriptor from the font descriptor array based on the index.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 22

Parameters

NameDescription
OH_Drawing_Array* descriptorArrayPointer to the font descriptor array OH_Drawing_Array.
size_t indexIndex of the array, starting from 0.

Returns

TypeDescription
const OH_Drawing_FontFullDescriptor*Returns the pointer to the font descriptor object OH_Drawing_FontFullDescriptor at the specified index.
Returns NULL if the index is out of range or the array is invalid.

OH_Drawing_DestroyFontFullDescriptors()

void OH_Drawing_DestroyFontFullDescriptors(OH_Drawing_Array* descriptorArray)

Description

Releases the memory occupied by the font descriptor array.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 22

Parameters

NameDescription
OH_Drawing_Array* descriptorArrayPointer to the font descriptor array OH_Drawing_Array.

OH_Drawing_DestroyFontFullDescriptor()

void OH_Drawing_DestroyFontFullDescriptor(const OH_Drawing_FontFullDescriptor* descriptor)

Description

Releases the memory occupied by the font descriptor pointer. This function can be used to release the font descriptor pointer obtained by calling OH_Drawing_GetFontFullDescriptorByFullName.

Since: 24

Parameters

NameDescription
const OH_Drawing_FontFullDescriptor* descriptorPointer to the font descriptor object OH_Drawing_FontFullDescriptor.

OH_Drawing_GetFontFullDescriptorAttributeInt()

OH_Drawing_ErrorCode OH_Drawing_GetFontFullDescriptorAttributeInt(const OH_Drawing_FontFullDescriptor* descriptor, OH_Drawing_FontFullDescriptorAttributeId id, int* value)

Description

Obtains the attributes of a font descriptor of the int type.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 22

Parameters

NameDescription
const OH_Drawing_FontFullDescriptor* descriptorPointer to the font descriptor object OH_Drawing_FontFullDescriptor.
OH_Drawing_FontFullDescriptorAttributeId idFont descriptor attribute ID. You can obtain the font descriptor attribute from OH_Drawing_FontFullDescriptorAttributeId.
int* valuePointer to the attribute of the int type. It is used as an output parameter.

Returns

TypeDescription
OH_Drawing_ErrorCodeReturns the execution result.
OH_DRAWING_SUCCESS if the operation is successful.
OH_DRAWING_ERROR_INCORRECT_PARAMETER if the descriptor or value parameter is null.
OH_DRAWING_ERROR_ATTRIBUTE_ID_MISMATCH if the input attribute ID does not match the called function.

OH_Drawing_GetFontFullDescriptorAttributeBool()

OH_Drawing_ErrorCode OH_Drawing_GetFontFullDescriptorAttributeBool(const OH_Drawing_FontFullDescriptor* descriptor, OH_Drawing_FontFullDescriptorAttributeId id, bool* value)

Description

Obtains the font descriptor attribute of the bool type.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 22

Parameters

NameDescription
const OH_Drawing_FontFullDescriptor* descriptorPointer to the font descriptor object OH_Drawing_FontFullDescriptor.
OH_Drawing_FontFullDescriptorAttributeId idFont descriptor attribute ID. You can obtain the font descriptor attribute from OH_Drawing_FontFullDescriptorAttributeId.
bool* valuePointer to the bool attribute It is used as an output parameter.

Returns

TypeDescription
OH_Drawing_ErrorCodeReturns the execution result.
OH_DRAWING_SUCCESS if the operation is successful.
OH_DRAWING_ERROR_INCORRECT_PARAMETER if the descriptor or value parameter is null.
OH_DRAWING_ERROR_ATTRIBUTE_ID_MISMATCH if the input attribute ID does not match the called function.

OH_Drawing_GetFontFullDescriptorAttributeString()

OH_Drawing_ErrorCode OH_Drawing_GetFontFullDescriptorAttributeString(const OH_Drawing_FontFullDescriptor* descriptor, OH_Drawing_FontFullDescriptorAttributeId id, OH_Drawing_String* str)

Description

Obtains the attributes of the OH_Drawing_String font descriptor.

NOTE If OH_Drawing_String is no longer needed, the caller needs to manually release the strData member in the OH_Drawing_String struct.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 22

Parameters

NameDescription
const OH_Drawing_FontFullDescriptor* descriptorPointer to the font descriptor object OH_Drawing_FontFullDescriptor.
OH_Drawing_FontFullDescriptorAttributeId idFont descriptor attribute ID. You can obtain the font descriptor attribute from OH_Drawing_FontFullDescriptorAttributeId.
OH_Drawing_String* strPointer to the OH_Drawing_String attribute. It is used as an output parameter.

Returns

TypeDescription
OH_Drawing_ErrorCodeReturns the execution result.
OH_DRAWING_SUCCESS if the operation is successful.
OH_DRAWING_ERROR_INCORRECT_PARAMETER if descriptor or str is a null pointer.
OH_DRAWING_ERROR_ATTRIBUTE_ID_MISMATCH if the input attribute ID does not match the called function.

OH_Drawing_GetFontUnicodeArrayFromFile()

OH_Drawing_ErrorCode OH_Drawing_GetFontUnicodeArrayFromFile(const char* fontSrc, uint32_t index, int32_t** unicodeArray, int32_t* arrayLength)

Description

Obtains a Unicode array from a font file.

Since: 23

Parameters

NameDescription
const char* fontSrcFont file path.
uint32_t indexIndex of the font in a TTC/OTC file. This parameter shall be set to 0 for non-TTC/OTC files.
int32_t** unicodeArrayOutput parameter, which is used to receive the Unicode array. Use free() to release the Unicode array when the array is no longer needed.
int32_t* arrayLengthOutput parameter, which is used to receive the length of the Unicode array.

Returns

TypeDescription
OH_Drawing_ErrorCodeReturns the execution result.
OH_DRAWING_SUCCESS if the operation is successful.
OH_DRAWING_ERROR_INCORRECT_PARAMETER if the font path is invalid or the file is not a font file.

OH_Drawing_GetFontUnicodeArrayFromBuffer()

OH_Drawing_ErrorCode OH_Drawing_GetFontUnicodeArrayFromBuffer(uint8_t* fontBuffer, size_t length, uint32_t index, int32_t** unicodeArray, int32_t* arrayLength)

Description

Obtains a Unicode array from a font buffer.

Since: 23

Parameters

NameDescription
uint8_t* fontBufferFont file data.
size_t lengthLength of the font file data.
uint32_t indexIndex of the font in a TTC/OTC file. This parameter shall be set to 0 for non-TTC/OTC files.
int32_t** unicodeArrayOutput parameter, which is used to receive the Unicode array. Use free() to release the Unicode array when the array is no longer needed.
int32_t* arrayLengthOutput parameter, which is used to receive the length of the Unicode array.

Returns

TypeDescription
OH_Drawing_ErrorCodeReturns the execution result.
OH_DRAWING_SUCCESS if the operation is successful.
OH_DRAWING_ERROR_INCORRECT_PARAMETER if the buffer data is invalid or not font file data.

OH_Drawing_GetFontCountFromFile()

uint32_t OH_Drawing_GetFontCountFromFile(const char* fontSrc)

Description

Obtains the number of fonts contained in a font file.

Since: 23

Parameters

NameDescription
const char* fontSrcFont file path.

Returns

TypeDescription
uint32_tNumber of fonts.

OH_Drawing_GetFontCountFromBuffer()

uint32_t OH_Drawing_GetFontCountFromBuffer(uint8_t* fontBuffer, size_t length)

Description

Obtains the number of fonts contained in a font buffer.

Since: 23

Parameters

NameDescription
uint8_t* fontBufferFont buffer data.
size_t lengthLength of the font data.

Returns

TypeDescription
uint32_tNumber of fonts.

OH_Drawing_GetFontPathsByType()

OH_Drawing_String* OH_Drawing_GetFontPathsByType(OH_Drawing_SystemFontType fontType, size_t* pathCount)

Description

Obtains all font file paths of the specified font type.

Since: 23

Parameters

NameDescription
OH_Drawing_SystemFontType fontTypeEnum for the system font types, which is OH_Drawing_SystemFontType.
size_t* pathCountNumber of font file paths in the list returned.

Returns

TypeDescription
OH_Drawing_String*Returns a list of OH_Drawing_String objects representing font file paths. Use free() to free the object pointer and the internal pointer held by each OH_Drawing_String object when they are no longer needed.

OH_Drawing_GetFontFullDescriptorAttributeArray()

OH_Drawing_Array* OH_Drawing_GetFontFullDescriptorAttributeArray(const OH_Drawing_FontFullDescriptor* descriptor, OH_Drawing_FontFullDescriptorAttributeId id)

Description

Obtains the object array attributes of the font descriptor.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 24

Parameters

NameDescription
const OH_Drawing_FontFullDescriptor* descriptorPointer to the font descriptor object OH_Drawing_FontFullDescriptor.
OH_Drawing_FontFullDescriptorAttributeId idFont descriptor attribute ID. You can obtain the font descriptor attribute from OH_Drawing_FontFullDescriptorAttributeId.

Returns

TypeDescription
OH_Drawing_Array*Object array returned.

OH_Drawing_GetFontVariationAxisByIndex()

OH_Drawing_FontVariationAxis* OH_Drawing_GetFontVariationAxisByIndex(OH_Drawing_Array* array, size_t index)

Description

Obtains the corresponding font variable axis from the font variable axis array by index.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 24

Parameters

NameDescription
OH_Drawing_Array* arrayPointer to the font variable axis array OH_Drawing_Array.
size_t indexIndex of the array, starting from 0.

Returns

TypeDescription
OH_Drawing_FontVariationAxis*Returns the pointer to the font variable axis object OH_Drawing_FontVariationAxis at the specified index.
Returns NULL if the index is out of range or the array is invalid.

OH_Drawing_DestroyFontVariationAxis()

void OH_Drawing_DestroyFontVariationAxis(OH_Drawing_Array* fontVariaAxisArray)

Description

Releases the memory occupied by the font variable axis array.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 24

Parameters

NameDescription
OH_Drawing_Array* fontVariaAxisArrayPointer to the font variable axis array object OH_Drawing_Array.

OH_Drawing_GetFontVariationAxisAttributeDouble()

OH_Drawing_ErrorCode OH_Drawing_GetFontVariationAxisAttributeDouble(OH_Drawing_FontVariationAxis* variationAxis, OH_Drawing_FontVariationAxisAttributeId id, double *value)

Description

Obtains the font variable axis attributes of the double type.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 24

Parameters

NameDescription
OH_Drawing_FontVariationAxis* variationAxisPointer to the font variable axis object OH_Drawing_FontVariationAxis.
OH_Drawing_FontVariationAxisAttributeId idFont variable axis attribute ID. You can obtain the font variable axis attribute from OH_Drawing_FontVariationAxisAttributeId.
double *valuePointer to the attributes of the double type. It is used as an output parameter.

Returns

TypeDescription
OH_Drawing_ErrorCodeReturns the execution result.
OH_DRAWING_SUCCESS if the operation is successful.
OH_DRAWING_ERROR_INCORRECT_PARAMETER if the parameter variationAxis or value is a null pointer.
OH_DRAWING_ERROR_ATTRIBUTE_ID_MISMATCH if the input attribute ID does not match the called function.

OH_Drawing_GetFontVariationAxisAttributeInt()

OH_Drawing_ErrorCode OH_Drawing_GetFontVariationAxisAttributeInt(OH_Drawing_FontVariationAxis* variationAxis, OH_Drawing_FontVariationAxisAttributeId id, int *value)

Description

Obtains the font variable axis attributes of the int type.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 24

Parameters

NameDescription
OH_Drawing_FontVariationAxis* variationAxisPointer to the font variable axis object OH_Drawing_FontVariationAxis.
OH_Drawing_FontVariationAxisAttributeId idFont variable axis attribute ID. You can obtain the font variable axis attribute from OH_Drawing_FontVariationAxisAttributeId.
int *valuePointer to the attribute of the int type. It is used as an output parameter.

Returns

TypeDescription
OH_Drawing_ErrorCodeReturns the execution result.
OH_DRAWING_SUCCESS if the operation is successful.
OH_DRAWING_ERROR_INCORRECT_PARAMETER if the parameter variationAxis or value is a null pointer.
OH_DRAWING_ERROR_ATTRIBUTE_ID_MISMATCH if the input attribute ID does not match the called function.

OH_Drawing_GetFontVariationAxisAttributeStr()

OH_Drawing_ErrorCode OH_Drawing_GetFontVariationAxisAttributeStr(OH_Drawing_FontVariationAxis* variationAxis, OH_Drawing_FontVariationAxisAttributeId id, OH_Drawing_String *str)

Description

Obtains the font variable axis attributes of the OH_Drawing_String type.

NOTE

If OH_Drawing_String is no longer needed, the caller needs to manually release the strData member in the OH_Drawing_String struct.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 24

Parameters

NameDescription
OH_Drawing_FontVariationAxis* variationAxisPointer to the font variable axis object OH_Drawing_FontVariationAxis.
OH_Drawing_FontVariationAxisAttributeId idFont variable axis attribute ID. You can obtain the font variable axis attribute from OH_Drawing_FontVariationAxisAttributeId.
OH_Drawing_String *strPointer to the OH_Drawing_String attribute. It is used as an output parameter.

Returns

TypeDescription
OH_Drawing_ErrorCodeReturns the execution result.
OH_DRAWING_SUCCESS if the operation is successful.
OH_DRAWING_ERROR_INCORRECT_PARAMETER if the parameter variationAxis or str is a null pointer.
OH_DRAWING_ERROR_ATTRIBUTE_ID_MISMATCH if the input attribute ID does not match the called function.

OH_Drawing_GetFontVariationInstanceByIndex()

OH_Drawing_FontVariationInstance* OH_Drawing_GetFontVariationInstanceByIndex(OH_Drawing_Array* array, size_t index)

Description

Obtains the corresponding font variable instance from the font variable instance array by index.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 24

Parameters

NameDescription
OH_Drawing_Array* arrayPointer to the font variable instance array OH_Drawing_Array.
size_t indexIndex of the array, starting from 0.

Returns

TypeDescription
OH_Drawing_FontVariationInstance*Returns the pointer to the font variable instance object OH_Drawing_FontVariationInstance at the specified index.
Returns NULL if the index is out of range or the array is invalid.

OH_Drawing_DestroyFontVariationInstance()

void OH_Drawing_DestroyFontVariationInstance(OH_Drawing_Array* fontVariaAxisInstance)

Description

Releases the memory occupied by the font variable instance array.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 24

Parameters

NameDescription
OH_Drawing_Array* fontVariaAxisInstancePointer to the font variable instance array object OH_Drawing_Array.

OH_Drawing_GetFontVariationInstanceAttributeStr()

OH_Drawing_ErrorCode OH_Drawing_GetFontVariationInstanceAttributeStr(OH_Drawing_FontVariationInstance* variationInstance, OH_Drawing_FontVariationInstanceAttributeId id, OH_Drawing_String* str)

Description

Obtains the font variable instance attributes of the OH_Drawing_String type.

NOTE

If OH_Drawing_String is no longer needed, the caller needs to manually release the strData member in the OH_Drawing_String struct.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 24

Parameters

NameDescription
OH_Drawing_FontVariationInstance* variationInstancePointer to the font variable instance object OH_Drawing_FontVariationInstance.
OH_Drawing_FontVariationInstanceAttributeId idFont variable instance attribute ID. You can obtain the font variable instance attribute from OH_Drawing_FontVariationInstanceAttributeId.
OH_Drawing_String* strPointer to the OH_Drawing_String attribute. It is used as an output parameter.

Returns

TypeDescription
OH_Drawing_ErrorCodeReturns the execution result.
OH_DRAWING_SUCCESS if the operation is successful.
OH_DRAWING_ERROR_INCORRECT_PARAMETER if the parameter variationInstance or str is a null pointer.
OH_DRAWING_ERROR_ATTRIBUTE_ID_MISMATCH if the input attribute ID does not match the called function.

OH_Drawing_GetFontVariationInstanceCoordinate()

OH_Drawing_FontVariationInstanceCoordinate* OH_Drawing_GetFontVariationInstanceCoordinate(OH_Drawing_FontVariationInstance* variationInstance, size_t* arrayLength)

Description

Obtains the variable font attribute object of the font variable instance.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 24

Parameters

NameDescription
OH_Drawing_FontVariationInstance* variationInstancePointer to the font variable instance.
size_t* arrayLengthPointer to the list length of OH_Drawing_FontVariationInstanceCoordinate.

Returns

TypeDescription
OH_Drawing_FontVariationInstanceCoordinate*Returns the pointer to the variable font attribute list.

OH_Drawing_GetFontFullDescriptorByFullName()

const OH_Drawing_FontFullDescriptor* OH_Drawing_GetFontFullDescriptorByFullName(const OH_Drawing_String* fullName, OH_Drawing_SystemFontType fontType)

Description

Obtains the complete font descriptor object based on the font name and type.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 24

Parameters

NameDescription
const OH_Drawing_String* fullNamePointer to the font name object OH_Drawing_String.
OH_Drawing_SystemFontType fontTypeEnum for the system font type object, which is OH_Drawing_SystemFontType.

Returns

TypeDescription
const OH_Drawing_FontFullDescriptor*Returns the pointer to the complete font descriptor object OH_Drawing_FontFullDescriptor. If OH_Drawing_FontFullDescriptor is not required, use the OH_Drawing_DestroyFontFullDescriptor API to release the pointer of the object.

你可能感兴趣的鸿蒙文章

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/jOX9bqiM