I know this question is asked and answered before in the links below. I want to change the default font without having to add to every css.
Things I have tried:
- Changing the .tff, .eot, .woff, .svg file directly to merge my fonts and ionicons
- Tried to implement the font by specifying it in html and css file (it works, but i want it to be default)
- Overwrite the www/lib/ionic/fonts with open-sans font (the ionicons disappear)
- When i use the first link (all formatting is gone, only left with text and buttons) I also tried placing the font-face on top and bottom in scss/ionic.app.scss
Please help! The answers i have seen are instructions but no explanation how it works. I don't know how "ionic setup sass" works/what it does. How gulp plays a part in this.
https://forum.ionicframework.com/t/how-to-change-the-font-of-all-texts-in-ionic/30459
https://forum.ionicframework.com/t/change-font-family-and-use-ionicons-icons/26729
Import all the font files
in to your app.
Example:
@font-face {
font-family: 'Lato-Light';
src: url('../fonts/Lato-Light.eot') format('embedded-opentype'), url('../fonts/Lato-Light.woff') format('woff'), url('../fonts/Lato-Light.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
If you want this font in entire app ,Just give like this
* {
font-family: 'Lato-Light' !important;
}
If you have any doubt.Please let me know.Thanks
The correct solution for Ionic 2 should be to change the $font-family-base
variable and its friends. That's the way Ionic is made to do it. It gives you more control (like having different fonts per platform), and it avoids the !important
keyword, which is always a good thing.
Using Ionic 3.3, go to your variables.scss
and find the section "Shared variables". Add these lines:
$font-family-base: 'MyFont';
$font-family-ios-base: 'MyFont';
$font-family-md-base: 'MyFont';
$font-family-wp-base: 'MyFont';
For Ionic 2:
Download the fonts from fonts.google.com and paste it in your assets folder. Now in your scss file do the following:
@font-face {
font-family: MyFont;
src: url("../assets/fonts/Lato-Regular.ttf");
}
body, span, button, h1, h2, h3, h4, h5, h6, p, ion-item, ion-title {
font-family: 'MyFont' !important;
}
You don't want to replace the icon font by the way, so you should use the CSS3 not() property
For example, in app.scss :
@import url(https://fonts.googleapis.com/css?family=Varela+Round);
*:not(ion-icon) {
font-family: 'Varela Round', sans-serif!important;
}
You can simply include your icons as svg
format.
Here's a list with all the latest ionicons
: https://github.com/Orlandster1998/ionicons-svg