openharmony 鸿蒙 arkts-apis-graphics-drawing-TypefaceArguments

2026-08-25 浏览 (1)

Class (TypefaceArguments)

This module defines a struct for setting typeface arguments.

NOTE

  • The initial APIs of this module are supported since API version 11. Newly added APIs will be marked with a superscript to indicate their earliest API version.

  • The initial APIs of this class are supported since API version 20.

  • This module uses the physical pixel unit, px.

  • The module operates under a single-threaded model. The caller needs to manage thread safety and context state transitions.

Modules to Import

import { drawing } from '@kit.ArkGraphics2D';

constructor20+

constructor()

Constructor for typeface arguments.

Atomic service API: This API can be used in atomic services since API version 22.

System capability: SystemCapability.Graphics.Drawing

Example

import { drawing } from '@kit.ArkGraphics2D';
let typeFaceArgument = new drawing.TypefaceArguments();

addVariation20+

addVariation(axis: string, value: number)

Defines the typeface weight.

Atomic service API: This API can be used in atomic services since API version 22.

System capability: SystemCapability.Graphics.Drawing

Parameters

NameTypeMandatoryDescription
axisstringYesThe 'wght' tag for the weight variation in the typeFaceArgument object. Whether the tag is supported depends on the loaded typeface file. For details, check the typeface file.
valuenumberYesValue linked to the 'wght' tag for the weight variation in the typeFaceArgument object. The value must be within the range defined in the typeface file. Otherwise, the value does not take effect. Values below the minimum will be set to the minimum and values above the maximum to the maximum. For details, check the typeface file.

Error codes

For details about the following error code, see Drawing and Display Error Codes.

IDError Message
25900001Parameter error.Possible causes: Incorrect parameter range.

Example

import { drawing } from '@kit.ArkGraphics2D';

let typeFaceArgument = new drawing.TypefaceArguments();
typeFaceArgument.addVariation('wght', 10);

你可能感兴趣的鸿蒙文章

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