首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

运用外部的字体

2012-07-29 
使用外部的字体We aren’t limited in our Android applications to just the built-in fonts. Android sup

使用外部的字体
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.

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);

热点排行