加载字体的方法
uni.loadFontFace({ family: '中英文都可', source: `url('${host}/static/xxx/xxx.ttf')`, success() { console.log('success') }, fail(res) { console.log('fail',res) } })
同一字体的不同粗细
family可设置是同一个,通过设置font-weight决定使用哪个字体文件
uni.loadFontFace({ family: '名称1', source: `url('${host}/static/xxx/xxx.otf')`, desc: { weight: 'normal' }, success() { console.log('success') }, fail(res) { console.log('fail',res) } }) uni.loadFontFace({ family: '名称1', source: `url('${host}/static/xxx/xxx-Roman.otf')`, desc: { weight: 550 }, success() { console.log('success') }, fail(res) { console.log('fail',res) } }) uni.loadFontFace({ family: '名称1', source: `url('${host}/static/xxx/xxx-Md.otf')`, desc: { weight: 650 }, success() { console.log('success') }, fail(res) { console.log('fail',res) } }) uni.loadFontFace({ family: '名称1', source: `url('${host}/static/xxx/xxx-Bd.otf')`, desc: { weight: 750 }, success() { console.log('success') }, fail(res) { console.log('fail',res) } })