Using Custom Fonts

Using custom fonts is very easy and straight-forward in Ionic 4 apps. There are two ways it can be done

Method 1. Using custom font files from Assets

In this method, you need to download custom font files and keep them in assets for static storage. In the sample provided in the app, we have two different fonts downloaded in assets
  • Muli - Full font family with various font-faces
  • Qranklestein - Single font file, hence single font-face
The font is imported in global.scss using
@font-face {
font-family: 'Qranklestein';
font-style: normal;
font-weight: normal;
src: url('./assets/fonts/Qranklestein.ttf');
To define different font-faces of same font, vary the font-style and font-weight properties of the font-face. For example, Muli-Bold-Italic font-face is imported as
@font-face {
font-family: 'Muli';
font-style: italic;
font-weight: bold;
src: url('./assets/fonts/Muli-BoldItalic.ttf');
To use the font in your app, you just need to use the mentioned font-family in any of the CSS styles
:root[mode=ios] .muli,
:root[mode=md] .muli{
--ion-font-family: 'Muli'!important;
font-family: 'Muli' !important;
Different font-faces of same font

Method 2. Using Google Fonts

If you want to skip the hassle of importing fonts from assets, and use the vast variety of Google Fonts, you can simply import them in your index.html like this
<link href="" rel="stylesheet">
and then use the font simply by defining the font-family in a CSS class
:root[mode=ios] .srisakdi,
:root[mode=md] .srisakdi{
--ion-font-family: 'Srisakdi'!important;
font-family: 'Srisakdi' !important;
Font imported from Google Fonts
To find a Google font, visit Google Fonts . You will see a huge variety of fonts
Wide variety of fonts on Google Fonts
Whichever Font you like, click the + sign next to it. Your font gets selected. Click the hovering div at the bottom saying 1 family selected , you will see the details of the selected font
Use the <link> and CSS code snippet to import the font into your app as explained earlier in this section. If you have variety of font styles (Bold, italic etc ) make sure to include that in the CSS declarations as explained in Method 1 above.