magazine resources subscribe about advertising

New Architect Daily
Commentary and updates on current events and technologies

CMP Media E-Book

Download your copy today.

Research
Search for reports and white papers from industry vendors and analysts.

This Week at NewArchitect.com Subscribe now to our free email newsletter and get notified when the site is updated with new articles







Day of Defeat Online Gaming

 New Architect > Archives > 2000 > 04 > Java@Work  

Best Font Forward

By Al Williams

Java has never been famous for its flexibility with fonts. In all fairness, decreased font versatility may be a necessary sacrifice for the myriad platforms that Java supports. Still, the documentation for java.awt.Font says that you can depend only on Serif, SansSerif, Monospaced, Dialog, DialogInput, and Symbol fonts—not much of a choice. You can always use system-specific fonts, but by doing so you lose portability.

The Java 2 Platform (JDK 1.2) improves the situation measurably by extending the Font class; however, doing anything uncommon still requires quite a bit of work. Besides, not all browsers support the latest version of Java, so all of your extra effort might only prohibit some users from using your applet. With Java 2 you can construct a Font object using one of the predefined names, or you can use the name of a native font. You can also pass a Map-derived object (like a Hashtable) that contains attributes, defined by the TextAttribute class, to describe the font. You can even retrieve an array of all the fonts on a system using GraphicsEnvironment.GetAllFonts. Armed with this list, you can make new fonts using deriveFont. What if you just want simple font effects that are compatible with any platform, even with older browsers? The answer is to create your own special effects using simple, widely available functions. Using text to do your drawing, this can be quite simple and effective.

In this month's column, I'll show you how to create some simple text effects like those in



  Day of Defeat Online Gaming

home | daily | current issue | archives | features | critical decisions | case studies | expert opinion | reviews | access | industry events | newsletter | research | careers | info centers | advertising | subscribe | subscriber service | editorial calendar | press | contacts


Copyright © 2006 CMP Media, LLC Read our privacy policy, your California privacy rights, terms of service.
SDMG Web sites: BYTE.com, C/C++ Users Journal, Developer Pipeline, Dr. Dobb's Journal, DotNetJunkies, MSDN Magazine, Sys Admin,
SD Expo, SD Magazine, SqlJunkies, The Perl Journal, Unixreview, Windows Developer Network, New Architect

web2