Skip to main content

FontAttr

Typeobject
Backlinks3

The font attributes of a text fragment.

PropertyTypeRequired
classstringRequired
lengthintegerOptional
bordersArray<Border>Optional
fillsArray<Fill>Optional
fillUseTypeintegerOptional
namestringOptional
subFamilyNamestringOptional
postScriptstringOptional
fontVariationsArray<FontVariation>Optional
sizenumberOptional
letterSpacingValuenumberOptional
letterSpacingUnitintegerOptional
lineSpacingValuenumberOptional
lineSpacingUnitintegerOptional
underlineintegerOptional
linethroughbooleanOptional
textCaseintegerOptional
fontVariantCapsintegerOptional
baselineShiftnumberOptional
fontVariantPositionintegerOptional
horizontalScalenumberOptional
verticalScalenumberOptional
rotatenumberOptional
textParagraphTextParagraphOptional
hyperlinkstringOptional

class​

Required

Type

string

Value

constant: the value of this property must be equal to:

"fontAttr"

length​

Optional

Description

The number of characters(UTF-8) that these attributes apply to. If this property is missing, it means these attributes apply to all remaining characters in the text. Note: If a UTF-8 character is 4 bytes, its length counts as 2. If a UTF-8 character is 1 ~ 3 bytes, its length counts as 1.

Type

integer

borders​

Optional

Description

A list of the character's border styles. Priority: The borders of the text fragment > the borders in defaultFontAttr of the text > the borders in the text object's style.

Type

Array<Border>

fills​

Optional

Description

A list of the character's fill effects. The priority of fills is listed in fillUseType.

Type

Array<Fill>

fillUseType​

Optional

Description

The priority of fills.

Type

integer

Value

enum: the value of this property must be equal to one of the following values:

ValueExplanation
0
The fills of the text fragment > the fills in defaultFontAttr of the text > the fills in the text object's style. (Default value)
1
The corresponding property of the object takes precedence over fills. When style.fills and fills each have only one valid solid color object, the opacity of the two solid color objects is combined into the style.fills solid color object.

name​

Optional

Description

Common name of the font. The font name may contain subfamily, in which case the subFamilyName will not appear. If this property does not exist or is empty, the application can fall back to using its default font name.

Type

string

subFamilyName​

Optional

Description

Subfamily name or font type. The value may be empty.

Type

string

postScript​

Optional

Description

The PostScript name of the font. The value may be empty.

Type

string

fontVariations​

Optional

Description

A list of font variations.

Type

Array<FontVariation>

size​

Optional

Description

Font size. Default value is 1.

Type

number

letterSpacingValue​

Optional

Description

Text character spacing value (can be negative). Must be used together with letterSpacingUnit. Default value is 0.

Type

number

letterSpacingUnit​

Optional

Description

The unit of letterSpacingValue value.

Type

integer

Value

enum: the value of this property must be equal to one of the following values:

ValueExplanation
0
pixel (default value)
1
percent. Final pixel value equals to size * letterSpacingValue / 100.

lineSpacingValue​

Optional

Description

The spacing value of the text lines. Must be used together with lineSpacingUnit. Default value is 0.

Type

number

lineSpacingUnit​

Optional

Description

The unit of lineSpacingValue value.

Type

integer

Value

enum: the value of this property must be equal to one of the following values:

ValueExplanation
0
pixel (default value)
1
auto. Use default font metrics height.
2
raw. Final pixel value equals to size * lineSpacingValue.

underline​

Optional

Description

The underline type of the text.

Type

integer

Value

enum: the value of this property must be equal to one of the following values:

ValueExplanation
0
none (default value)
1
single line
2
double line

linethrough​

Optional

Description

Whether the text has a line through. Default value is false.

Type

boolean

textCase​

Optional

Description

The type of text case. Note: textCase and fontVariantCaps are mutually exclusive. If either item is nonzero, you can ignore the value of the other, as they will not be nonzero at the same time.

Type

integer

Value

enum: the value of this property must be equal to one of the following values:

ValueExplanation
0
do nothing (default value)
1
uppercase
2
lowercase
3
title case

fontVariantCaps​

Optional

Description

The type of small caps. Note: textCase and fontVariantCaps are mutually exclusive. If either item is nonzero, you can ignore the value of the other, as they will not be nonzero at the same time.

Type

integer

Value

enum: the value of this property must be equal to one of the following values:

ValueExplanation
0
do nothing (default value)
1
small caps
2
force small caps, including uppercase characters

baselineShift​

Optional

Description

Vertical offset of the text baseline. Default value is 0.

Type

number

fontVariantPosition​

Optional

Description

The position of the text characters.

Type

integer

Value

enum: the value of this property must be equal to one of the following values:

ValueExplanation
0
normal (default value)
1
superscript
2
subscript

horizontalScale​

Optional

Description

Scale the text characters horizontally. Default value is 1. Value examples: 0.5: 50% 1: not scale 1.75: 175% 2: 200%

Type

number

verticalScale​

Optional

Description

Scale the text characters vertically. Default value is 1. Refer to horizontalScale for value examples.

Type

number

rotate​

Optional

Description

Rotation angle of the text characters. Default value is 0.

Type

number

Value

maximum: the value of this number must smaller than or equal to: 180

minimum: the value of this number must greater than or equal to: -180

textParagraph​

Optional

Description

The properties of the text paragraph, which are consistent across the same text paragraph.

Optional

Description

Hyperlink for jump.

Type

string