Reputation: 1067
Im building an application only for tablet and I want to use my own font in ttf format. How can I load .ttf fonts into quasar?
Another option would be to convert it to woff?
I have tried this in app.scss but it didnt work:
@font-face {
font-family: 'MyFont';
src: url('css/fonts/MyFont.ttf') format('truetype');
font-weight: 700;
font-style: italic;
}
.my-custom-font {
font-family: 'Cookies', Fallback sans-serif;
}
Upvotes: 7
Views: 8721
Reputation: 129
1-Put Your font Files in ./src/css/fonts Folder
2-Delclare the Font Name inside ./src/css/app.css
@font-face {
font-family: "vazir";
font-style: normal;
font-weight: 400;
src: url("./fonts/Vazir-Medium.woff2") format("woff2"),
url("./fonts/Vazir-Medium.ttf") format("truetype"),
url("./fonts/Vazir-Medium.woff") format("woff");
font-display: swap;
}
3-Define Font in ./src/css/quasar.variables.scss
$primary: #1976d2;
$secondary: #26a69a;
$accent: #9c27b0;
$dark: #1d1d1d;
$dark-page: #121212;
$positive: #21ba45;
$negative: #c10015;
$info: #31ccec;
$warning: #f2c037;
$typography-font-family: "vazir";
4-Comment roboto-font inside ./quasar.config.js
extras: [
// 'ionicons-v4',
// 'mdi-v5',
// 'fontawesome-v6',
// 'eva-icons',
// 'themify',
// 'line-awesome',
// 'roboto-font-latin-ext', // this or either 'roboto-font', NEVER both!
//"vazir",
// "roboto-font", // optional, you are not bound to it
"material-icons", // optional, you are not bound to it
],
Upvotes: 7
Reputation: 465
I use stylus without removing any line for fonts as others suggested but by doing the following steps:
assets/fonts/plex
'$typography-font-family
in quasar.variables.styl
app.styl:
// app global css in Stylus form
@font-face {
font-family: plex;
src: url(../assets/fonts/plex/IBM-Plex-Sans-Arabic/fonts/complete/woff/IBMPlexSansArabic-Regular.woff);
}
quasar.variables.styl:
// Quasar Stylus Variables
// --------------------------------------------------
// To customize the look and feel of this app, you can override
// the Stylus variables found in Quasar's source Stylus files.
// Check documentation for full list of Quasar variables
// Your own variables (that are declared here) and Quasar's own
// ones will be available out of the box in your .vue/.styl files
// It's highly recommended to change the default colors
// to match your app's branding.
// Tip: Use the "Theme Builder" on Quasar's documentation website.
$primary = #1976D2
$secondary = #26A69A
$accent = #9C27B0
$dark = #1D1D1D
$positive = #21BA45
$negative = #C10015
$info = #31CCEC
$warning = #F2C037
$typography-font-family = 'plex'
quasar install config:
App dir........... /home/abuabdellah/work/.../quasar
App URL........... http://localhost:8080
Dev mode.......... spa
Pkg quasar........ v1.15.23
Pkg @quasar/app... v2.2.10
Transpiled JS..... yes (Babel)
Upvotes: 1
Reputation: 341
Hi everyone for people with recent version, my solution was:
and load it like this for example in app.scss:
And in the quasar.conf.js, you should comment the line with "roboto-font" like this:
Hope it helps, cheers!
Upvotes: 4
Reputation: 61
Remove the ‘roboto-font’ from the quasar.config.js file (unless you intend to still use it as a secondary font). Either select a font from Google Fonts for import, or download a font family .WOFF file to include.
Similar to the documentation ( https://quasar.dev/style/typography#Add-custom-fonts ), you should import the font-family, but it should go into the ‘src/css/quasar.variables.*’ file. Then, change one or more of the default styling variables.
I’m going to assume Sass for examples below:
// Example: Import Open Sans with multiple weights
@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;600;700;800&display=swap')
// Set the default font-family
$typography-font-family : 'Open Sans', sans-serif !default
// Fix font-weight values to match the imported font family weights
$text-weights: (thin: 300, light: 400, regular: 600, medium: 700, bold: 800, bolder: 800) !default
$button-font-weight: 600 // or 400 if you prefer thinner
Upvotes: 6