跳到主要内容

bn.loadFontFace

loadFontFace(payload): Promise<LoadFontFaceResponse>

description Dynamic load network font, file address should be download type.

example

bn.loadFontFace({
family: 'Bitstream Wedding band Serif Bold',
source: 'url("https://sungd.github.io/Pacific.ttf")',
success: console.log
})

Parameters

NameType
payloadLoadFontFacePayload

Returns

Promise<LoadFontFaceResponse>

status: when success is 'loaded', otherwise, it's failed

LoadFontFacePayload

Ƭ LoadFontFacePayload: Object

Type declaration

NameTypeDescription
familystringDefined font name
sourcestringThe address of the font resource. The suggested format is TTF and Woff
scopes?("webview" | "native")[]Font scope, optional value is webview / Native, default Webview
desc?{ style?: "normal" | "italic" | "oblique" | `oblique ${string}` ; variant?: string ; weight?: string }Optional font descriptor
desc.style?"normal" | "italic" | "oblique" | `oblique ${string}`Font style, optional value is normal / italic / oblique
desc.variant?stringSets font display text for small uppercase letters, optional normal / small-caps / inherit
desc.weight?stringFont size, optional value is normal / bold / 100 / 200../ 900
success?(res: Omit<LoadFontFaceResponse, "status">) => void-
fail?(res: Omit<LoadFontFaceResponse, "status">) => void-
complete?(res: Omit<LoadFontFaceResponse, "status">) => void-

LoadFontFaceResponse

Ƭ LoadFontFaceResponse: Object

Type declaration

NameTypeDescription
status?"loaded" | "error"when success is 'loaded', when fail, it's undefined
errMsgstringwhen success is ''
code?number | string-

LoadFontFaceResponse

Ƭ LoadFontFaceResponse: Object

Type declaration

NameTypeDescription
status?"loaded" | "error"when success is 'loaded', when fail, it's undefined
errMsgstringwhen success is ''
code?number | string-