- 將外部字體放在與index.html同目錄下;
- 打開index.html文件;
- 在style中引入外部字體:
@font-face { font-family: 'MyText'; src:url('./font/MyText.ttf') ; }
- 在script里監聽字體是否加載完成:
document.fonts.ready.then(success, fail); function success(){ egret.runEgret({renderMode:"webgl", audioType:0}); } function fail(){ }
- 直接引用:label.fontFamily ="MyText"