Using Custom Fonts
Using custom fonts is very easy and straight-forward in Ionic 4 apps. There are two ways it can be done
Last updated
Using custom fonts is very easy and straight-forward in Ionic 4 apps. There are two ways it can be done
Last updated
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
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
To use the font in your app, you just need to use the mentioned font-family
in any of the CSS styles
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
and then use the font simply by defining the font-family in a CSS class
To find a Google font, visit Google Fonts . You will see a huge variety of 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.