Skip to content

Font

wx.loadFont

TIP

The API usage is as follows: string wx.loadFont(string path)

  • Functional description: Load a custom font file.
  • Parameters and descriptions: string path, Font file path. Supports local path and code package path.
  • Return value: string, If the font is loaded successfully, the font family value is returned, otherwise null is returned.

wx.getTextLineHeight

TIP

The API usage is as follows: number wx.getTextLineHeight(Object object)

  • Functional description: Get the line height of a line of text.
  • Parameters and descriptions: Object object。
PropertiesTypeDefault valueRequiredDescription
fontStylestringnormalNoFont style
fontWeightstringnormalNoFont weight
fontSizenumber16NoFont size
fontFamilystring-YesFont name
textstring-YesText content
successFunction-NoCallback function for successful interface call
failFunction-NoCallback function for failed interface call
completeFunction-NoCallback function for interface call completion (executed regardless of success or failure)
  • object.fontStyle Legal value

    Legal valueDescription
    normalNormal
    italicItalic
  • object.fontWeight Legal value

    Legal valueDescription
    normalNormal
    boldBold
  • Return value:number The line height of the text.