tencent cloud

Feedback

Last updated: 2024-07-24 09:54: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 js.
    Note:
    The contet-type returned by the font file refers to the font, and will fail to parse if it is not in the correct format;
    For true machine compatibility, the font link must be https;
    The link to the font must be under the same source, or enable cors support, the domain name of the mini program is servicewechat.com(If the client has a custom domain name, please adjust it here according to the custom configuration).;
    The tooltip Faild to load font can be ignored.
    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
    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
    // https://sungd.github.io/Pacifico.ttf Font links need to have https enabled and cross-domain settings turned on
    wx.loadFontFace({
    family:Bitstream Vera Serif Bold,
    family:MyFont.
    source:url(’https://sungd.github.io/Pacifico.ttf‘),
    Success: console.log
    })
    page {
    font-family: 'MyFont';
    }
    
    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