wx.loadBuiltInFontFace(Object object)

基础库 3.7.9 开始支持,低版本需做兼容处理。

以 Promise 风格 调用:不支持

微信小程序插件:支持,需要微信小程序基础库版本不低于 3.7.9

微信 Windows 版:支持

微信 Mac 版:支持

功能描述

加载内置字体。

参数

Object object

属性 类型 默认值 必填 说明
global boolean false 是否全局生效
family string 定义的字体名称
source string 要加载的内置字体名字
合法值 说明
WeChatSansSS WeChatSansSS 字体
WeChatSansStd WeChatSansStd 字体
scopes Array 字体作用范围,可选值为 webview / native / skyline,默认全选,设置 native 可在 Canvas 2D 下使用
success function 接口调用成功的回调函数
fail function 接口调用失败的回调函数
complete function 接口调用结束的回调函数(调用成功、失败都会执行)

示例代码

在开发者工具中预览效果

wx.loadBuiltInFontFace({
  family: 'WeChatSansSS',
  source: 'WeChatSansSS',
  success: console.log
})