cc.loader.load({ url: ${wx.env.USER_DATA_PATH}"/font/MaShanZheng-Regular.ttf", type: “ttf” }, (err, font) => {
if (!err) {
let MaShanZheng = new cc.TTFFont()
MaShanZheng.name = "Ma Shan Zheng"
MaShanZheng["_nativeAsset"] = font
// 重写cc.Label的_onLoad方法
const originalOnLoad = cc.Label.prototype["onLoad"]
cc.Label.prototype["onLoad"] = function () {
this.font = MaShanZheng
this._forceUpdateRenderData(true)
originalOnLoad.call(this) // 调用原始的_onLoad方法
}
}
})