import config from '@/config';
function loadFont(weight = 400, global = false) {
  const source = {
    400: `url("${config.h5StaticPath}/font/Montserrat/Montserrat-Regular.ttf")`, // Regular
    500: `url("${config.h5StaticPath}/font/Montserrat/Montserrat-Medium.ttf")` // Medium
  }
  wx.loadFontFace({
    family: 'Montserrat',
    source: source[weight],
    desc: {
      weight: weight
    },
    global,
    success: function (message) {
      // console.log('load font-family success:', message)
    },
    fail: function (message) {
      console.log('load font-family fail: ', message)
    }
  })
}

export default loadFont

export function loadFontUrl(fontSource, fontFamily, global) {
  wx.loadFontFace({
    family: fontFamily,
    source: fontSource,
    desc: {
      weight: 400
    },
    global,
    success: function (message) {
      // console.log('load font-family success:', message)
    },
    fail: function (message) {
      console.log('load font-family fail: ', message)
    }
  })
}
