mc.loadFontFace(Object object)

动态加载网络字体,文件地址需为下载类型。

注意:

  1. 字体文件返回的 contet-type 参考 font,格式不正确时会解析失败。
  2. 字体链接为http时需要启用http
  3. 字体链接必须是同源下的,或开启了cors支持,应用的域名是service.morecross.cn

Object object 参数

属性 类型 默认值 必填 说明
global Boolean false 是否全局生效
family String 定义的字体名称
source String 字体资源的地址。建议格式为 TTF 和 WOFF,WOFF2 在低版本的iOS上会不兼容。
desc Object 可选的字体描述符
success Function 接口调用成功的回调函数
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

Object.desc 的结构

属性 类型 默认值 必填 说明
style String 'normal' 字体样式,可选值为 normal / italic / oblique
weight String 'normal' 字体粗细,可选值为 normal / bold / 100 / 200../ 900
variant String 'normal' 设置小型大写字母的字体显示文本,可选值为 normal / small-caps / inherit

示例代码:

mc.loadFontFace({
  family: 'Bitstream Vera Serif Bold',
  source: 'url("https://sungd.github.io/Pacifico.ttf")',
  complete: function (res) {
    console.log(res);
  }
})

results matching ""

    No results matching ""

    results matching ""

      No results matching ""