Working With Custom Fonts

Dheeraj Kumar Gunti

Reading Time : ( words)

Beautiful fonts make the appearance of the application crisp and smooth. There are lot of fonts which iOS supports in using them and even if you are looking for a different font you can do it with Custom Font concept.

Following is the simple example and procedure for using custom fonts.

As in general create an iOS application and Create a sample view controller.

(Optional) Create a folder named Fonts (Good Practice to have this so that it is easy to understand).

Download your font from Font Place. Add the .ttf file to the Fonts Folder.

Right click on the folder and choose build action as content as shown in the below picture. This gives an indication to the application that the file should render as a separate content file.

Open Info.Plist and click on source tab in the bottom. Add New Entry the Property list file and Choose "Fonts Provided by Application" and specify the path of the font file as string. (Shown in the below picure)

Note: Please specify the exact path of the font located.

Here is the sample code to use the custom font.

var lblTitle = new UILabel (new CGRect (20, 190, 300, 60));
lblTitle.Font = UIFont.FromName ("Calibri", 20);
lblTitle.TextColor = UIColor.Blue;
lblTitle.Text = "Sample Custom Font";
this.View.AddSubview (lblTitle);


Enjoy Coding.... :)