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

angryTom
Release: 2020-03-19 17:31:48
Original
7126 people have browsed it

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')}
})
Copy after login

(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;
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template