From 59828a30c2074b6f4273e708c613a106c303aa73 Mon Sep 17 00:00:00 2001 From: yinjiacheng Date: Sat, 9 Nov 2024 16:05:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0loadFontFace=E7=A4=BA?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/API/load-font-face/load-font-face.uvue | 22 ++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/pages/API/load-font-face/load-font-face.uvue b/pages/API/load-font-face/load-font-face.uvue index aa7cbbfe..a5b4b38e 100644 --- a/pages/API/load-font-face/load-font-face.uvue +++ b/pages/API/load-font-face/load-font-face.uvue @@ -13,7 +13,14 @@ }} \ue101 - 非全局加载字体: + 非全局加载字体: + font-family: uni.ttf(base64格式) + + {{ + uniIcon3 + }} + \ue102 + font-family: 阿里妈妈刀隶体-ttf (网络字体下载后生效) font-family: @@ -28,7 +35,8 @@ data() { return { uniIcon1: '\ue100', - uniIcon2: '\ue101', + uniIcon2: '\ue101', + uniIcon3: '\ue102' } }, onLoad() { @@ -42,6 +50,16 @@ fail(error) { console.warn('global loadFontFace uni.ttf fail', error.errMsg) }, + }) + uni.loadFontFace({ + family: 'UniFontFamily2', + source: "url(data:font/ttf;charset=utf-8;base64,AAEAAAAKAIAAAwAgT1MvMjpAVPQAAACsAAAAYGNtYXAADeKoAAABDAAAAUJnbHlmUL6yUwAAAlAAAAEYaGVhZBeGAMAAAANoAAAANmhoZWED3gOCAAADoAAAACRobXR4BCEAAAAAA8QAAAAGbG9jYQCMAAYAAAPMAAAABm1heHABEQBiAAAD1AAAACBuYW1le6YhIAAAA/QAAAMecG9zdNTj4UYAAAcUAAAAMAAEBAABkAAFAAACiQLMAAAAjwKJAswAAAHrADIBCAAAAgAFAwAAAAAAAAAAAAAQAAAAAAAAAAAAAABQZkVkAEDhAuECA4D/gABcA4AAgAAAAAEAAAAAAgACzQAA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AAAADABUAIgABAAAAAAAEAAgANwABAAAAAAAFADsAPwABAAAAAAAGAAgAegABAAAAAAAKACsAggABAAAAAAALABMArQADAAEECQAAACYAwAADAAEECQABABAA5gADAAEECQACAA4A9gADAAEECQADACoBBAADAAEECQAEABABLgADAAEECQAFAHYBPgADAAEECQAGABABtAADAAEECQAKAFYBxAADAAEECQALACYCGkNyZWF0ZWQgYnkgaWNvbmZvbnR1bmlpY29uc1JlZ3VsYXJ1bmlpY29uczpWZXJzaW9uIDEuMDB1bmlpY29uc1ZlcnNpb24gMS4wMDtKYW51YXJ5IDMsIDIwMjA7Rm9udENyZWF0b3IgMTIuMC4wLjI1MzUgNjQtYml0dW5paWNvbnNHZW5lcmF0ZWQgYnkgc3ZnMnR0ZiBmcm9tIEZvbnRlbGxvIHByb2plY3QuaHR0cDovL2ZvbnRlbGxvLmNvbQBDAHIAZQBhAHQAZQBkACAAYgB5ACAAaQBjAG8AbgBmAG8AbgB0AHUAbgBpAGkAYwBvAG4AcwBSAGUAZwB1AGwAYQByAHUAbgBpAGkAYwBvAG4AcwA6AFYAZQByAHMAaQBvAG4AIAAxAC4AMAAwAHUAbgBpAGkAYwBvAG4AcwBWAGUAcgBzAGkAbwBuACAAMQAuADAAMAA7AEoAYQBuAHUAYQByAHkAIAAzACwAIAAyADAAMgAwADsARgBvAG4AdABDAHIAZQBhAHQAbwByACAAMQAyAC4AMAAuADAALgAyADUAMwA1ACAANgA0AC0AYgBpAHQAdQBuAGkAaQBjAG8AbgBzAEcAZQBuAGUAcgBhAHQAZQBkACAAYgB5ACAAcwB2AGcAMgB0AHQAZgAgAGYAcgBvAG0AIABGAG8AbgB0AGUAbABsAG8AIABwAHIAbwBqAGUAYwB0AC4AaAB0AHQAcAA6AC8ALwBmAG8AbgB0AGUAbABsAG8ALgBjAG8AbQAAAAIAAAAAAAAACgABAAAAAAAAAAAAAAAAAAAAAAAAAAIAAgAAAQIJcGVyc29uYWRk)", + success() { + console.log('loadFontFace uni.ttf(base64 format) success') + }, + fail(error) { + console.warn('loadFontFace uni.ttf(base64 format) fail', error.errMsg) + }, }) uni.loadFontFace({ family: 'AlimamaDaoLiTiTTF', -- GitLab