2***@qq.com
2***@qq.com
  • 发布:2024-09-03 10:54
  • 更新:2024-09-05 09:34
  • 阅读:214

app端怎么使用uni.loadFontFace引入本地字体呀?

分类:HBuilderX
uni.loadFontFace({  
                        family:fontFamily,  
                        source:`url(/var/mobile/Containers/Data/Application/F36F399D-F596-4CDD-A522-79BC3B6E844E/Documents/Pandora/apps/HBuilder/www/"_doc/uniapp_temp_1725267368011/download/兵克侠客体.ttf")`,  
                        //source:`url(${this.displayedFonts[i].localityUrl})`,  
                        success:(res) => {  
                            this.selectedLayer.style.fontFamily = fontFamily;  
                            this.displayedFonts[i].loaded = true;  
                            console.log(res)  
                            this.displayedFonts[i].download = true;  
                            this.setLayerText(this.selectedLayer, this.selectedLayer.srcText);  

                        },  
                        fail: (res)=> {  
                            this.displayedFonts[i].download = false;  
                            console.log(res)  
                        },  
                    })

报错:"errMsg": "loadFontFace:fail SyntaxError: The string did not match the expected pattern."
这个路径已经转成平台绝对路径了,求求大佬帮帮小白吧

2024-09-03 10:54 负责人:无 分享
已邀请:
2***@qq.com

2***@qq.com (作者) - 每天爱打游戏的快乐小菜比

我现在发现了一个问题uni.loadFontFace只能读取_www/static/文件夹下的,其他文件夹都不可以。这算是bug吗?

要回复问题请先登录注册