loadFont.js 1.53 KB
Newer Older
huahua committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
let loadFont = function(textlist,list) {
	// var num = 0
	// const source = {
	// 	100: 'url("http://tprint.refinecolor.com/text/CangErXiaoWanZi.ttf")',
	// 	1: 'url("https://tprint.refinecolor.com/text/Qiantu_rabbit.ttf")',
	// 	2: 'url("https://tprint.refinecolor.com/text/Stand_cool_black.ttf")',
	// 	3: 'url("https://tprint.refinecolor.com/text/Standing_cool_happy_body.ttf")',
	// 	4: 'url("https://tprint.refinecolor.com/text/ZhankuQingkeButterBody.ttf")',
	// 	5: 'url("https://tprint.refinecolor.com/text/Font_horizon_method_stick_body.ttf")',
	// }
	uni.showLoading({
		title: '加载字体...',
		mask: true,
	});
	wx.loadFontFace({
		global:true,
		family: textlist.key,
		source: 'url(' + textlist.remark + ')',
		desc: {
			weight: 100
		},
		success: function(message) {
			// console.log('load font-family success:', message)
			textlist.textlong = true
		},
		fail: function(message) {
			textlist.textlong = false
			// console.log('load font-family fail: ', message)
		},
		complete(res) {
			uni.hideLoading();
			// wx.showToast({title: '字体下载完成',icon: 'success',duration: 2000});
			// console.log('complete', res)
			textlist.long = true
			// list.forEach(item=>{
			// 	if(item.long == true){
			// 		num++
			// 	}
			// })
			// uni.showLoading({
			// 	title: num + '/' + list.length + '字体加载中...',
			// 	mask: true,
			// });
			// if(num == 6){
			// 	uni.hideLoading();
			// 	wx.showToast({title: '字体加载完成',icon: 'success',duration: 2000});
			// }
			// num = 0
		}
	})
	
}

export default loadFont