| Dialog | DialogInput | Monospaced | SansSerif | 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 | comes with JRE |
| DialogInput | Courier New | comes with Windows |
| Monospaced | Courier New | comes with Windows |
| SansSerif | Lucida Sans | comes with JRE |
| Serif | Times New Roman | comes with Windows |
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.17] | The information on this page is for non-military use only. | ||
| You are visitor number 11. | Military use includes use by defence contractors. | ||
| You can get a fresh copy of this page from: | or possibly from your local J: drive (Java virtual drive/Mindprod website mirror) | ||
| http://mindprod.com/jgloss/logicalfonts.html | J:\mindprod\jgloss\logicalfonts.html | ||