I did a lot of reading but none of the links show me exactly how to add fonts in vuejs. This is how I import the font in my less file.
@font-face {
  font-family: "Questrial";
  src: url("../../fonts/Questrial-Regular.ttf");
}
@font-face {
  font-family: "Galano_Grotesque_extra_Bold";
  src: url("../../fonts/Galano_Grotesque_Bold.otf");
}
@font-face {
  font-family: "Galano_Grotesque_Bold";
  src: url("../../fonts/Galano_Grotesque_DEMO_Bold.otf");
}
This is the error that i get
ERROR in ./src/themes/jatango-theme/components/fonts/Galano_Grotesque_Bold.otf 1:4 Module parse failed: Unexpected character '' (1:4) You may need an appropriate loader to handle this file type. (Source code omitted for this binary file)
I am a newbie to VUEJS with no previous knowledge of react or angular. I only know jquery and javascript. So please someone give me a step by step guide to include the fonts. Thanks in advance :)


If you have some local font files of your own, place them in a font directory within src and reference them within . style. scss using @font-face as you normally would—webpack will see that you're referencing a font file and run it through the file-loader like it did with Font Awesome and Google Fonts.
To add a Google Font to a Vue. js component, we can imnport it in our CSS. @import url("https://fonts.googleapis.com/css?family=Roboto+Condensed"); Then we can set the font-family to Roboto in the elements we want.
Put your fonts in the public/fonts/ folder.
In css or scss, specify the path starting with /fonts/.
Example scss:
$font-dir: "/fonts/";
@font-face {
  font-family: "NameFont";
  src: url("#{$font-dir}NameFontRegular/NameFontRegular.eot");
  src: url("#{$font-dir}NameFontRegular/NameFontRegular.eot?#iefix")format("embedded-opentype"),
  url("#{$font-dir}NameFontRegular/NameFontRegular.woff") format("woff"),
  url("#{$font-dir}NameFontRegular/NameFontRegular.ttf") format("truetype");
  font-style: normal;
  font-weight: normal;
}
Next, import your scss into main.js
Example:
// eslint-disable-next-line
import styles from './assets/scss/main.scss';
or in vue.config.js
Example:
module.exports = {
...
  css: {
    modules: true,
    loaderOptions: {
      css: {
        localIdentName: '[name]-[hash]',
        camelCase: 'only'
      },
      sass: {
        data: '@import "~@/assets/scss/import/_variables.scss"; @import "~@/assets/scss/import/_mixins.scss";'
      },
    },
  },
...
}
                        Hope this will help others who are facing the same issue. For some reason Vue.js is giving error when using .otf files. I used .woff and now everything works fine. Use the following code in your webpack.config.js file :
      module.exports = function (config, { isClient, isDev }) {
            module: { rules: [ { test: /\.(woff|woff2|eot|ttf|svg)(\?.*$|$)/, 
            loader: 'file-loader' } ] }
            return config }
and import the files in your css file using something like this
 @font-face { 
       font-family: "Questrial";
       src: url("../../fonts/Questrial-Regular.ttf"); 
   }
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With