May 19, 2021 WeChat Mini Program Development Document
Base library 2.1.0 starts to support, and low versions need to be compatible.
The network font is loaded dynamically, and the file address needs to be the download type. '2.10.0' supports global effective and needs to be called .js app.
Attention:
Property | Type | The default | Required | Description | The lowest version |
---|---|---|---|---|---|
global | boolean | false | Whether | Whether to take effect globally | 2.10.0 |
family | string | Is | The defined font name | ||
source | string | Is | The address of the font resource. The recommended formats are TTF and WOFF2, which are incompatible on lower versions of iOS. | ||
desc | Object | Whether | Optional font descriptor | ||
success | function | Whether | The interface calls a successful callback function | ||
fail | function | Whether | The interface calls the failed callback function | ||
complete | function | Whether | Callback function at end of interface call (call succeeds, fails are executed) |
The structure of object.desc
Property | Type | The default | Required | Description |
---|---|---|---|---|
style | string | 'normal' | no | Font style, optional value is normal / italic / oblique |
weight | string | 'normal' | no | Font thick, optional value is normal / bold / 100/200 ../ 900 |
variant | string | 'normal' | no | Set the font display of small uppercase letters, optional value is normal / small-caps / inherit |
Attributes | type | illustrate |
---|---|---|
status | string | Load font results |
Property | Type | Description |
---|---|---|
status | string | Load the font results |
Property | Type | Description |
---|---|---|
status | string | Load the font results |
Preview the effect in the developer tool
wx.loadFontFace({
family: 'Bitstream Vera Serif Bold',
source: 'url("https://sungd.github.io/Pacifico.ttf")',
success: console.log
})