智能照明系统APP-本地串口
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
LightingSystemApp-serial/.svn/pristine/fa/fa6376b83aa325251dee381c800...

39 lines
1.2 KiB

export function loadFontFace ({
options,
callbackId
}) {
const { family, source, desc = {} } = options
const fonts = document.fonts
if (fonts) {
const fontFace = new FontFace(family, source, desc)
fontFace
.load()
.then(() => {
fonts.add(fontFace)
UniViewJSBridge.publishHandler('onLoadFontFaceCallback', {
callbackId,
data: {
errMsg: 'loadFontFace:ok'
}
})
})
.catch(error => {
UniViewJSBridge.publishHandler('onLoadFontFaceCallback', {
callbackId,
data: {
errMsg: `loadFontFace:fail ${error}`
}
})
})
} else {
var style = document.createElement('style')
style.innerText = `@font-face{font-family:"${family}";src:${source};font-style:${desc.style};font-weight:${desc.weight};font-stretch:${desc.stretch};unicode-range:${desc.unicodeRange};font-variant:${desc.variant};font-feature-settings:${desc.featureSettings};}`
document.head.appendChild(style)
UniViewJSBridge.publishHandler('onLoadFontFaceCallback', {
callbackId,
data: {
errMsg: 'loadFontFace:ok'
}
})
}
}