Home  >  Article  >  WeChat Applet  >  How to set the Apple Pingfang font in the mini program

How to set the Apple Pingfang font in the mini program

angryTom
angryTomOriginal
2020-03-19 17:31:487089browse

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 of

thinkphp 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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn