Use external fonts

Using beautiful fonts applet micro letter:

There are several ways:
1. Convert the required font files into css base64 format, like Ali font icon iconfont use

In the font conversion website https://transfonter.org/, first the Add ` Fonts ,选中Base64 encode Formats 根据你的字体格式选择,一般是TTF 格式,在选择Convert`, get good compression package after conversion, you can get fonts css file after decompression, but in the micro-channel applet is not here apply, as the size of the applet must be packaged <2MB, css file thus obtained exceeds the volume limit, this approach is not feasible

2. Use wx.loadFontFace load external fonts
Documentation: https://developers.weixin.qq.com/miniprogram/dev/api/wx.loadFontFace.html

. 1 
2
. 3
. 4
. 5
. 6
. 7
. 8
. 9
10
. 11
12 is
13 is < large column  using external font br /> 14
wx.loadFontFace({
family: this.data.fontFamily,
source: 'url("https://sungd.github.io/Pacifico.ttf")',
success(res) {
console.log(res.status)
self.setData({ loaded: true })
},
fail: function(res) {
console.log(res.status)
},
complete: function(res) {
console.log(res.status)
}
});

3. disposed in wxss

1
2
3
4
5
/ * Network Load Font * / 
@ font-face {
font-Family: 'the Bitstream Vera Serif Bold Font';
the src: URL ( 'https://sungd.github.io/Pacifico.ttf');
}

Guess you like

Origin www.cnblogs.com/lijianming180/p/12286286.html