Custom fonts in Titanium

Posted By : Siddharth Dixit | 25-Feb-2015

Custom Fonts in Titanium

This blog describes the addition of custom fonts in Titanium. Sometimes there are requirements to add custom fonts such as handwritten, fancy fonts etc. into the application. Fonts give unique texture to the text used.

1)  First of all, create the project in Titanium.

2)  Go to app>assets folder and create the fonts folder for alloy project, add the fonts folder into the resources folder in case of classic project.

 

4)  Place the respective fonts files into it, the font files must be in .otf and .ttf format.

5)  Open the tiapp.xml file and write the following code into ios plist.

 <ios>

        <plist>

            <dict>

               <key>UIAppFonts</key>

                <array>

                    <string>fonts/Impact.ttf</string>

                </array>

            </dict>

        </plist>

    </ios>

 

Lastly, write the following code in app.js -

var label = Ti.UI.createLabel({
	text: "Hello world",
	textAlign :'center',
	font: {
		fontSize: 24,
		fontFamily:'Impact'
		
	},
	color: "#686868",
	height: Ti.UI.SIZE
});
win.add(label);
win.open();

 

Thanks

About Author

Author Image
Siddharth Dixit

Siddharth is an iPhone and Android application developer with experience in Titanium Framework .

Request for Proposal

Name is required

Comment is required

Sending message..