From 2362e5e8b2946c7f417fc9afbec7e7d0dfc8072f Mon Sep 17 00:00:00 2001 From: laihanbin <512412344@qq.com> Date: Wed, 13 Dec 2023 17:50:01 +0800 Subject: [PATCH] fix: load font first --- .../Chinese-chess/src/pages/OfflineGame.vue | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/packages/Chinese-chess/src/pages/OfflineGame.vue b/packages/Chinese-chess/src/pages/OfflineGame.vue index 2509c3e..e391a6f 100644 --- a/packages/Chinese-chess/src/pages/OfflineGame.vue +++ b/packages/Chinese-chess/src/pages/OfflineGame.vue @@ -32,14 +32,20 @@ onMounted(() => { chatListRef.value && chatInputRef.value ) { - const ctrl = createController({ - oMain: mainRef.value, - oManual: manualRef.value, - oChatList: chatListRef.value, - oChatInput: chatInputRef.value - }) - ctrl.initGame() - ctrl.run() + const font = new FontFace('PieceFont', 'url(fzlsft.ttf)') + font.load().then(f => { + (document.fonts as any).add(f) + }).then(async () => await document.fonts.ready.then()) + .then(() => { + const ctrl = createController({ + oMain: mainRef.value!, + oManual: manualRef.value!, + oChatList: chatListRef.value!, + oChatInput: chatInputRef.value! + }) + ctrl.initGame() + ctrl.run() + }) } })