Skip to content

Using Google Fonts in an Ionic Application

Published:

2 min read

In this post, I will be showing you to change font in any Ionic 2/3 application. To start with, I will be setting up a new ionic project such that you can refer back to on Github.

$ ionic start ionic-use-google-fonts blank

cd in to the new project created by the above Ionic CLI command and run ionic serve to see the blank template with just a homepage available. As of now, the Ionic application looks like this:

The font here used in the application at global level is default. We will be changing it to Revalia. It’s just a random suggestion, you can pick whatever you want but I’d suggest, if you are doing for the first time or new to Ionic development, pick a font in which you can see the changes reflected in the app.

After selecting the font, open the highlighted link in the screenshot above, in a new tab.

Again, open the link provided in the latin section, just like in the above image and download or save the file directly in you ionic project.

The location to save the file will be YOUR-IonicApp > src/assets/fonts. Create a new directory fonts in the assets folder if not available. Place the file there, and rename it as per your convenience.

Now since we want this font to be used at the global level of application, open app.scss in src/app and first include the local file of the font we want to use and then use that font at global level by using an asterisk * as css-selector:

@font-face {
  font-family: "Revalia";
  src: url("../assets/fonts/revalia.woff2") format("woff2");
}

* {
  font-family: Revalia;
}

Run the ionic application with:

$ ionic serve

Output:

To get the full code, you can visit this Github Repository.

Originally Published at Hackernoon.com


Previous Post
Multi Page Navigation in an Ionic App
Next Post
Basic Navigation in Ionic Applications

I'm a software developer and technical writer. On this blog, I share my learnings about both fields. Recently, I have begun exploring other topics, so don't be surprised if you find something new here.

Currently, working as a documentation lead at Expo.