字體
wx.loadFont
TIP
該API使用方法為: string wx.loadFont(string path)
- 功能說明: 載入自訂字體檔案。
- 參數及說明: string path, 字體檔案路徑。支援本地路徑、程式碼包路徑。
- 返回值: string, 如果載入字體成功,則傳回字體 family 值,否則傳回 null。
wx.getTextLineHeight
TIP
該API使用方法為: number wx.getTextLineHeight(Object object)
- 功能說明: 取得一行文字的行高。
- 參數及說明: Object object。
| 内容 | 類型 | 預設值 | 必填 | 說明 |
|---|---|---|---|---|
| fontStyle | string | normal | 否 | 字體樣式 |
| fontWeight | string | normal | 否 | 字重 |
| fontSize | number | 16 | 否 | 號碼 |
| fontFamily | string | - | 是 | 字體名稱 |
| text | string | - | 是 | 文字的內容 |
| success | Function | - | 否 | 接口調用成功的回呼函數 |
| fail | Function | - | 否 | 接口調用失敗的回呼函數 |
| complete | Function | - | 否 | 接口調用結束的回呼函數(無論成功與否都執行) |
object.fontStyle 合法值
合法值 說明 normal 正常 italic 斜體 object.fontWeight 合法值
合法值 說明 normal 正常 bold 粗體 返回值:number 文字的行高。