Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
bcec6139
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6005
Star
91
Fork
164
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
bcec6139
编写于
7月 19, 2023
作者:
DCloud-WZF
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: loadFontFace
上级
b178eb54
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
182 addition
and
11 deletion
+182
-11
jest-setup.js
jest-setup.js
+7
-0
jest.config.js
jest.config.js
+8
-9
pages.json
pages.json
+12
-0
pages/API/load-font-face/load-font-face-child.test.js
pages/API/load-font-face/load-font-face-child.test.js
+12
-0
pages/API/load-font-face/load-font-face-child.uvue
pages/API/load-font-face/load-font-face-child.uvue
+29
-0
pages/API/load-font-face/load-font-face.test.js
pages/API/load-font-face/load-font-face.test.js
+12
-0
pages/API/load-font-face/load-font-face.uvue
pages/API/load-font-face/load-font-face.uvue
+96
-0
pages/CSS/text/font-family.uvue
pages/CSS/text/font-family.uvue
+1
-1
pages/tabBar/API.uvue
pages/tabBar/API.uvue
+5
-1
static/font/uni.ttf
static/font/uni.ttf
+0
-0
未找到文件。
jest-setup.js
0 → 100755
浏览文件 @
bcec6139
const
{
toMatchImageSnapshot
}
=
require
(
'
jest-image-snapshot
'
);
expect
.
extend
({
toMatchImageSnapshot
});
\ No newline at end of file
jest.config.js
浏览文件 @
bcec6139
module
.
exports
=
{
testTimeout
:
10000
,
reporters
:
[
'
default
'
],
watchPathIgnorePatterns
:
[
'
/node_modules/
'
,
'
/dist/
'
,
'
/.git/
'
],
moduleFileExtensions
:
[
'
js
'
,
'
json
'
],
rootDir
:
__dirname
,
testMatch
:
[
"
<rootDir>/pages/**/*test.[jt]s?(x)
"
],
testPathIgnorePatterns
:
[
'
/node_modules/
'
]
testTimeout
:
10000
,
reporters
:
[
'
default
'
],
watchPathIgnorePatterns
:
[
'
/node_modules/
'
,
'
/dist/
'
,
'
/.git/
'
],
moduleFileExtensions
:
[
'
js
'
,
'
json
'
],
rootDir
:
__dirname
,
testMatch
:
[
"
<rootDir>/pages/**/*test.[jt]s?(x)
"
],
testPathIgnorePatterns
:
[
'
/node_modules/
'
],
setupFilesAfterEnv
:
[
'
<rootDir>/jest-setup.js
'
],
}
pages.json
浏览文件 @
bcec6139
...
...
@@ -220,6 +220,18 @@
"navigationBarTitleText"
:
"消息提示框"
}
},
{
"path"
:
"pages/API/load-font-face/load-font-face"
,
"style"
:
{
"navigationBarTitleText"
:
"动态加载字体"
}
},
{
"path"
:
"pages/API/load-font-face/load-font-face-child"
,
"style"
:
{
"navigationBarTitleText"
:
"动态加载字体-子页面"
}
},
{
"path"
:
"pages/API/get-location/get-location"
,
"style"
:
{
...
...
pages/API/load-font-face/load-font-face-child.test.js
0 → 100644
浏览文件 @
bcec6139
const
PAGE_PATH
=
'
/pages/API/load-font-face/load-font-face-child
'
describe
(
'
loadFontFace global
'
,
()
=>
{
beforeAll
(
async
()
=>
{
const
page
=
await
program
.
navigateTo
(
PAGE_PATH
)
await
page
.
waitFor
(
1000
)
})
it
(
'
screenshot
'
,
async
()
=>
{
const
image
=
await
program
.
screenshot
()
expect
(
image
).
toMatchImageSnapshot
()
})
})
pages/API/load-font-face/load-font-face-child.uvue
0 → 100644
浏览文件 @
bcec6139
<template>
<view>
<page-head title="loadFontFace-child"></page-head>
<view class="uni-padding-wrap">
<text class="item" style="font-family: UniFontFamily"
>全局加载 font-family: uni.ttf</text
>
<text class="item" style="font-family: AlimamaDaoLiTiTTF"
>font-family: 阿里妈妈刀隶体-ttf</text
>
<text class="item" style="font-family: AlimamaDaoLiTiOTF"
>font-family: 阿里妈妈刀隶体-otf</text
>
<text class="item" style="font-family: AlimamaDaoLiTiWOFF"
>font-family: 阿里妈妈刀隶体-woff</text
>
<text class="item" style="font-family: AlimamaDaoLiTiWOFF2"
>font-family: 阿里妈妈刀隶体-woff2</text
>
</view>
</view>
</template>
<style>
.item {
font-size: 20px;
line-height: 40px;
}
</style>
pages/API/load-font-face/load-font-face.test.js
0 → 100644
浏览文件 @
bcec6139
const
PAGE_PATH
=
'
/pages/API/load-font-face/load-font-face
'
describe
(
'
loadFontFace
'
,
()
=>
{
beforeAll
(
async
()
=>
{
const
page
=
await
program
.
navigateTo
(
PAGE_PATH
)
await
page
.
waitFor
(
2000
)
})
it
(
'
screenshot
'
,
async
()
=>
{
const
image
=
await
program
.
screenshot
()
expect
(
image
).
toMatchImageSnapshot
()
})
})
pages/API/load-font-face/load-font-face.uvue
0 → 100644
浏览文件 @
bcec6139
<template>
<view>
<page-head title="loadFontFace"></page-head>
<view class="uni-padding-wrap">
<text class="item" style="font-family: UniFontFamily"
>全局加载 font-family: uni.ttf</text
>
<text class="item" style="font-family: AlimamaDaoLiTiTTF"
>font-family: 阿里妈妈刀隶体-ttf (网络字体下载后生效)</text
>
<text class="item" style="font-family: AlimamaDaoLiTiOTF"
>font-family: 阿里妈妈刀隶体-otf</text
>
<text class="item" style="font-family: AlimamaDaoLiTiWOFF"
>font-family: 阿里妈妈刀隶体-woff</text
>
<text class="item" style="font-family: AlimamaDaoLiTiWOFF2"
>font-family: 阿里妈妈刀隶体-woff2</text
>
<button class="uni-btn" @click="navigateToChild">跳转子页面</button>
</view>
</view>
</template>
<script>
export default {
onLoad() {
uni.loadFontFace({
global: true,
family: 'UniFontFamily',
source: '/static/font/uni.ttf',
success() {
console.log('global loadFontFace uni.ttf success')
},
fail(error) {
console.warn('global loadFontFace uni.ttf fail', error.errMsg)
},
})
uni.loadFontFace({
family: 'AlimamaDaoLiTiTTF',
source:
'https://native-res.dcloud.net.cn/uni-app-x/static/font/AlimamaDaoLiTi.ttf',
success() {
console.log('loadFontFace AlimamaDaoLiTi.ttf success')
},
fail(error) {
console.warn('loadFontFace AlimamaDaoLiTi.ttf fail', error.errMsg)
},
})
uni.loadFontFace({
family: 'AlimamaDaoLiTiOTF',
source: '/static/font/AlimamaDaoLiTi.otf',
success() {
console.log('loadFontFace AlimamaDaoLiTi.otf success')
},
fail(error) {
console.warn('loadFontFace AlimamaDaoLiTi.otf fail', error.errMsg)
},
})
uni.loadFontFace({
family: 'AlimamaDaoLiTiWOFF',
source: '/static/font/AlimamaDaoLiTi.woff',
success() {
console.log('loadFontFace AlimamaDaoLiTi.woff success')
},
fail(error) {
console.warn('loadFontFace AlimamaDaoLiTi.woff fail', error.errMsg)
},
})
uni.loadFontFace({
family: 'AlimamaDaoLiTiWOFF2',
source: '/static/font/AlimamaDaoLiTi.woff2',
success() {
console.log('loadFontFace AlimamaDaoLiTi.woff2 success')
},
fail(error) {
console.warn('loadFontFace AlimamaDaoLiTi.woff2 fail', error.errMsg)
},
})
},
methods: {
navigateToChild() {
uni.navigateTo({
url: '/pages/API/load-font-face/load-font-face-child',
})
},
},
}
</script>
<style>
.item {
font-size: 20px;
line-height: 40px;
}
</style>
pages/CSS/text/font-family.uvue
浏览文件 @
bcec6139
<template>
<view>
<view
class="uni-padding-wrap"
>
<text class="common" style="font-family: monospace"
>font-family: monospace</text
>
...
...
pages/tabBar/API.uvue
浏览文件 @
bcec6139
...
...
@@ -140,7 +140,11 @@
{
name: "显示消息提示框",
url: "toast",
},
},
{
name: "动态加载字体",
url: "load-font-face",
},
] as Page[],
},
{
...
...
static/font/uni.ttf
0 → 100644
浏览文件 @
bcec6139
文件已添加
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录