Reference textWeight()

textWeight()

Sets or gets the current font weight.

The textWeight() function is used to specify the weight (thickness) of the text. When a numeric value is provided, it sets the font weight to that value and updates the rendering properties accordingly (including the "font-variation-settings" on the canvas style). When called without an argument, it returns the current font weight setting.

Examples

Syntax

textWeight(weight)
textWeight()

Parameters

weight
Number: The numeric weight value to set for the text.

Returns

Number: If no arguments are provided, the current font weight
Notice any errors or typos? Please let us know. Please feel free to edit src/type/textCore.js and open a pull request!

Related References