• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# drawing_font.h
2
3<!--Kit: ArkGraphics 2D-->
4<!--Subsystem: Graphic-->
5<!--Owner: @hangmengxin-->
6<!--Designer: @wangyanglan-->
7<!--Tester: @nobuggers-->
8<!--Adviser: @ge-yafang-->
9
10## 概述
11
12文件中定义了与字体相关的功能函数。
13
14**引用文件:** <native_drawing/drawing_font.h>
15
16**库:** libnative_drawing.so
17
18**起始版本:** 11
19
20**相关模块:** [Drawing](capi-drawing.md)
21
22## 汇总
23
24### 结构体
25
26| 名称 | typedef关键字 | 描述 |
27| -- | -- | -- |
28| [OH_Drawing_Font_Metrics](capi-drawing-oh-drawing-font-metrics.md) | OH_Drawing_Font_Metrics | 定义字体度量信息的结构体。 |
29
30### 枚举
31
32| 名称 | typedef关键字 | 描述 |
33| -- | -- | -- |
34| [OH_Drawing_FontHinting](#oh_drawing_fonthinting) | OH_Drawing_FontHinting | 字型轮廓效果类型枚举。 |
35| [OH_Drawing_FontEdging](#oh_drawing_fontedging) | OH_Drawing_FontEdging | 字型边缘效果类型枚举。 |
36
37### 函数
38
39| 名称 | 描述 |
40| -- | -- |
41| [OH_Drawing_ErrorCode OH_Drawing_FontGetSpacing(const OH_Drawing_Font* font, float* spacing)](#oh_drawing_fontgetspacing) | 用于获取推荐的字型行间距。 |
42| [OH_Drawing_ErrorCode OH_Drawing_FontGetPos(const OH_Drawing_Font* font, const uint16_t* glyphs, int count,const OH_Drawing_Point* origin, OH_Drawing_Point2D* points)](#oh_drawing_fontgetpos) | 用于从指定的原点开始,获取每个字形的相对位置。 |
43| [OH_Drawing_ErrorCode OH_Drawing_FontGetWidthsBounds(const OH_Drawing_Font* font, const uint16_t* glyphs, int count,const OH_Drawing_Brush* brush, const OH_Drawing_Pen* pen, float* widths, OH_Drawing_Array* bounds)](#oh_drawing_fontgetwidthsbounds) | 用于获取字形数组中每个字形的宽度和边界框。 |
44| [OH_Drawing_ErrorCode OH_Drawing_FontMeasureTextWithBrushOrPen(const OH_Drawing_Font* font, const void* text,size_t byteLength, OH_Drawing_TextEncoding encoding, const OH_Drawing_Brush* brush, const OH_Drawing_Pen* pen,OH_Drawing_Rect* bounds, float* textWidth)](#oh_drawing_fontmeasuretextwithbrushorpen) | 使用画刷或画笔获取文本的宽度和边界框。 |
45| [OH_Drawing_Font* OH_Drawing_FontCreate(void)](#oh_drawing_fontcreate) | 用于创建一个字型对象。 |
46| [void OH_Drawing_FontSetBaselineSnap(OH_Drawing_Font* font, bool baselineSnap)](#oh_drawing_fontsetbaselinesnap) | 当前画布矩阵轴对齐时,将字型基线设置为是否与像素对齐。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
47| [bool OH_Drawing_FontIsBaselineSnap(const OH_Drawing_Font* font)](#oh_drawing_fontisbaselinesnap) | 当前画布矩阵轴对齐时,获取字型基线是否与像素对齐。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
48| [void OH_Drawing_FontSetSubpixel(OH_Drawing_Font* font, bool isSubpixel)](#oh_drawing_fontsetsubpixel) | 设置字型是否使用次像素渲染。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
49| [bool OH_Drawing_FontIsSubpixel(const OH_Drawing_Font* font)](#oh_drawing_fontissubpixel) | 获取字型是否使用次像素渲染。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
50| [void OH_Drawing_FontSetForceAutoHinting(OH_Drawing_Font* font, bool isForceAutoHinting)](#oh_drawing_fontsetforceautohinting) | 用于设置是否自动调整字型轮廓。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
51| [bool OH_Drawing_FontIsForceAutoHinting(const OH_Drawing_Font* font)](#oh_drawing_fontisforceautohinting) | 获取字型轮廓是否自动调整。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
52| [void OH_Drawing_FontSetTypeface(OH_Drawing_Font* font, OH_Drawing_Typeface* typeface)](#oh_drawing_fontsettypeface) | 用于给字型设置字体。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
53| [OH_Drawing_Typeface* OH_Drawing_FontGetTypeface(OH_Drawing_Font* font)](#oh_drawing_fontgettypeface) | 获取字体对象。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
54| [void OH_Drawing_FontSetTextSize(OH_Drawing_Font* font, float textSize)](#oh_drawing_fontsettextsize) | 用于给字型对象设置文字大小。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
55| [float OH_Drawing_FontGetTextSize(const OH_Drawing_Font* font)](#oh_drawing_fontgettextsize) | 获取字型对象的文字大小。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
56| [int OH_Drawing_FontCountText(OH_Drawing_Font* font, const void* text, size_t byteLength,OH_Drawing_TextEncoding encoding)](#oh_drawing_fontcounttext) | 获取文本所表示的字符数量。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font、text任意一个为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
57| [uint32_t OH_Drawing_FontTextToGlyphs(const OH_Drawing_Font* font, const void* text, uint32_t byteLength,OH_Drawing_TextEncoding encoding, uint16_t* glyphs, int maxGlyphCount)](#oh_drawing_fonttexttoglyphs) | 用于将文本转换为字形索引。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font、text、glyphs任意一个为NULL或者byteLength等于0或者maxGlyphCount小于等于0时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
58| [void OH_Drawing_FontGetWidths(const OH_Drawing_Font* font, const uint16_t* glyphs, int count, float* widths)](#oh_drawing_fontgetwidths) | 用于获取字符串中每个字符的宽度。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font、glyphs、widths任意一个为NULL或者count小于等于0时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
59| [OH_Drawing_ErrorCode OH_Drawing_FontMeasureSingleCharacter(const OH_Drawing_Font* font, const char* str,float* textWidth)](#oh_drawing_fontmeasuresinglecharacter) | 用于测量单个字符的宽度。当前字型中的字体不支持待测量字符时,退化到使用系统字体测量字符宽度。 |
60| [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)](#oh_drawing_fontmeasuretext) | 用于获取文本的宽度和边界框。 |
61| [void OH_Drawing_FontSetLinearText(OH_Drawing_Font* font, bool isLinearText)](#oh_drawing_fontsetlineartext) | 用于设置线性可缩放字型。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
62| [bool OH_Drawing_FontIsLinearText(const OH_Drawing_Font* font)](#oh_drawing_fontislineartext) | 获取字型对象是否使用线性缩放。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
63| [void OH_Drawing_FontSetTextSkewX(OH_Drawing_Font* font, float skewX)](#oh_drawing_fontsettextskewx) | 用于给字型设置文本倾斜。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
64| [float OH_Drawing_FontGetTextSkewX(const OH_Drawing_Font* font)](#oh_drawing_fontgettextskewx) | 获取字型文本在x轴上的倾斜度。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
65| [void OH_Drawing_FontSetFakeBoldText(OH_Drawing_Font* font, bool isFakeBoldText)](#oh_drawing_fontsetfakeboldtext) | 用于设置增加描边宽度以近似粗体字体效果。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
66| [bool OH_Drawing_FontIsFakeBoldText(const OH_Drawing_Font* font)](#oh_drawing_fontisfakeboldtext) | 获取是否增加笔画宽度以接近粗体字体。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
67| [void OH_Drawing_FontSetScaleX(OH_Drawing_Font* font, float scaleX)](#oh_drawing_fontsetscalex) | 用于设置字型在x轴上的缩放比例。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
68| [float OH_Drawing_FontGetScaleX(const OH_Drawing_Font* font)](#oh_drawing_fontgetscalex) | 获取字型在x轴上的缩放比例。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
69| [void OH_Drawing_FontSetHinting(OH_Drawing_Font* font, OH_Drawing_FontHinting fontHinting)](#oh_drawing_fontsethinting) | 用于设置字型轮廓效果。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER;<br>fontHinting不在枚举范围内时返回OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE。 |
70| [OH_Drawing_FontHinting OH_Drawing_FontGetHinting(const OH_Drawing_Font* font)](#oh_drawing_fontgethinting) | 获取字型轮廓效果枚举类型。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
71| [void OH_Drawing_FontSetEmbeddedBitmaps(OH_Drawing_Font* font, bool isEmbeddedBitmaps)](#oh_drawing_fontsetembeddedbitmaps) | 用于设置字型是否转换成位图处理。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
72| [bool OH_Drawing_FontIsEmbeddedBitmaps(const OH_Drawing_Font* font)](#oh_drawing_fontisembeddedbitmaps) | 获取字型是否转换成位图处理。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
73| [void OH_Drawing_FontSetEdging(OH_Drawing_Font* font, OH_Drawing_FontEdging fontEdging)](#oh_drawing_fontsetedging) | 用于设置字型边缘效果。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER;<br>fontEdging不在枚举范围内时返回OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE。 |
74| [OH_Drawing_FontEdging OH_Drawing_FontGetEdging(const OH_Drawing_Font* font)](#oh_drawing_fontgetedging) | 获取字型边缘效果。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
75| [void OH_Drawing_FontDestroy(OH_Drawing_Font* font)](#oh_drawing_fontdestroy) | 用于销毁字型对象并回收该对象占有的内存。 |
76| [float OH_Drawing_FontGetMetrics(OH_Drawing_Font* font, OH_Drawing_Font_Metrics* fontMetrics)](#oh_drawing_fontgetmetrics) | 获取字体度量信息。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font、fontMetrics任意一个为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
77| [OH_Drawing_ErrorCode OH_Drawing_FontGetBounds(const OH_Drawing_Font* font, const uint16_t* glyphs, uint32_t count,OH_Drawing_Array* bounds)](#oh_drawing_fontgetbounds) | 获取字型指定字形索引的矩形边界。 |
78| [OH_Drawing_ErrorCode OH_Drawing_FontGetPathForGlyph(const OH_Drawing_Font* font, uint16_t glyph,OH_Drawing_Path* path)](#oh_drawing_fontgetpathforglyph) | 获取字型指定字形索引的轮廓。 |
79| [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)](#oh_drawing_fontgettextpath) | 获取文字轮廓路径。 |
80| [OH_Drawing_ErrorCode OH_Drawing_FontSetThemeFontFollowed(OH_Drawing_Font* font, bool followed)](#oh_drawing_fontsetthemefontfollowed) | 设置字型中的字体是否跟随主题字体。设置跟随主题字体后,若系统启用主题字体并且字型未被设置字体,字型会使用该主题字体。 |
81| [OH_Drawing_ErrorCode OH_Drawing_FontIsThemeFontFollowed(const OH_Drawing_Font* font, bool* followed)](#oh_drawing_fontisthemefontfollowed) | 获取字型中的字体是否跟随主题字体。默认不跟随主题字体。 |
82| [OH_Drawing_ErrorCode OH_Drawing_FontMeasureSingleCharacterWithFeatures(const OH_Drawing_Font* font, const char* str,const OH_Drawing_FontFeatures* fontFeatures, float* textWidth)](#oh_drawing_fontmeasuresinglecharacterwithfeatures) | 用于测量单个字符的宽度,字符带有字体特征。当前字型中的字体不支持待测量字符时,退化到使用系统字体测量字符宽度。 |
83| [OH_Drawing_FontFeatures* OH_Drawing_FontFeaturesCreate(void)](#oh_drawing_fontfeaturescreate) | 用于创建一个字体特征容器对象。 |
84| [OH_Drawing_ErrorCode OH_Drawing_FontFeaturesAddFeature(OH_Drawing_FontFeatures* fontFeatures,const char* name, float value)](#oh_drawing_fontfeaturesaddfeature) | 向字体特征容器对象中添加一个字体特征。 |
85| [OH_Drawing_ErrorCode OH_Drawing_FontFeaturesDestroy(OH_Drawing_FontFeatures* fontFeatures)](#oh_drawing_fontfeaturesdestroy) | 用于销毁字体特征容器对象并回收该对象占有的内存。 |
86
87## 枚举类型说明
88
89### OH_Drawing_FontHinting
90
91```
92enum OH_Drawing_FontHinting
93```
94
95**描述**
96
97字型轮廓效果类型枚举。
98
99**起始版本:** 12
100
101| 枚举项 | 描述 |
102| -- | -- |
103| FONT_HINTING_NONE | 不修改字型轮廓。 |
104| FONT_HINTING_SLIGHT | 最小限度修改字型轮廓以改善对比度。 |
105| FONT_HINTING_NORMAL | 修改字型轮廓以提高对比度。 |
106| FONT_HINTING_FULL | 修改字型轮廓以获得最大对比度。 |
107
108### OH_Drawing_FontEdging
109
110```
111enum OH_Drawing_FontEdging
112```
113
114**描述**
115
116字型边缘效果类型枚举。
117
118**起始版本:** 12
119
120| 枚举项 | 描述 |
121| -- | -- |
122| FONT_EDGING_ALIAS | 无抗锯齿处理。 |
123| FONT_EDGING_ANTI_ALIAS | 使用抗锯齿来平滑字型边缘。 |
124| FONT_EDGING_SUBPIXEL_ANTI_ALIAS | 使用次像素级别的抗锯齿来平滑字型边缘,可以获得更加平滑的字型渲染效果。 |
125
126
127## 函数说明
128
129### OH_Drawing_FontMeasureSingleCharacterWithFeatures()
130
131```
132OH_Drawing_ErrorCode OH_Drawing_FontMeasureSingleCharacterWithFeatures(const OH_Drawing_Font* font, const char* str, const OH_Drawing_FontFeatures* fontFeatures, float* textWidth)
133```
134
135**描述**
136
137用于测量单个字符的宽度,字符带有字体特征。当前字型中的字体不支持待测量字符时,退化到使用系统字体测量字符宽度。
138
139**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
140
141**起始版本:** 20
142
143
144**参数:**
145
146| 参数项 | 描述 |
147| -- | -- |
148| [const OH_Drawing_Font](capi-drawing-oh-drawing-font.md)* font | 指向字型对象[OH_Drawing_Font](capi-drawing-oh-drawing-font.md)的指针。 |
149| const char* str | 待测量的单个字符。可以传入字符串,但只会以UTF-8编码解析并测量字符串中的首个字符。 |
150| [const OH_Drawing_FontFeatures](capi-drawing-oh-drawing-fontfeatures.md)* fontFeatures | 指向字体特征容器对象[OH_Drawing_FontFeatures](capi-drawing-oh-drawing-fontfeatures.md)的指针。容器中未加入任何字体特征时使用TTF(TrueType Font)文件中预设的字体特征。 |
151| float* textWidth | 用于存储得到的字符宽度,作为出参使用。 |
152
153**返回:**
154
155| 类型 | 说明 |
156| -- | -- |
157| [OH_Drawing_ErrorCode](capi-drawing-error-code-h.md#oh_drawing_errorcode) | 函数返回执行结果。<br>返回OH_DRAWING_SUCCESS,表示执行成功。<br>返回OH_DRAWING_ERROR_INVALID_PARAMETER,表示参数font、str、fontFeatures或者textWidth任意一个为空指针或者str的长度为0。 |
158
159### OH_Drawing_FontFeaturesCreate()
160
161```
162OH_Drawing_FontFeatures* OH_Drawing_FontFeaturesCreate(void)
163```
164
165**描述**
166
167用于创建一个字体特征容器对象。
168
169**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
170
171**起始版本:** 20
172
173**返回:**
174
175| 类型 | 说明 |
176| -- | -- |
177| [OH_Drawing_FontFeatures](capi-drawing-oh-drawing-fontfeatures.md)* | 函数会返回一个指针,指向创建的字体特征容器对象[OH_Drawing_FontFeatures](capi-drawing-oh-drawing-fontfeatures.md)。<br>如果返回的对象指针为空,则表示字体特征容器对象创建失败。失败的原因可能为:没有可用的内存。 |
178
179### OH_Drawing_FontFeaturesAddFeature()
180
181```
182OH_Drawing_ErrorCode OH_Drawing_FontFeaturesAddFeature(OH_Drawing_FontFeatures* fontFeatures, const char* name, float value)
183```
184
185**描述**
186
187向字体特征容器对象中添加一个字体特征。
188
189**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
190
191**起始版本:** 20
192
193
194**参数:**
195
196| 参数项 | 描述 |
197| -- | -- |
198| [OH_Drawing_FontFeatures](capi-drawing-oh-drawing-fontfeatures.md)* fontFeatures | 指向字体特征容器对象[OH_Drawing_FontFeatures](capi-drawing-oh-drawing-fontfeatures.md)的指针。 |
199| const char* name | 字体特征的名称。常见的字体特征名称包含liga、frac、case等,需要对应的ttf文件支持才能生效。 |
200| float value | 字体特征的数值。建议通过字体查看工具或查阅字体文档,确定具体的有效取值范围。 |
201
202**返回:**
203
204| 类型 | 说明 |
205| -- | -- |
206| [OH_Drawing_ErrorCode](capi-drawing-error-code-h.md#oh_drawing_errorcode) | 函数返回执行结果。<br>返回OH_DRAWING_SUCCESS,表示执行成功。<br>返回OH_DRAWING_ERROR_INVALID_PARAMETER,表示参数fontFeatures或name为空指针。 |
207
208### OH_Drawing_FontFeaturesDestroy()
209
210```
211OH_Drawing_ErrorCode OH_Drawing_FontFeaturesDestroy(OH_Drawing_FontFeatures* fontFeatures)
212```
213
214**描述**
215
216用于销毁字体特征容器对象并回收该对象占有的内存。
217
218**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
219
220**起始版本:** 20
221
222
223**参数:**
224
225| 参数项 | 描述 |
226| -- | -- |
227| [OH_Drawing_FontFeatures](capi-drawing-oh-drawing-fontfeatures.md)* fontFeatures | 指向字体特征容器对象[OH_Drawing_FontFeatures](capi-drawing-oh-drawing-fontfeatures.md)的指针。 |
228
229**返回:**
230
231| 类型 | 说明 |
232| -- | -- |
233| [OH_Drawing_ErrorCode](capi-drawing-error-code-h.md#oh_drawing_errorcode) | 函数返回执行结果。<br>返回OH_DRAWING_SUCCESS,表示执行成功。<br>返回OH_DRAWING_ERROR_INVALID_PARAMETER,表示参数fontFeatures为空指针。 |
234
235### OH_Drawing_FontMeasureTextWithBrushOrPen()
236
237```
238OH_Drawing_ErrorCode OH_Drawing_FontMeasureTextWithBrushOrPen(const OH_Drawing_Font* font, const void* text,size_t byteLength, OH_Drawing_TextEncoding encoding, const OH_Drawing_Brush* brush, const OH_Drawing_Pen* pen,OH_Drawing_Rect* bounds, float* textWidth)
239```
240
241**描述**
242
243使用画刷或画笔获取文本的宽度和边界框。
244
245**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
246
247**起始版本:** 19
248
249**参数:**
250
251| 参数项 | 描述 |
252| -- | -- |
253| const OH_Drawing_Font* font | 指向字型对象[OH_Drawing_Font](capi-drawing-oh-drawing-font.md)的指针。 |
254| const void* text | 指向文本的指针。 |
255| size_t byteLength | 表示以字节为单位的文本长度。 |
256| [OH_Drawing_TextEncoding](capi-drawing-types-h.md#oh_drawing_textencoding) encoding | 文本编码类型。 |
257| const OH_Drawing_Brush* brush | 指向画刷对象[OH_Drawing_Brush](capi-drawing-oh-drawing-brush.md)的指针。 |
258| const OH_Drawing_Pen* pen | 指向画笔对象[OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)的指针。 |
259| OH_Drawing_Rect* bounds | 用于承载获取的边界框,可以为NULL。 |
260| float* textWidth | 表示文本宽度。 |
261
262**返回:**
263
264| 类型 | 说明 |
265| -- | -- |
266| [OH_Drawing_ErrorCode](capi-drawing-error-code-h.md#oh_drawing_errorcode) | 函数返回执行操作码。<br>返回OH_DRAWING_SUCCESS,表示执行成功。<br>返回OH_DRAWING_ERROR_INVALID_PARAMETER,表示参数font、text、textWidth至少有一个为空,或者byteLength为0,或者brush和pen同时存在。 |
267
268### OH_Drawing_FontGetWidthsBounds()
269
270```
271OH_Drawing_ErrorCode OH_Drawing_FontGetWidthsBounds(const OH_Drawing_Font* font, const uint16_t* glyphs, int count,const OH_Drawing_Brush* brush, const OH_Drawing_Pen* pen, float* widths, OH_Drawing_Array* bounds)
272```
273
274**描述**
275
276用于获取字形数组中每个字形的宽度和边界框。
277
278**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
279
280**起始版本:** 19
281
282**参数:**
283
284| 参数项 | 描述 |
285| -- | -- |
286| const OH_Drawing_Font* font | 指向字型对象[OH_Drawing_Font](capi-drawing-oh-drawing-font.md)的指针。 |
287| const uint16_t* glyphs | 字形索引存储首地址。 |
288| int count | 字形索引的数量,大小与glyphs数组大小保持一致。 |
289| const OH_Drawing_Brush* brush | 指向画刷对象[OH_Drawing_Brush](capi-drawing-oh-drawing-brush.md)的指针。 |
290| const OH_Drawing_Pen* pen | 指向画笔对象[OH_Drawing_Pen](capi-drawing-oh-drawing-pen.md)的指针。 |
291| float* widths | 字形宽度存储首地址,用于存储得到的字形宽度,作为返回值返回给调用者。 |
292| OH_Drawing_Array* bounds | 字形边界框存储首地址,用于存储得到的字形边界框。 |
293
294**返回:**
295
296| 类型 | 说明 |
297| -- | -- |
298| [OH_Drawing_ErrorCode](capi-drawing-error-code-h.md#oh_drawing_errorcode) | 函数返回执行操作码。<br>返回OH_DRAWING_SUCCESS,表示执行成功。<br>返回OH_DRAWING_ERROR_INVALID_PARAMETER,表示参数font、glyphs至少有一个为空,或者count不大于0,或者brush和pen同时存在,或者widths和bounds同时为空。 |
299
300### OH_Drawing_FontGetPos()
301
302```
303OH_Drawing_ErrorCode OH_Drawing_FontGetPos(const OH_Drawing_Font* font, const uint16_t* glyphs, int count,const OH_Drawing_Point* origin, OH_Drawing_Point2D* points)
304```
305
306**描述**
307
308用于从指定的原点开始,获取每个字形的相对位置。
309
310**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
311
312**起始版本:** 19
313
314**参数:**
315
316| 参数项 | 描述 |
317| -- | -- |
318| const OH_Drawing_Font* font | 指向字型对象[OH_Drawing_Font](capi-drawing-oh-drawing-font.md)的指针。 |
319| const uint16_t* glyphs | 字形索引存储首地址。 |
320| int count | 字形索引的数量,大小与glyphs数组大小保持一致。 |
321| const OH_Drawing_Point* origin | 指向第一个字形的位置,可以为NULL,为NULL默认从(0, 0)开始。 |
322| [OH_Drawing_Point2D](capi-drawing-oh-drawing-point2d.md)* points | 字形相对位置存储首地址,用于存储得到的字形相对位置,作为返回值返回给调用者。 |
323
324**返回:**
325
326| 类型 | 说明 |
327| -- | -- |
328| [OH_Drawing_ErrorCode](capi-drawing-error-code-h.md#oh_drawing_errorcode) | 函数返回执行操作码。<br>返回OH_DRAWING_SUCCESS,表示执行成功。<br>返回OH_DRAWING_ERROR_INVALID_PARAMETER,表示参数font、glyphs、points至少有一个为空,或者count不大于0。 |
329
330### OH_Drawing_FontGetSpacing()
331
332```
333OH_Drawing_ErrorCode OH_Drawing_FontGetSpacing(const OH_Drawing_Font* font, float* spacing)
334```
335
336**描述**
337
338用于获取推荐的字型行间距。
339
340**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
341
342**起始版本:** 19
343
344**参数:**
345
346| 参数项 | 描述 |
347| -- | -- |
348| const OH_Drawing_Font* font | 指向字型对象[OH_Drawing_Font](capi-drawing-oh-drawing-font.md)的指针。 |
349| float* spacing | 推荐的字型行间距,作为返回值返回给调用者。 |
350
351**返回:**
352
353| 类型 | 说明 |
354| -- | -- |
355| [OH_Drawing_ErrorCode](capi-drawing-error-code-h.md#oh_drawing_errorcode) | 函数返回执行操作码。<br>返回OH_DRAWING_SUCCESS,表示执行成功。<br>返回OH_DRAWING_ERROR_INVALID_PARAMETER,表示参数font、spacing至少有一个为空。 |
356
357### OH_Drawing_FontCreate()
358
359```
360OH_Drawing_Font* OH_Drawing_FontCreate(void)
361```
362
363**描述**
364
365用于创建一个字型对象。
366
367**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
368
369**起始版本:** 11
370
371**返回:**
372
373| 类型 | 说明 |
374| -- | -- |
375| [OH_Drawing_Font](capi-drawing-oh-drawing-font.md)* | 函数会返回一个指针,指针指向创建的字型对象。 |
376
377### OH_Drawing_FontSetBaselineSnap()
378
379```
380void OH_Drawing_FontSetBaselineSnap(OH_Drawing_Font* font, bool baselineSnap)
381```
382
383**描述**
384
385当前画布矩阵轴对齐时,将字型基线设置为是否与像素对齐。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
386
387**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
388
389**起始版本:** 12
390
391
392**参数:**
393
394| 参数项 | 描述 |
395| -- | -- |
396| [OH_Drawing_Font](capi-drawing-oh-drawing-font.md)* font | 指向字型对象[OH_Drawing_Font](capi-drawing-oh-drawing-font.md)的指针。 |
397| bool baselineSnap | 指示字型基线是否和像素对齐。true表示对齐,false表示不对齐。 |
398
399### OH_Drawing_FontIsBaselineSnap()
400
401```
402bool OH_Drawing_FontIsBaselineSnap(const OH_Drawing_Font* font)
403```
404
405**描述**
406
407当前画布矩阵轴对齐时,获取字型基线是否与像素对齐。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
408
409**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
410
411**起始版本:** 12
412
413
414**参数:**
415
416| 参数项 | 描述 |
417| -- | -- |
418| const [OH_Drawing_Font](capi-drawing-oh-drawing-font.md)* font | 指向字型对象[OH_Drawing_Font](capi-drawing-oh-drawing-font.md)的指针。 |
419
420**返回:**
421
422| 类型 | 说明 |
423| -- | -- |
424| bool | 返回字型基线是否与像素对齐。true为对齐,false为没有对齐。 |
425
426### OH_Drawing_FontSetSubpixel()
427
428```
429void OH_Drawing_FontSetSubpixel(OH_Drawing_Font* font, bool isSubpixel)
430```
431
432**描述**
433
434设置字型是否使用次像素渲染。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
435
436**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
437
438**起始版本:** 12
439
440
441**参数:**
442
443| 参数项 | 描述 |
444| -- | -- |
445| [OH_Drawing_Font](capi-drawing-oh-drawing-font.md)* font | 指向字型对象[OH_Drawing_Font](capi-drawing-oh-drawing-font.md)的指针。 |
446| bool isSubpixel | 字型是否使用次像素渲染。true为使用,false为不使用。 |
447
448### OH_Drawing_FontIsSubpixel()
449
450```
451bool OH_Drawing_FontIsSubpixel(const OH_Drawing_Font* font)
452```
453
454**描述**
455
456获取字型是否使用次像素渲染。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
457
458**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
459
460**起始版本:** 12
461
462
463**参数:**
464
465| 参数项 | 描述 |
466| -- | -- |
467| const [OH_Drawing_Font](capi-drawing-oh-drawing-font.md)* font | 指向字型对象[OH_Drawing_Font](capi-drawing-oh-drawing-font.md)的指针。 |
468
469**返回:**
470
471| 类型 | 说明 |
472| -- | -- |
473| bool | 返回字型是否使用次像素渲染。true为使用,false为不使用。 |
474
475### OH_Drawing_FontSetForceAutoHinting()
476
477```
478void OH_Drawing_FontSetForceAutoHinting(OH_Drawing_Font* font, bool isForceAutoHinting)
479```
480
481**描述**
482
483用于设置是否自动调整字型轮廓。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
484
485**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
486
487**起始版本:** 12
488
489
490**参数:**
491
492| 参数项 | 描述 |
493| -- | -- |
494| [OH_Drawing_Font](capi-drawing-oh-drawing-font.md)* font | 指向字型对象[OH_Drawing_Font](capi-drawing-oh-drawing-font.md)的指针。 |
495| bool isForceAutoHinting | 是否自动调整字型轮廓。true为自动调整,false为不自动调整。 |
496
497### OH_Drawing_FontIsForceAutoHinting()
498
499```
500bool OH_Drawing_FontIsForceAutoHinting(const OH_Drawing_Font* font)
501```
502
503**描述**
504
505获取字型轮廓是否自动调整。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
506
507**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
508
509**起始版本:** 12
510
511
512**参数:**
513
514| 参数项 | 描述 |
515| -- | -- |
516| const [OH_Drawing_Font](capi-drawing-oh-drawing-font.md)* font | 指向字型对象[OH_Drawing_Font](capi-drawing-oh-drawing-font.md)的指针。 |
517
518**返回:**
519
520| 类型 | 说明 |
521| -- | -- |
522| bool | 返回字型轮廓是否自动调整。true为自动调整,false为不自动调整。 |
523
524### OH_Drawing_FontSetTypeface()
525
526```
527void OH_Drawing_FontSetTypeface(OH_Drawing_Font* font, OH_Drawing_Typeface* typeface)
528```
529
530**描述**
531
532用于给字型设置字体。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
533
534**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
535
536**起始版本:** 11
537
538
539**参数:**
540
541| 参数项 | 描述 |
542| -- | -- |
543| [OH_Drawing_Font](capi-drawing-oh-drawing-font.md)* font | 指向字型对象的指针。 |
544| [OH_Drawing_Typeface](capi-drawing-oh-drawing-typeface.md)* typeface | 指向字体对象的指针,为NULL会使用系统默认字体对象。 |
545
546### OH_Drawing_FontGetTypeface()
547
548```
549OH_Drawing_Typeface* OH_Drawing_FontGetTypeface(OH_Drawing_Font* font)
550```
551
552**描述**
553
554获取字体对象。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
555
556**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
557
558**起始版本:** 12
559
560
561**参数:**
562
563| 参数项 | 描述 |
564| -- | -- |
565| [OH_Drawing_Font](capi-drawing-oh-drawing-font.md)* font | 指向字型对象[OH_Drawing_Font](capi-drawing-oh-drawing-font.md)的指针。 |
566
567**返回:**
568
569| 类型 | 说明 |
570| -- | -- |
571| [OH_Drawing_Typeface](capi-drawing-oh-drawing-typeface.md)* | OH_Drawing_Typeface 函数返回一个指针,指向字体对象[OH_Drawing_Typeface](capi-drawing-oh-drawing-typeface.md)。 |
572
573### OH_Drawing_FontSetTextSize()
574
575```
576void OH_Drawing_FontSetTextSize(OH_Drawing_Font* font, float textSize)
577```
578
579**描述**
580
581用于给字型对象设置文字大小。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
582
583**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
584
585**起始版本:** 11
586
587
588**参数:**
589
590| 参数项 | 描述 |
591| -- | -- |
592| [OH_Drawing_Font](capi-drawing-oh-drawing-font.md)* font | 指向字型对象的指针。 |
593| float textSize | 文字大小,该参数为浮点数,为负数时字体大小会被置为0。字体大小为0时,绘制的文字不会显示。 |
594
595### OH_Drawing_FontGetTextSize()
596
597```
598float OH_Drawing_FontGetTextSize(const OH_Drawing_Font* font)
599```
600
601**描述**
602
603获取字型对象的文字大小。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
604
605**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
606
607**起始版本:** 12
608
609
610**参数:**
611
612| 参数项 | 描述 |
613| -- | -- |
614| const [OH_Drawing_Font](capi-drawing-oh-drawing-font.md)* font | 指向字型对象[OH_Drawing_Font](capi-drawing-oh-drawing-font.md)的指针。 |
615
616**返回:**
617
618| 类型 | 说明 |
619| -- | -- |
620| float | 返回一个浮点数,表示文字大小。 |
621
622### OH_Drawing_FontCountText()
623
624```
625int OH_Drawing_FontCountText(OH_Drawing_Font* font, const void* text, size_t byteLength,OH_Drawing_TextEncoding encoding)
626```
627
628**描述**
629
630获取文本所表示的字符数量。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font、text任意一个为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
631
632**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
633
634**起始版本:** 12
635
636
637**参数:**
638
639| 参数项 | 描述 |
640| -- | -- |
641| [OH_Drawing_Font](capi-drawing-oh-drawing-font.md)* font | 指向字型对象[OH_Drawing_Font](capi-drawing-oh-drawing-font.md)的指针。 |
642| const void* text | 文本存储首地址。 |
643| size_t byteLength | 文本长度,单位为字节。 |
644| [OH_Drawing_TextEncoding](capi-drawing-types-h.md#oh_drawing_textencoding) encoding | 文本编码类型[OH_Drawing_TextEncoding](capi-drawing-types-h.md#oh_drawing_textencoding)。 |
645
646### OH_Drawing_FontTextToGlyphs()
647
648```
649uint32_t OH_Drawing_FontTextToGlyphs(const OH_Drawing_Font* font, const void* text, uint32_t byteLength,OH_Drawing_TextEncoding encoding, uint16_t* glyphs, int maxGlyphCount)
650```
651
652**描述**
653
654用于将文本转换为字形索引。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font、text、glyphs任意一个为NULL或者byteLength等于0或者maxGlyphCount小于等于0时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
655
656**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
657
658**起始版本:** 12
659
660
661**参数:**
662
663| 参数项 | 描述 |
664| -- | -- |
665| const [OH_Drawing_Font](capi-drawing-oh-drawing-font.md)* font | 指向字型对象[OH_Drawing_Font](capi-drawing-oh-drawing-font.md)的指针。 |
666| const void* text | 文本存储首地址。 |
667| uint32_t byteLength | 文本长度,单位为字节。 |
668| [OH_Drawing_TextEncoding](capi-drawing-types-h.md#oh_drawing_textencoding) encoding | 文本编码类型[OH_Drawing_TextEncoding](capi-drawing-types-h.md#oh_drawing_textencoding)。 |
669| uint16_t* glyphs | 字形索引存储首地址,用于存储得到的字形索引。 |
670| int maxGlyphCount | 文本所表示的最大字符数量。 |
671
672**返回:**
673
674| 类型 | 说明 |
675| -- | -- |
676| uint32_t | 返回字形索引数量。 |
677
678### OH_Drawing_FontGetWidths()
679
680```
681void OH_Drawing_FontGetWidths(const OH_Drawing_Font* font, const uint16_t* glyphs, int count, float* widths)
682```
683
684**描述**
685
686用于获取字符串中每个字符的宽度。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font、glyphs、widths任意一个为NULL或者count小于等于0时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
687
688**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
689
690**起始版本:** 12
691
692
693**参数:**
694
695| 参数项 | 描述 |
696| -- | -- |
697| const [OH_Drawing_Font](capi-drawing-oh-drawing-font.md)* font | 指向字型对象[OH_Drawing_Font](capi-drawing-oh-drawing-font.md)的指针。 |
698| const uint16_t* glyphs | 字形索引存储首地址。 |
699| int count | 字形索引的数量。 |
700| float* widths | 字形宽度存储首地址,用于存储得到的字形宽度。 |
701
702### OH_Drawing_FontMeasureSingleCharacter()
703
704```
705OH_Drawing_ErrorCode OH_Drawing_FontMeasureSingleCharacter(const OH_Drawing_Font* font, const char* str,float* textWidth)
706```
707
708**描述**
709
710用于测量单个字符的宽度。当前字型中的字体不支持待测量字符时,退化到使用系统字体测量字符宽度。
711
712**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
713
714**起始版本:** 12
715
716
717**参数:**
718
719| 参数项 | 描述 |
720| -- | -- |
721| const [OH_Drawing_Font](capi-drawing-oh-drawing-font.md)* font | 指向字型对象[OH_Drawing_Font](capi-drawing-oh-drawing-font.md)的指针。 |
722| const char* str | 待测量的单个字符。可以传入字符串,但只会以UTF-8编码解析并测量字符串中的首个字符。 |
723| float* textWidth | 用于存储得到的字符宽度。 |
724
725**返回:**
726
727| 类型 | 说明 |
728| -- | -- |
729| [OH_Drawing_ErrorCode](capi-drawing-error-code-h.md#oh_drawing_errorcode) | 函数返回执行错误码。<br> 返回OH_DRAWING_SUCCESS,表示执行成功。<br> 返回OH_DRAWING_ERROR_INVALID_PARAMETER,表示参数font、str、textWidth任意一个为NULL或者str的长度为0。 |
730
731### OH_Drawing_FontMeasureText()
732
733```
734OH_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)
735```
736
737**描述**
738
739用于获取文本的宽度和边界框。
740
741**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
742
743**起始版本:** 12
744
745
746**参数:**
747
748| 参数项 | 描述 |
749| -- | -- |
750| const [OH_Drawing_Font](capi-drawing-oh-drawing-font.md)* font | 指向字型对象[OH_Drawing_Font](capi-drawing-oh-drawing-font.md)的指针。 |
751| const void* text | 指向文本的指针。 |
752| size_t byteLength | 表示以字节为单位的文本长度。 |
753| [OH_Drawing_TextEncoding](capi-drawing-types-h.md#oh_drawing_textencoding) encoding | 文本编码类型。 |
754| [OH_Drawing_Rect](capi-drawing-oh-drawing-rect.md)* bounds | 用于承载获取的边界框,可以为NULL。 |
755| float* textWidth | 表示文本宽度。 |
756
757**返回:**
758
759| 类型 | 说明 |
760| -- | -- |
761| [OH_Drawing_ErrorCode](capi-drawing-error-code-h.md#oh_drawing_errorcode) | 函数返回执行错误码。<br> 返回OH_DRAWING_SUCCESS,表示执行成功。<br> 返回OH_DRAWING_ERROR_INVALID_PARAMETER,表示参数font,text,textWidth至少有一个为空,或者byteLength为0。 |
762
763### OH_Drawing_FontSetLinearText()
764
765```
766void OH_Drawing_FontSetLinearText(OH_Drawing_Font* font, bool isLinearText)
767```
768
769**描述**
770
771用于设置线性可缩放字型。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
772
773**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
774
775**起始版本:** 11
776
777
778**参数:**
779
780| 参数项 | 描述 |
781| -- | -- |
782| [OH_Drawing_Font](capi-drawing-oh-drawing-font.md)* font | 指向字型对象的指针。 |
783| bool isLinearText | 真为使能线性可缩放字型,假为不使能。 |
784
785### OH_Drawing_FontIsLinearText()
786
787```
788bool OH_Drawing_FontIsLinearText(const OH_Drawing_Font* font)
789```
790
791**描述**
792
793获取字型对象是否使用线性缩放。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
794
795**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
796
797**起始版本:** 12
798
799
800**参数:**
801
802| 参数项 | 描述 |
803| -- | -- |
804| const [OH_Drawing_Font](capi-drawing-oh-drawing-font.md)* font | 指向字型对象[OH_Drawing_Font](capi-drawing-oh-drawing-font.md)的指针。 |
805
806**返回:**
807
808| 类型 | 说明 |
809| -- | -- |
810| bool | 返回字型对象是否使用线性缩放,true为使用,false为不使用。 |
811
812### OH_Drawing_FontSetTextSkewX()
813
814```
815void OH_Drawing_FontSetTextSkewX(OH_Drawing_Font* font, float skewX)
816```
817
818**描述**
819
820用于给字型设置文本倾斜。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
821
822**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
823
824**起始版本:** 11
825
826
827**参数:**
828
829| 参数项 | 描述 |
830| -- | -- |
831| [OH_Drawing_Font](capi-drawing-oh-drawing-font.md)* font | 指向字型对象的指针。 |
832| float skewX | 轴相对于Y轴的倾斜度。 |
833
834### OH_Drawing_FontGetTextSkewX()
835
836```
837float OH_Drawing_FontGetTextSkewX(const OH_Drawing_Font* font)
838```
839
840**描述**
841
842获取字型文本在x轴上的倾斜度。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
843
844**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
845
846**起始版本:** 12
847
848
849**参数:**
850
851| 参数项 | 描述 |
852| -- | -- |
853| const [OH_Drawing_Font](capi-drawing-oh-drawing-font.md)* font | 指向字型对象[OH_Drawing_Font](capi-drawing-oh-drawing-font.md)的指针。 |
854
855**返回:**
856
857| 类型 | 说明 |
858| -- | -- |
859| float | 返回一个浮点数,表示x轴上的文本倾斜度。 |
860
861### OH_Drawing_FontSetFakeBoldText()
862
863```
864void OH_Drawing_FontSetFakeBoldText(OH_Drawing_Font* font, bool isFakeBoldText)
865```
866
867**描述**
868
869用于设置增加描边宽度以近似粗体字体效果。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
870
871**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
872
873**起始版本:** 11
874
875
876**参数:**
877
878| 参数项 | 描述 |
879| -- | -- |
880| [OH_Drawing_Font](capi-drawing-oh-drawing-font.md)* font | 指向字型对象的指针。 |
881| bool isFakeBoldText | 真为使能增加描边宽度,假为不使能。 |
882
883### OH_Drawing_FontIsFakeBoldText()
884
885```
886bool OH_Drawing_FontIsFakeBoldText(const OH_Drawing_Font* font)
887```
888
889**描述**
890
891获取是否增加笔画宽度以接近粗体字体。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
892
893**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
894
895**起始版本:** 12
896
897
898**参数:**
899
900| 参数项 | 描述 |
901| -- | -- |
902| const [OH_Drawing_Font](capi-drawing-oh-drawing-font.md)* font | 指向字型对象[OH_Drawing_Font](capi-drawing-oh-drawing-font.md)的指针。 |
903
904**返回:**
905
906| 类型 | 说明 |
907| -- | -- |
908| bool | 返回是否增加笔画宽度以接近粗体字体。true为增加,false为不增加。 |
909
910### OH_Drawing_FontSetScaleX()
911
912```
913void OH_Drawing_FontSetScaleX(OH_Drawing_Font* font, float scaleX)
914```
915
916**描述**
917
918用于设置字型在x轴上的缩放比例。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
919
920**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
921
922**起始版本:** 12
923
924
925**参数:**
926
927| 参数项 | 描述 |
928| -- | -- |
929| [OH_Drawing_Font](capi-drawing-oh-drawing-font.md)* font | 指向字型对象[OH_Drawing_Font](capi-drawing-oh-drawing-font.md)的指针。 |
930| float scaleX | 文本在x轴上的缩放比例。 |
931
932### OH_Drawing_FontGetScaleX()
933
934```
935float OH_Drawing_FontGetScaleX(const OH_Drawing_Font* font)
936```
937
938**描述**
939
940获取字型在x轴上的缩放比例。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
941
942**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
943
944**起始版本:** 12
945
946
947**参数:**
948
949| 参数项 | 描述 |
950| -- | -- |
951| const [OH_Drawing_Font](capi-drawing-oh-drawing-font.md)* font | 指向字型对象[OH_Drawing_Font](capi-drawing-oh-drawing-font.md)的指针。 |
952
953**返回:**
954
955| 类型 | 说明 |
956| -- | -- |
957| float | 返回文本在x轴上的缩放比例。 |
958
959### OH_Drawing_FontSetHinting()
960
961```
962void OH_Drawing_FontSetHinting(OH_Drawing_Font* font, OH_Drawing_FontHinting fontHinting)
963```
964
965**描述**
966
967用于设置字型轮廓效果。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER;<br>fontHinting不在枚举范围内时返回OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE。
968
969**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
970
971**起始版本:** 12
972
973
974**参数:**
975
976| 参数项 | 描述 |
977| -- | -- |
978| [OH_Drawing_Font](capi-drawing-oh-drawing-font.md)* font | 指向字型对象[OH_Drawing_Font](capi-drawing-oh-drawing-font.md)的指针。 |
979| [OH_Drawing_FontHinting](#oh_drawing_fonthinting) fontHinting | 字型轮廓枚举类型[OH_Drawing_FontHinting](capi-drawing-font-h.md#oh_drawing_fonthinting)。 |
980
981### OH_Drawing_FontGetHinting()
982
983```
984OH_Drawing_FontHinting OH_Drawing_FontGetHinting(const OH_Drawing_Font* font)
985```
986
987**描述**
988
989获取字型轮廓效果枚举类型。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
990
991**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
992
993**起始版本:** 12
994
995
996**参数:**
997
998| 参数项 | 描述 |
999| -- | -- |
1000| const [OH_Drawing_Font](capi-drawing-oh-drawing-font.md)* font | 指向字型对象[OH_Drawing_Font](capi-drawing-oh-drawing-font.md)的指针。 |
1001
1002**返回:**
1003
1004| 类型 | 说明 |
1005| -- | -- |
1006| [OH_Drawing_FontHinting](#oh_drawing_fonthinting) | OH_Drawing_FontHinting 返回字型轮廓效果枚举类型[OH_Drawing_FontHinting](capi-drawing-font-h.md#oh_drawing_fonthinting)。 |
1007
1008### OH_Drawing_FontSetEmbeddedBitmaps()
1009
1010```
1011void OH_Drawing_FontSetEmbeddedBitmaps(OH_Drawing_Font* font, bool isEmbeddedBitmaps)
1012```
1013
1014**描述**
1015
1016用于设置字型是否转换成位图处理。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
1017
1018**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
1019
1020**起始版本:** 12
1021
1022
1023**参数:**
1024
1025| 参数项 | 描述 |
1026| -- | -- |
1027| [OH_Drawing_Font](capi-drawing-oh-drawing-font.md)* font | 指向字型对象[OH_Drawing_Font](capi-drawing-oh-drawing-font.md)的指针。 |
1028| bool isEmbeddedBitmaps | 设置字型是否转换成位图处理,true表示转换成位图处理,false表示不转换成位图处理。 |
1029
1030### OH_Drawing_FontIsEmbeddedBitmaps()
1031
1032```
1033bool OH_Drawing_FontIsEmbeddedBitmaps(const OH_Drawing_Font* font)
1034```
1035
1036**描述**
1037
1038获取字型是否转换成位图处理。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
1039
1040**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
1041
1042**起始版本:** 12
1043
1044
1045**参数:**
1046
1047| 参数项 | 描述 |
1048| -- | -- |
1049| const [OH_Drawing_Font](capi-drawing-oh-drawing-font.md)* font | 指向字型对象[OH_Drawing_Font](capi-drawing-oh-drawing-font.md)的指针。 |
1050
1051**返回:**
1052
1053| 类型 | 说明 |
1054| -- | -- |
1055| bool | 返回字型是否转换成位图处理,true表示转换成位图处理,false表示不转换成位图处理。 |
1056
1057### OH_Drawing_FontSetEdging()
1058
1059```
1060void OH_Drawing_FontSetEdging(OH_Drawing_Font* font, OH_Drawing_FontEdging fontEdging)
1061```
1062
1063**描述**
1064
1065用于设置字型边缘效果。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER;<br>fontEdging不在枚举范围内时返回OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE。
1066
1067**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
1068
1069**起始版本:** 12
1070
1071
1072**参数:**
1073
1074| 参数项 | 描述 |
1075| -- | -- |
1076| [OH_Drawing_Font](capi-drawing-oh-drawing-font.md)* font | 指向字型对象[OH_Drawing_Font](capi-drawing-oh-drawing-font.md)的指针。 |
1077| [OH_Drawing_FontEdging](#oh_drawing_fontedging) fontEdging | 字型边缘效果。 |
1078
1079### OH_Drawing_FontGetEdging()
1080
1081```
1082OH_Drawing_FontEdging OH_Drawing_FontGetEdging(const OH_Drawing_Font* font)
1083```
1084
1085**描述**
1086
1087获取字型边缘效果。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
1088
1089**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
1090
1091**起始版本:** 12
1092
1093
1094**参数:**
1095
1096| 参数项 | 描述 |
1097| -- | -- |
1098| const [OH_Drawing_Font](capi-drawing-oh-drawing-font.md)* font | 指向字型对象[OH_Drawing_Font](capi-drawing-oh-drawing-font.md)的指针。 |
1099
1100**返回:**
1101
1102| 类型 | 说明 |
1103| -- | -- |
1104| [OH_Drawing_FontEdging](#oh_drawing_fontedging) | 返回字型边缘效果。 |
1105
1106### OH_Drawing_FontDestroy()
1107
1108```
1109void OH_Drawing_FontDestroy(OH_Drawing_Font* font)
1110```
1111
1112**描述**
1113
1114用于销毁字型对象并回收该对象占有的内存。
1115
1116**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
1117
1118**起始版本:** 11
1119
1120
1121**参数:**
1122
1123| 参数项 | 描述 |
1124| -- | -- |
1125| [OH_Drawing_Font](capi-drawing-oh-drawing-font.md)* font | 指向字型对象的指针。 |
1126
1127### OH_Drawing_FontGetMetrics()
1128
1129```
1130float OH_Drawing_FontGetMetrics(OH_Drawing_Font* font, OH_Drawing_Font_Metrics* fontMetrics)
1131```
1132
1133**描述**
1134
1135获取字体度量信息。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>font、fontMetrics任意一个为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
1136
1137**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
1138
1139**起始版本:** 12
1140
1141
1142**参数:**
1143
1144| 参数项 | 描述 |
1145| -- | -- |
1146| [OH_Drawing_Font](capi-drawing-oh-drawing-font.md)* font | 指向字型对象[OH_Drawing_Font](capi-drawing-oh-drawing-font.md)的指针。 |
1147| [OH_Drawing_Font_Metrics](capi-drawing-oh-drawing-font-metrics.md)* fontMetrics | 指向字体度量信息对象[OH_Drawing_Font_Metrics](capi-drawing-oh-drawing-font-metrics.md)的指针。 |
1148
1149**返回:**
1150
1151| 类型 | 说明 |
1152| -- | -- |
1153| float | 函数返回一个浮点数变量,表示建议的行间距。 |
1154
1155### OH_Drawing_FontGetBounds()
1156
1157```
1158OH_Drawing_ErrorCode OH_Drawing_FontGetBounds(const OH_Drawing_Font* font, const uint16_t* glyphs, uint32_t count,OH_Drawing_Array* bounds)
1159```
1160
1161**描述**
1162
1163获取字型指定字形索引的矩形边界。
1164
1165**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
1166
1167**起始版本:** 18
1168
1169
1170**参数:**
1171
1172| 参数项 | 描述 |
1173| -- | -- |
1174| const [OH_Drawing_Font](capi-drawing-oh-drawing-font.md)* font | 指向字型对象[OH_Drawing_Font](capi-drawing-oh-drawing-font.md)的指针。 |
1175| const uint16_t* glyphs | 字形索引数组。 |
1176| uint32_t count | 字形数组的长度。 |
1177| [OH_Drawing_Array](capi-drawing-oh-drawing-array.md)* bounds | 矩形边界数组。 |
1178
1179**返回:**
1180
1181| 类型 | 说明 |
1182| -- | -- |
1183| [OH_Drawing_ErrorCode](capi-drawing-error-code-h.md#oh_drawing_errorcode) | 函数返回执行错误码。<br> 返回OH_DRAWING_SUCCESS,表示执行成功。<br> 返回OH_DRAWING_ERROR_INVALID_PARAMETER,表示参数font、glyphs或bounds为空,或者count为零。 |
1184
1185### OH_Drawing_FontGetPathForGlyph()
1186
1187```
1188OH_Drawing_ErrorCode OH_Drawing_FontGetPathForGlyph(const OH_Drawing_Font* font, uint16_t glyph,OH_Drawing_Path* path)
1189```
1190
1191**描述**
1192
1193获取字型指定字形索引的轮廓。
1194
1195**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
1196
1197**起始版本:** 18
1198
1199
1200**参数:**
1201
1202| 参数项 | 描述 |
1203| -- | -- |
1204| const [OH_Drawing_Font](capi-drawing-oh-drawing-font.md)* font | 指向字型对象[OH_Drawing_Font](capi-drawing-oh-drawing-font.md)的指针。 |
1205| uint16_t glyph | 指定的字形索引。 |
1206| [OH_Drawing_Path](capi-drawing-oh-drawing-path.md)* path | 指向路径对象[OH_Drawing_Path](capi-drawing-oh-drawing-path.md)的指针, 用于存储得到的字形路径。 |
1207
1208**返回:**
1209
1210| 类型 | 说明 |
1211| -- | -- |
1212| [OH_Drawing_ErrorCode](capi-drawing-error-code-h.md#oh_drawing_errorcode) | 函数返回执行错误码。<br> 返回OH_DRAWING_SUCCESS,表示执行成功。<br> 返回OH_DRAWING_ERROR_INVALID_PARAMETER,表示参数font或者path为空, 或者指定glyph不存在。 |
1213
1214### OH_Drawing_FontGetTextPath()
1215
1216```
1217OH_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)
1218```
1219
1220**描述**
1221
1222获取文字轮廓路径。
1223
1224**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
1225
1226**起始版本:** 18
1227
1228
1229**参数:**
1230
1231| 参数项 | 描述 |
1232| -- | -- |
1233| const [OH_Drawing_Font](capi-drawing-oh-drawing-font.md)* font | 指示字型对象[OH_Drawing_Font](capi-drawing-oh-drawing-font.md)的指针。 |
1234| const void* text | 指示要获取轮廓路径的文本字符串。 |
1235| size_t byteLength | 指示要获取对应文本路径的字节长度,如果此字节长度大于text字符串的字节长度,会发生未定义行为。 |
1236| [OH_Drawing_TextEncoding](capi-drawing-types-h.md#oh_drawing_textencoding) encoding | 指示文本编码格式,支持 UTF-8、UTF-16、UTF-32,以及字形索引,具体类型格式可见[OH_Drawing_TextEncoding](capi-drawing-types-h.md#oh_drawing_textencoding)。 |
1237| float x | 指示文本在绘图区域内以原点为起始位置的X坐标。 |
1238| float y | 指示文本在绘图区域内以原点为起始位置的Y坐标。 |
1239| [OH_Drawing_Path](capi-drawing-oh-drawing-path.md)* path | 返回获取到的文字轮廓路径对象,作为出参使用。 |
1240
1241**返回:**
1242
1243| 类型 | 说明 |
1244| -- | -- |
1245| [OH_Drawing_ErrorCode](capi-drawing-error-code-h.md#oh_drawing_errorcode) | 返回错误代码。<br> 如果操作成功,则返回 [OH_DRAWING_SUCCESS](capi-drawing-error-code-h.md#oh_drawing_errorcode)。<br> 如果 font、text 或 path 中的任何一个为空指针,则返回 [OH_DRAWING_ERROR_INVALID_PARAMETER](capi-drawing-error-code-h.md#oh_drawing_errorcode)。 |
1246
1247### OH_Drawing_FontSetThemeFontFollowed()
1248
1249```
1250OH_Drawing_ErrorCode OH_Drawing_FontSetThemeFontFollowed(OH_Drawing_Font* font, bool followed)
1251```
1252
1253**描述**
1254
1255设置字型中的字体是否跟随主题字体。设置跟随主题字体后,若系统启用主题字体并且字型未被设置字体,字型会使用该主题字体。
1256
1257**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
1258
1259**起始版本:** 15
1260
1261
1262**参数:**
1263
1264| 参数项 | 描述 |
1265| -- | -- |
1266| [OH_Drawing_Font](capi-drawing-oh-drawing-font.md)* font | 指示字型对象[OH_Drawing_Font](capi-drawing-oh-drawing-font.md)的指针。 |
1267| bool followed | 字型中的字体是否跟随主题字体,true表示跟随主题字体,false表示不跟随主题字体。 |
1268
1269**返回:**
1270
1271| 类型 | 说明 |
1272| -- | -- |
1273| [OH_Drawing_ErrorCode](capi-drawing-error-code-h.md#oh_drawing_errorcode) | 函数返回执行错误码。<br> 返回OH_DRAWING_SUCCESS,表示执行成功。<br> 返回OH_DRAWING_ERROR_INVALID_PARAMETER,表示参数font为空。 |
1274
1275### OH_Drawing_FontIsThemeFontFollowed()
1276
1277```
1278OH_Drawing_ErrorCode OH_Drawing_FontIsThemeFontFollowed(const OH_Drawing_Font* font, bool* followed)
1279```
1280
1281**描述**
1282
1283获取字型中的字体是否跟随主题字体。默认不跟随主题字体。
1284
1285**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
1286
1287**起始版本:** 15
1288
1289
1290**参数:**
1291
1292| 参数项 | 描述 |
1293| -- | -- |
1294| const [OH_Drawing_Font](capi-drawing-oh-drawing-font.md)* font | 指示字型对象[OH_Drawing_Font](capi-drawing-oh-drawing-font.md)的指针。 |
1295| bool* followed | 返回字型中的字体是否跟随主题字体的结果,true表示跟随主题字体,false表示不跟随主题字体。作为出参使用。 |
1296
1297**返回:**
1298
1299| 类型 | 说明 |
1300| -- | -- |
1301| [OH_Drawing_ErrorCode](capi-drawing-error-code-h.md#oh_drawing_errorcode) | 函数返回执行错误码。<br> 返回OH_DRAWING_SUCCESS,表示执行成功。<br> 返回OH_DRAWING_ERROR_INVALID_PARAMETER,表示参数font或者followed其中一个为空。 |
1302
1303
1304