Home >WeChat Applet >Mini Program Development >How to set the Apple Pingfang font in the mini program
How to set the Apple Pingfang font in the mini program
To use the Pingfang font in the mini program, you can use the official API: wx.loadFontFace (loading external fonts) to achieve.
Usage example:
wx.loadFontFace ({ family: 'PingFangSC-Medium', source: 'url("https://www.your-server.com/PingFangSC-Medium.ttf")', success: function(){console.log('load font success')} })
(Recommended learning: Small program development)
One thing to note here is that,# The name at ##family is the name of the font-family when used. For example, the font loaded above is used like this:
.foo { font-family:PingFangSC-Medium; }
Recommendation
Because The fonts may be relatively large, so it is not recommended to use multiple fonts in a small program, as this will affect the user experience. In order to ensure the interface effect, you can load fonts in the onLoad cycle, perform subsequent operations in the success callback, and add Loading when necessary to make the program more friendly. PHP Chinese website, a large number ofthinkphp tutorials, welcome to learn!
The above is the detailed content of How to set the Apple Pingfang font in the mini program. For more information, please follow other related articles on the PHP Chinese website!