We aren't limited in our Android applications to just the built-in fonts. Android supports the creation of Typeface objects from any TrueType font file. TrueType fonts are a standard and work on a variety of platforms. This opens up a wide range of possibilities for our applications.
Many sites on the Internet offer free fonts, and, of course, there are font foundries, companies that create fonts that will sell you a license to use their fonts.
One font that I found that was completely different from Android's built-in fonts is the Chopin Script font by Claude Pelletier. It is in the public domain and available as a free download from a variety of sources such as fontspace.com
(www.fontspace.com/diogene/chopinscript). To use the font, I downloaded it and put the.ttf file (ChopinScript.ttf) into my project's "assets" folder.
The Typeface.createFromAsset method takes in an AssetManager, which can be gotten through a call to getAssets from the Context and the name of the file. It returns a Typeface object that can be passed into the Paint.setTypeface method.
Typeface chops = Typeface.createFromAsset(getAssets(), "ChopinScript.ttf"); paint.setTypeface(chops);
Was this article helpful?