This API is used via wx.loadFontFace(Object object).
Attribute | Type | Default value | Required | Description |
global | boolean | false | No | Is it globally effective? |
family | string | - | Yes | Defined font name |
source | string | - | Yes | The address of the font resource. The recommended formats are TTF and WOFF, as WOFF2 may not be compatible with older versions of iOS. |
desc | object | - | No | Optional font descriptors |
scopes | Array | - | No | The scope of the font's application, with optional values being 'webview' or 'native'. The default is 'webview', but setting it to 'native' allows for use under Canvas 2D. |
success | function | - | No | Callback Function of Successful Interface Call |
fail | function | - | No | Callback Function of Successful Interface Call |
complete | function | - | No | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
Structure attributes | Type | Default value | Required | Description |
style | string | normal | No | Font style, with optional values being 'normal', 'italic', or 'oblique'. |
weight | string | normal | No | Font weight, with optional values being 'normal', 'bold', '100', '200', or '900'. |
variant | string | normal | No | Sets the display text for small capital letters, with optional values being 'normal', 'small-caps', or 'inherit'. |
Attribute | Type | Description |
status | string | Font Loading Results |
Attribute | Type | Description |
status | string | Font Loading Results |
Attribute | Type | Description |
status | string | Font Loading Results |
wx.loadFontFace({family: 'Bitstream Vera Serif Bold',source: 'url("https://sungd.github.io/Pacifico.ttf")',success: console.log})
Was this page helpful?