How to easily add custom fonts (typeface) to your B4A android applications

Today, I bring you another simple tutorial on how to add custom fonts easily to B4A android applications.

B4A is the fastest growing android applications development IDE out there. With a large community  of developers always available to attend to your needs.

Download B4A link

A lot of people emailed me asking this questions. Now, why would you want to add custom fonts to your applications? N0te I will be using font and typeface interchangeably. Lets get stared.

WHY ADD CUSTOM FONTS TO YOUR ANDROID APPLICATIONS

Well, applications are not only about coding, the interface also matters. B4A currently has 3 typefaces that is SERIF, Monospace and Sans-Serif which is not enough. And typefaces like handwriting font or even your official corperate typeface can also make your UI beautiful.

Ways in Adding typeface

I will be highlighting on 3 ways but we will actually use two method.

You can add the typeface by Code.

To do this;

  1. click on File Manager in your IDE
  2. click on Add Files
  3. Navigate to where you have your fonts on your computer and add them
  4. Next Write this few lines of code to apply it to labels, edittext, or any other control you like.

 

Looking a the Code Above, I added 3 files to my assets folder, i then declared a variable with type “TYPEFACE”

I loaded the fonts and assign it tot he variables.

Now the last thing left is just applying it to the controls. If you want to apply the typeface to all views at once, you can use this code below

 

Adding the typeface through the Wysiwyg Designer

To do this

  1. Click to open the WYSIWYG Designer to open
  2. click on add files – A dialog will open, choose the font you will like to include
  3. Select the View you will like to apply the font to
  4. click on the Typeface dropdown in the properties pane, your new fonts should be listed there
  5. Select it and apply. See image below

 

Finally the third method

Using a library

There is a library by NJDude in the b4a Forum. Download and add to your project.

Instructions are on this  PAGE HERE

DOWNLOAD SOURCE CODE 

Congratulations. Remember to leave your comments below if you find any difficulties.

b4a banner

2 Comments

Leave a Comment

Your email address will not be published. Required fields are marked *