tencent cloud

Feedback

Last updated: 2024-03-04 23:12:24

    loadFontFace

    This API is used via wx.loadFontFace(Object object).
    Feature Description: Dynamically loads web fonts. The file address must be of download type, and it needs to be invoked within app.js.
    Note:
    The content-type returned by the font file should reference the font; incorrect formatting will result in parsing failure.
    The font link must be https (http is not supported on iOS).
    The font link must originate from the same source, or have CORS support enabled. The domain for the mini program is servicewechat.com.
    The tool's prompt "Failed to load font" can be ignored.
    Prior to version 2.10.0, it was only effective on the call page.
    Parameter and Description: Object
    Attribute
    Type
    Default value
    Required
    Description
    global
    boolean
    false
    No
    Is it globally effective?
    family
    string
    -
    Yes
    Defined font name
    source
    string
    -
    Yes
    The address of the font resource. The recommended formats are TTF and WOFF, as WOFF2 may not be compatible with older versions of iOS.
    desc
    object
    -
    No
    Optional font descriptors
    scopes
    Array
    -
    No
    The scope of the font's application, with optional values being 'webview' or 'native'. The default is 'webview', but setting it to 'native' allows for use under Canvas 2D.
    success
    function
    -
    No
    Callback Function of Successful Interface Call
    fail
    function
    -
    No
    Callback Function of Successful Interface Call
    complete
    function
    -
    No
    Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations)
    Structural value of 'desc'
    Structure attributes
    Type
    Default value
    Required
    Description
    style
    string
    normal
    No
    Font style, with optional values being 'normal', 'italic', or 'oblique'.
    weight
    string
    normal
    No
    Font weight, with optional values being 'normal', 'bold', '100', '200', or '900'.
    variant
    string
    normal
    No
    Sets the display text for small capital letters, with optional values being 'normal', 'small-caps', or 'inherit'.
    Parameters for object.success callback function: Object res.
    Attribute
    Type
    Description
    status
    string
    Font Loading Results
    Parameters for object.fail callback function: Object res
    Attribute
    Type
    Description
    status
    string
    Font Loading Results
    object.complete Callback Function Parameters: Object res
    Attribute
    Type
    Description
    status
    string
    Font Loading Results
    Sample Code
    wx.loadFontFace({
    family: 'Bitstream Vera Serif Bold',
    source: 'url("https://sungd.github.io/Pacifico.ttf")',
    success: console.log
    })
    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support