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

2026-08-25 浏览 (1)

drawing_text_run.h

Overview

This file declares the capabilities of runs, such as obtaining the typographic boundary and drawing.

File to include: <native_drawing/drawing_text_run.h>

Library: libnative_drawing.so

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 18

Related module: Drawing

Summary

Functions

NameDescription
OH_Drawing_Array* OH_Drawing_GetRunStringIndices(OH_Drawing_Run* run, int64_t start, int64_t length)Obtains an array of character indices of glyphs within a specified range of a run, where the indices are offsets relative to the entire paragraph.
uint64_t OH_Drawing_GetRunStringIndicesByIndex(OH_Drawing_Array* stringIndices, size_t index)Obtains character indices of glyphs in a run by index.
void OH_Drawing_DestroyRunStringIndices(OH_Drawing_Array* stringIndices)Releases the pointer to a character index array object.
void OH_Drawing_GetRunStringRange(OH_Drawing_Run* run, uint64_t* location, uint64_t* length)Obtains the range of glyphs generated by a run.
float OH_Drawing_GetRunTypographicBounds(OH_Drawing_Run* run, float* ascent, float* descent, float* leading)Obtains the typographic boundary of a run. The typographic boundary is related to the font and font size used for typography, but not the characters within the text.
void OH_Drawing_RunPaint(OH_Drawing_Canvas* canvas, OH_Drawing_Run* run, double x, double y)Paints the text contained in a run on the canvas.
OH_Drawing_Rect* OH_Drawing_GetRunImageBounds(OH_Drawing_Run* run)Obtains the image boundary of a run. The image boundary is related to characters and is equivalent to the visual boundary.
void OH_Drawing_DestroyRunImageBounds(OH_Drawing_Rect* rect)Releases the pointer to an image boundary object of a run.
OH_Drawing_Array* OH_Drawing_GetRunGlyphs(OH_Drawing_Run* run, int64_t start, int64_t length)Obtains an array of glyphs within the specified range of a run.
uint16_t OH_Drawing_GetRunGlyphsByIndex(OH_Drawing_Array* glyphs, size_t index)Obtains individual glyphs in a run by index.
void OH_Drawing_DestroyRunGlyphs(OH_Drawing_Array* glyphs)Releases the pointer to a glyph array in a run.
OH_Drawing_Array* OH_Drawing_GetRunPositions(OH_Drawing_Run* run, int64_t start, int64_t length)Obtains the positions of glyphs within the specified range of a run.
OH_Drawing_Point* OH_Drawing_GetRunPositionsByIndex(OH_Drawing_Array* positions, size_t index)Obtains the positions of individual glyphs in a run by index.
void OH_Drawing_DestroyRunPositions(OH_Drawing_Array* positions)Releases the pointer to a glyph position array in a run.
uint32_t OH_Drawing_GetRunGlyphCount(OH_Drawing_Run* run)Obtains the number of glyphs in a run.
OH_Drawing_Font* OH_Drawing_GetRunFont(OH_Drawing_Run* run)Obtains the font object of a run.
OH_Drawing_TextDirection OH_Drawing_GetRunTextDirection(OH_Drawing_Run* run)Obtains the text direction of a run.
OH_Drawing_Array* OH_Drawing_GetRunGlyphAdvances(OH_Drawing_Run* run, uint32_t start, uint32_t length)Obtains the glyph advance array of a run.
OH_Drawing_Point* OH_Drawing_GetRunGlyphAdvanceByIndex(OH_Drawing_Array* advances, size_t index)Obtains the advances of individual glyphs in a run by index.
void OH_Drawing_DestroyRunGlyphAdvances(OH_Drawing_Array* advances)Releases the pointer to a glyph advance array in a run.

Function Description

OH_Drawing_GetRunStringIndices()

OH_Drawing_Array* OH_Drawing_GetRunStringIndices(OH_Drawing_Run* run, int64_t start, int64_t length)

Description

Obtains an array of character indices of glyphs within a specified range of a run, where the indices are offsets relative to the entire paragraph.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 18

Parameters

NameDescription
OH_Drawing_Run* runPointer to an OH_Drawing_Run object.
int64_t startStart position in the run. If a negative number is passed, a null pointer is returned.
int64_t lengthLength of the range in the run. If the length is 0, the array of all character indices in the run is obtained. If the length is less than 0, a null pointer is returned.

Returns

TypeDescription
OH_Drawing_Array*Returns the character index array of the glyph. Call OH_Drawing_DestroyRunStringIndices to release this pointer when the object is no longer needed.

OH_Drawing_GetRunStringIndicesByIndex()

uint64_t OH_Drawing_GetRunStringIndicesByIndex(OH_Drawing_Array* stringIndices, size_t index)

Description

Obtains character indices of glyphs in a run by index.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 18

Parameters

NameDescription
OH_Drawing_Array* stringIndicesPointer to a character index array.
size_t indexIndex of the character index array.

Returns

TypeDescription
uint64_tReturns the character indices.

OH_Drawing_DestroyRunStringIndices()

void OH_Drawing_DestroyRunStringIndices(OH_Drawing_Array* stringIndices)

Description

Releases the pointer to a character index array object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 18

Parameters

NameDescription
OH_Drawing_Array* stringIndicesPointer to a character index array.

OH_Drawing_GetRunStringRange()

void OH_Drawing_GetRunStringRange(OH_Drawing_Run* run, uint64_t* location, uint64_t* length)

Description

Obtains the range of glyphs generated by a run.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 18

Parameters

NameDescription
OH_Drawing_Run* runPointer to an OH_Drawing_Run object.
uint64_t* locationStart position of the range in the run, which is an offset relative to the entire paragraph.
uint64_t* lengthLength of the range.

OH_Drawing_GetRunTypographicBounds()

float OH_Drawing_GetRunTypographicBounds(OH_Drawing_Run* run, float* ascent, float* descent, float* leading)

Description

Obtains the typographic boundary of a run. The typographic boundary is related to the font and font size used for typography, but not the characters within the text.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 18

Parameters

NameDescription
OH_Drawing_Run* runPointer to an OH_Drawing_Run object.
float* ascentDistance from the top of the tallest character to the baseline in the run.
float* descentDistance from the bottom of the lowest character to the baseline in the run.
float* leadingVertical space between lines in the run.

Returns

TypeDescription
floatReturns the layout width of the run.

OH_Drawing_RunPaint()

void OH_Drawing_RunPaint(OH_Drawing_Canvas* canvas, OH_Drawing_Run* run, double x, double y)

Description

Paints the text contained in a run on the canvas.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 18

Parameters

NameDescription
OH_Drawing_Canvas* canvasPointer to an OH_Drawing_Canvas object.
OH_Drawing_Run* runPointer to an OH_Drawing_Run object.
double xX coordinate of the run.
double yY coordinate of the run.

OH_Drawing_GetRunImageBounds()

OH_Drawing_Rect* OH_Drawing_GetRunImageBounds(OH_Drawing_Run* run)

Description

Obtains the image boundary of a run. The image boundary is related to characters and is equivalent to the visual boundary.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 18

Parameters

NameDescription
OH_Drawing_Run* runPointer to an OH_Drawing_Run object.

Returns

TypeDescription
OH_Drawing_Rect*Returns the pointer to an OH_Drawing_Rect object. Call OH_Drawing_DestroyRunImageBounds to release this pointer when the object is no longer needed.

OH_Drawing_DestroyRunImageBounds()

void OH_Drawing_DestroyRunImageBounds(OH_Drawing_Rect* rect)

Description

Releases the pointer to an image boundary object of a run.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 18

Parameters

NameDescription
OH_Drawing_Rect* rectPointer to the image boundary, which is an OH_Drawing_Rect object.

OH_Drawing_GetRunGlyphs()

OH_Drawing_Array* OH_Drawing_GetRunGlyphs(OH_Drawing_Run* run, int64_t start, int64_t length)

Description

Obtains an array of glyphs within the specified range of a run.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 18

Parameters

NameDescription
OH_Drawing_Run* runPointer to an OH_Drawing_Run object.
int64_t startStart position in the run. If a negative number is passed, a null pointer is returned.
int64_t lengthLength of the range in the run. If the length is 0, all character indices of the run are obtained. If the length is less than 0, a null pointer is returned.

Returns

TypeDescription
OH_Drawing_Array*Returns the pointer to an OH_Drawing_Array object of a glyph array in a run. Call OH_Drawing_DestroyRunGlyphs to release this pointer when the object is no longer needed.

OH_Drawing_GetRunGlyphsByIndex()

uint16_t OH_Drawing_GetRunGlyphsByIndex(OH_Drawing_Array* glyphs, size_t index)

Description

Obtains individual glyphs in a run by index.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 18

Parameters

NameDescription
OH_Drawing_Array* glyphsPointer to the glyph array, which is an OH_Drawing_Array object.
size_t indexIndex of the glyph array.

Returns

TypeDescription
uint16_tReturns the individual glyphs.

OH_Drawing_DestroyRunGlyphs()

void OH_Drawing_DestroyRunGlyphs(OH_Drawing_Array* glyphs)

Description

Releases the pointer to a glyph array in a run.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 18

Parameters

NameDescription
OH_Drawing_Array* glyphsPointer to the glyph array, which is an OH_Drawing_Array object.

OH_Drawing_GetRunPositions()

OH_Drawing_Array* OH_Drawing_GetRunPositions(OH_Drawing_Run* run, int64_t start, int64_t length)

Description

Obtains the positions of glyphs within the specified range of a run.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 18

Parameters

NameDescription
OH_Drawing_Run* runPointer to an OH_Drawing_Run object.
int64_t startStart position in the run. If a negative number is passed, a null pointer is returned.
int64_t lengthLength of the range in the run. If the length is 0, all character indices of the run are obtained. If the length is less than 0, a null pointer is returned.

Returns

TypeDescription
OH_Drawing_Array*Returns the pointer to an OH_Drawing_Array object of a glyph position array in a run. Call OH_Drawing_DestroyRunPositions to release this pointer when the object is no longer needed.

OH_Drawing_GetRunPositionsByIndex()

OH_Drawing_Point* OH_Drawing_GetRunPositionsByIndex(OH_Drawing_Array* positions, size_t index)

Description

Obtains the positions of individual glyphs in a run by index.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 18

Parameters

NameDescription
OH_Drawing_Array* positionsPointer to the glyph position array, which is an OH_Drawing_Array object.
size_t indexIndex of the glyph position array in the run.

Returns

TypeDescription
OH_Drawing_Point*Returns the pointer to an OH_Drawing_Point object, which holds the positions of individual glyphs in the run.

OH_Drawing_DestroyRunPositions()

void OH_Drawing_DestroyRunPositions(OH_Drawing_Array* positions)

Description

Releases the pointer to a glyph position array in a run.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 18

Parameters

NameDescription
OH_Drawing_Array* positionsPointer to the glyph position array, which is an OH_Drawing_Array object.

OH_Drawing_GetRunGlyphCount()

uint32_t OH_Drawing_GetRunGlyphCount(OH_Drawing_Run* run)

Description

Obtains the number of glyphs in a run.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 18

Parameters

NameDescription
OH_Drawing_Run* runPointer to an OH_Drawing_Run object.

Returns

TypeDescription
uint32_tReturns the number of glyphs.

OH_Drawing_GetRunFont()

OH_Drawing_Font* OH_Drawing_GetRunFont(OH_Drawing_Run* run)

Description

Obtains the font object of a run.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 20

Parameters

NameDescription
OH_Drawing_Run* runPointer to an OH_Drawing_Run object.

Returns

TypeDescription
OH_Drawing_Font*Returns the pointer to an OH_Drawing_Font object in a run. Call OH_Drawing_FontDestroy to release this pointer when the object is no longer needed.

OH_Drawing_GetRunTextDirection()

OH_Drawing_TextDirection OH_Drawing_GetRunTextDirection(OH_Drawing_Run* run)

Description

Obtains the text direction of a run.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 20

Parameters

NameDescription
OH_Drawing_Run* runPointer to an OH_Drawing_Run object.

Returns

TypeDescription
OH_Drawing_TextDirectionReturns the text direction of a run. 0: TEXT_DIRECTION_RTL, which means right-to-left; 1: TEXT_DIRECTION_LTR, which means left-to-right. For details, see OH_Drawing_TextDirection.

OH_Drawing_GetRunGlyphAdvances()

OH_Drawing_Array* OH_Drawing_GetRunGlyphAdvances(OH_Drawing_Run* run, uint32_t start, uint32_t length)

Description

Obtains the glyph advance array of a run.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 20

Parameters

NameDescription
OH_Drawing_Run* runPointer to an OH_Drawing_Run object.
uint32_t startStart position in the run. If a negative number is passed, a null pointer is returned.
uint32_t lengthLength of the range in the run. If the length is 0, all glyph advances from the start to the end of the run are obtained. If the length is less than 0, a null pointer is returned.

Returns

TypeDescription
OH_Drawing_Array*Returns the pointer to an OH_Drawing_Array object of a glyph advance array in a run. Call OH_Drawing_DestroyRunGlyphAdvances to release this pointer when the object is no longer needed.

OH_Drawing_GetRunGlyphAdvanceByIndex()

OH_Drawing_Point* OH_Drawing_GetRunGlyphAdvanceByIndex(OH_Drawing_Array* advances, size_t index)

Description

Obtains the advances of individual glyphs in a run by index.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 20

Parameters

NameDescription
OH_Drawing_Array* advancesPointer to the glyph advance array, which is an OH_Drawing_Array object.
size_t indexIndex of the glyph advance array in a run.

Returns

TypeDescription
OH_Drawing_Point*Returns the pointer to an OH_Drawing_Point object, which holds the advance of individual glyphs in the run. x indicates the advance, and y is a reserved field and defaults to 0.

OH_Drawing_DestroyRunGlyphAdvances()

void OH_Drawing_DestroyRunGlyphAdvances(OH_Drawing_Array* advances)

Description

Releases the pointer to a glyph advance array in a run.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 20

Parameters

NameDescription
OH_Drawing_Array* advancesPointer to the glyph advance array, which is an OH_Drawing_Array 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/gzA6yKWq