| Dialog | DialogInput | Monospaced | SansSerif | Serif |
| cursive | fantasy | monospace | sans-serif | serif |
The five Java logical fonts Dialog, DialogInput, Monospaced, SansSerif, Serif are guaranteed available to every Java program. They will be automatically mapped onto the most suitable font available at a given platform. They generally will not work in HTML or CSS. Note how they have slightly different spellings than the equivalent logical fonts in HTML/CSS: Java’s Monospaced vs CSS’s monospace, SansSerif vs sans-serif and Serif vs serif.
Since every computer supports a different set of fonts, Sun decided to ensure at least these five fonts were supported everywhere: Serif, SansSerif, Monospaced, Dialog, and DialogInput. These are not actual fonts, but they map to some actual font either built-in to the OS or supplied by Sun in TrueType form. The key is these fonts you can count on being present everywhere.
If there were no logical fonts it would be impossible to write a program guaranteed to run everywhere since they are no physical fonts guaranteed to be installed everywhere. By mapping logical fonts to physical fonts, monospaced for example can be mapped onto the most popular monospaced font on a given platform, without Sun having to licence and provide the physical font for every conceivable platform.
Even though your computer may have hundreds of fonts installed, with AWT, you can only get at five of them, five chosen by Sun, (unless you use drawString). Sun chooses the physical fonts from ones it bundles and ones known to be installed with the OS, and then maps the five logical fonts onto five chosen physical ones. Sun chose physical fonts with support for a wide selection of Unicode characters to represent its logical fonts.
| Java Logical Fonts In Windows | ||
|---|---|---|
| Java Logical Font | Corresponding Actual Font | Notes |
| Dialog | Lucida Sans or Arial plus extra chars in Vista. | comes with JRE |
| DialogInput | Courier New | comes with Windows |
| Monospaced | Courier New | comes with Windows |
| SansSerif | Lucida Sans or Arial plus extra chars in Vista. | comes with JRE |
| Serif | Times New Roman | comes with Windows |
In Vista, it would make more sense to map Monospaced ⇒ Consolas and Dialog ⇒ Segoe UI. You could do that now by testing the platform and selecting specific rather than logical fonts when you are running under Vista.
In JDK 1.4+ and perhaps earlier you also have guaranteed Swing fonts Lucida Bright, Lucida Sans and Lucida Sans Typewriter which are not strictly speaking considered logical fonts, even though Sun makes them universally available by shipping them with the JRE.
Swing components can use the five Java logical fonts and any other scalable (i.e. OpenType, PostScript or TrueType) fonts installed on the system, e.g. Lucida Console or Tiresias PCFont Z.
![]() |
and suggestions to improve this page to Roedy Green : | ||
| Canadian Mind Products | |||
| mindprod.com IP:[65.110.21.43] | |||
| Your face IP:[38.103.63.62] | ![]() | ||
| You are visitor number 11. | |||
| You can get a fresh copy of this page from: | or possibly from your local J: drive (Java virtual drive/mindprod.com website mirror) | ||
| http://mindprod.com/jgloss/logicalfonts.html | J:\mindprod\jgloss\logicalfonts.html | ||