Java Tips Weblog

Visual Font Designer

Posted by Darryl Burke on November 30, 2008

When trying to create an attractive Font, the first challenge is usually to research the difference that applicable attributes make to its appearance. Applying and reviewing numerous combinations of attributes can be a tedious exercise.

VisualFontDesigner makes it a breeze to quickly visualize the effects of most of the available attributes, with the added bonus of generating a code block that can be directly copied to recreate the font elsewhere.

The nature of GUI programming demands some familiarity with setting custom fonts. The Font class makes the setting of only two attributes – Bold and Italic – easy, while largely obscuring the wide range of font variations possible by application of other attributes.

While the primary purpose behind VisualFontDesigner is to provide a quick, easy, and fun way to customize a font, it is also hoped that perusing the code will familiarize the casual GUI programmer with the APIs involved in creating a range of custom fonts, and also encourage experimenting with the generated code to produce still more variations.

visual-font-designer

All controls of VisualFontDesigner are furnished with tool tips to facilitate immediate productive use of the tool. Fonts that lack the glyphs for common text are shown in red in the Font family combo box.

The attributes that can be manipulated are

  • Font family
  • Font size
  • Bold
  • Italic
  • Underline
  • Strikethrough
  • Kerning
  • Foreground / Background
  • Swap colors
  • Width
  • Tracking
  • Superscript

The Foreground and Background of a Component may be set to a Color. The corresponding attributes of Font, however, may be instances of any class implementing Paint. This makes it possible to design some interesting fonts using MultipleGradientPaint and TexturePaint.

For ease of use, VisualFontDesigner limits the selection of the Foreground and Background attributes to Color.

Get The Code

VisualFontDesigner.java

Related Reading

Java API: java.awt.Font
Java API: java.awt.font.TextAttribute

2 Responses to “Visual Font Designer”

  1. aliefte said

    it’s very nice blog.. thanks so much for share knowledge about java.. this blog is helpfull to me whose beginner java programming.. :)

  2. Darryl Burke said

    Thank you, Aliefte. We’re glad you like it.

    Cheers, Darryl

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>