| Fun with Fonts |
|
|
|
|
Inevitably, you’ll get the question “hey, can we change this font?” when doing application development. The answer depends on what fonts come with the platform, whether you can add other fonts, and how to apply them to the widget or whatever needs the font change.
Android is no different. It comes with some fonts plus a means for adding new fonts. Though, as with any new environment, there are a few idiosyncrasies to deal with. Android natively knows three fonts, by the shorthand names of “sans”, “serif”, and “monospace”. These fonts are actually the Droid series of fonts, created for the Open Handset Alliance by Ascender. For those fonts, you can just reference them in your layout XML, if you choose, such as:
This layout builds a table showing short samples of four fonts.
Notice how the first three have the The three built-in fonts are very nice. However, it may be that a designer, or a manager, or a customer wants a different font than one of those three. Or perhaps you want to use a font for specialized purposes, such as a “dingbats” font instead of a series of PNG graphics. The easiest way to accomplish this is to package the desired
font(s) with your application. To do this, simply create an Then, you need to tell your widgets to use that font. Unfortunately, you can no longer use layout XML for this, since the XML does not know about any fonts you may have tucked away as an application asset. Instead, you need to make the change in Java code:
Here, we grab the Then, it is just a matter of telling the The results?
Note that Android does not seem to like all TrueType fonts. I
spent a lot of time trying to figure out what I was doing wrong with this sample,
before switching to a different font, and everything “just worked”. When Android
dislikes a custom font, rather than raise an Also note that TrueType fonts can be rather pudgy, particularly if they support an extensive subset of the available Unicode characters. The Handmade Typewriter font used here runs over 70KB; the DejaVu free fonts can run upwards of 500KB apiece. Even compressed, these add bulk to your application, so be careful not to go overboard with custom fonts, lest your application take up too much room on your users’ phones.
Source: http://androidguys.com/2008/08/18/fun-with-fonts/
Set as favorite
Bookmark
Email This
Hits: 4618 Comments (7)
![]() http://www.wholewatches.com/cartier-watches.html
written by wow gold , December 19, 2009 do you like replica hangbags and replica watches
report abuse
vote down
vote up
Votes: -1
http://www.dunk2u.com
written by cheap ugg boots , December 31, 2009 Just because it’s a tough-as-nails ugg outlet store doesn’t mean you can’t wear it everywhere. If you want something casual, cozy,wholesale ugg boots and beautifully crafted, you can take your pick from Emu’s wide range of designer footwear. Emu Boots are high-end fashion and space-age technologies are combined to produce products that last for years. You’d be hard-pressed to find anything superior than stepping into EMU Australia’s hottest footwear.Everything is for you,merryUgg Boots christmas!
report abuse
vote down
vote up
Votes: -2
http://www.cheapuggsonline.net
written by ugg outlet , January 05, 2010 Isaac Newton: Why apples are falling uggs outlet on Google today.Isaac Newton, one of the most important names in science, has inspired a surprising logo swap on Google's homepage. The mind behind our modern laws of gravity and motion would have turned 367 years old on January 4. The search engine giant is ringing in the big day with its first cheap ugg animated "Google doodle."
report abuse
vote down
vote up
Votes: -1
...
written by Nike star , January 06, 2010 LeBron James Shoes
Nike Air Zoom LeBron III Nike air Zoom LeBron soldier II Nike Zoom LeBron 793 Nike Zoom LeBron James Soldier report abuse
vote down
vote up
Votes: -1
Portland coupons on android phone
written by soch , January 09, 2010 Thanks a lot for great tips om android fonts.
report abuse
vote down
vote up
Votes: +2
ugg boots
written by uggs outlet , January 18, 2010 Many womenswear trends ultimately cross over to the men's market, but not all. Take the Ugg boot. Ugg is really punting its footwear in uggs outlet the direction of gentlemen – motorbike boot-style Uggs, rugged waterproof Uggs – but we're not biting.
It can't be a matter of effeminacy; they're meant to be unisex. Those who first favoured the wool-lined sheepskin boot were not only men, but men of a macho stripe befitting footwear seemingly named after the main ugg boots for sale conversational gambit of the caveman: first world war aviators and sheep-shearers in rural Australia. report abuse
vote down
vote up
Votes: -1
Write comment
|