# Physical Fonts

Starting with the 1.2 release, the Java 2 SDK includes a set of TrueType fonts in the `lib/fonts` subdirectory. Prior to the 1.2 release, the JDK software relied on the host platform fonts. Logical fonts, such as Monospaced, are mapped to the host platform fonts in the `font.properties` file. To distinguish them from the logical fonts, this document refers to the TrueType fonts as physical fonts.

## Benefits

Because physical fonts are included in the Java 2 Platform itself, programmers are guaranteed to have a uniform set of font families available for several locales for use on whatever host platform the Java runtime environment is on. This obviously lessens programmer's dependence on the fonts might be provided by the host platform, which can vary greatly from platform to platform, and from locale to locale.

The SDK's physical fonts offer the following benefits:

- Consistent Look and Feel

  Your applications will look the same on all platforms because they will be using the same fonts. This makes testing, deployment, and support easier in a cross-platform environment.

- Rich Character Sets

  You don't have to switch fonts if you use characters from various scripts. For example, in a text component that uses the Lucida Sans Regular font, you can display characters in Hebrew, Arabic, German, and English, which are all included as part of the SDK's Lucida Sans Regular font. (Asian character sets for the physical fonts are not supported in the current release.)

- Euro Currency Symbol

  All of the physical fonts of the Java 2 Platform support the Euro currency symbol.

## The Physical Fonts Supplied by the Java 2 Platform

The Java 2 SDK provides three font families: Lucida Sans, Lucida Bright, and Lucida Sans Typewriter. Each family contains four fonts, for a total of 12 fonts:

- Lucida Sans Regular
- Lucida Sans Bold
- Lucida Sans Oblique
- Lucida Sans Bold Oblique

- Lucida Bright Regular
- Lucida Bright Bold
- Lucida Bright Italic
- Lucida Bright Bold Italic

- Lucida Sans Typewriter Regular
- Lucida Sans Typewriter Bold
- Lucida Sans Typewriter Oblique
- Lucida Sans Typewriter Bold Oblique

## Related Methods in the Java 2DTM API

- `GraphicsEnvironment.getAvailableFontFamilyNames`

  Returns an array of font family names available for use, including font families provided by the host platform as well as the families provided by the SDK.

- `GraphicsEnvironment.getAllFonts`

  Returns an array of physical fonts in this environment. The fonts returned include the fonts supplied by the host platform and the physical fonts of the SDK.

## Using the SDK's Physical Fonts

You can use the physical fonts in the SDK in the same way that you'd use any other fonts such as those supplied by the underlying platform. For example, you can create an instance of the Lucida Sans Regular font with the usual `Font` constructor. For example, this constructor would create a `Font` instance for the Lucida Sans Regular font.

>     Font f = new Font("Lucida Sans", font.PLAIN, 12)

The following example would create a `Font` instance for the Lucida Sans Typewriter Oblique font.

>     Font f = new Font("Lucida Sans Typewriter", font.ITALIC, 18)

The Java 2 Platform's physical fonts are located in the `jre/lib/fonts` folder in the Java 2 SDK and in the `lib/fonts` directory of the Java 2 Runtime Environment. Users can add additional TrueType fonts to this directory for use by their programs. The TrueType fonts must be Unicode encoded.

Copyright © 1998-99 Sun Microsystems, Inc. All rights re served.