[ Previous | Next | Contents | Glossary | Home | Search ]
The graPHIGS Programming Interface: Understanding Concepts

Chapter 19. Fonts

This chapter describes the treatment of fonts by the graPHIGS API It includes a discussion of font files, font directories, and font inquiry subroutines.


Font Files

In the graPHIGS API, the shell and nucleus may be running as two different processes. In some cases, they may be running on two different machines with two completely different disk systems. The font definition is read from the disk system which the nucleus can access. When the shell receives a call to the Activate Font (GPACFO) subroutine, it sends a corresponding request to a nucleus which owns the specified workstation. The nucleus searches its own disk system for the specified character set/font pair and loads it into the specified workstation.

The font file is taken from the nucleus's disk to:


Font Directory

Though the font files available to a nucleus will be enough for many applications, there are some cases where you may want to load a font definition to a workstation from the shell's disk. Following are three examples:

  1. The font is an application defined font and you do not want to install the font definition onto the nucleus's disk. If all font definitions must reside on the nucleus's disk, there is no way to avoid exposing your font definition to other applications.
  2. If your application uses multiple nuclei, either simultaneously or one at a time, you may not want to install a font definition to each nucleus. Especially if the font definition may be changed or re-defined, then you might want to keep the font definition file on your application's disk to make it easy to maintain.
  3. The nucleus does not have enough disk space to install all font definitions that your application requires. This will occur when the nucleus is implemented on a workstation with a small disk system or or one without any disk system such as the IBM 6090.

As a result of these requirements, the graPHIGS API supports the concept of a font directory. The font directory can be viewed as a run time disk system for fonts, which is dynamically created and attached to the shell by the Create Font Directory (GPCRFD) subroutine. A font directory is a nucleus resource and can be shared by multiple application processes using the Attach Resource (GPATR) subroutine.

When a font directory is created, it is empty. Your application can load any character set/font pair to the font directory using the Load Font (GPLDFO) subroutine. When the shell receives this call, it searches its own disk system for the specified font definition. When the shell finds the font file, it reads the file and sends it to the specified font directory. If the specified character set/font pair is already in the font directory, the font is replaced.

A given workstation can have only one font directory associated to the workstation at any given time. This association is set using the Associate Font Directory with Workstation (GPAFDW) subroutine. If the workstation already has a font directory associated with it, the subroutine call replaces the currently associated font directory.

When Activate Font (GPACFO) subroutine is called, the following actions are performed by the nucleus:

  1. The nucleus checks the workstation to see if it has an associated font directory. If so, it then searches for the specified font definition. If the font definition is found, it is activated on the workstation.
  2. If the specified font definition does not exist in the font directory, or the workstation has no associated font directory, the nucleus' disk system is searched, and if the font exists, the font is activated.
  3. The nucleus generates an error if the specified font definition does not exist in an associated font directory or in the nucleus' disk system.

As described above, the search of a font directory associated to a workstation supersedes the normal font file search order in the nucleus. Note that the contents of an associated font directory affects only subsequent Activate Font subroutines. The contents of a font directory does not affect any character set/font pairs already active on the workstation. Conceptually, each font definition is copied from the font directory to the workstation's font pool when it is activated and becomes independent of the font directory. Even if the font directory is disassociated from the workstation, character set/font pairs which are currently active on the workstation remain active.


Font Inquiries

In Version 1 of the graPHIGS API, the Inquire Annotation Font Characteristics (GPQAFC) returned the following information about how a workstation would process a specific character set and font pair:

The expansion factor information was returned as a deviation from the nominal aspect ratio of the corresponding geometric text font.

The meaning of the GPQAFC inquiry has been changed slightly in Version 2 but will still produce compatible results for Version 1 applications. The expansion factor information has been redefined to be relative to the annotation nominal font aspect ratio instead of the geometric font aspect ratio. To provide compatibility, all the annotation fonts will have the same aspect ratio as the geometric font with the same character set and font identifiers.

The Inquire Extended Annotation Font Characteristics (GPQXAF) subroutine will return the following information in addition to the information returned by GPQAFC

Unlike geometric text fonts, annotation text fonts are workstation specific.

With the introduction of the shell-nucleus concept and the associated nucleus resources, a font may reside in many places. These repositories for fonts include the shell font storage, the nucleus font storage, font directories, and workstations. A given character set and font number could have a different definition in each location. To inquire information about a font in the shell's font storage, use the following inquiry subroutines:

The primary use of GPQFCH and GPQFAR is to compute the length of a text string. GPQFCH returns whether the font has character box definitions for each character (proportional positioning), the amount of space between the capline and top line, the amount of space between the base and bottom lines and the aspect ratio of the nominal character box. GPQFAR returns the aspect ratio of each character within a specified string. This is only useful for a font which has proportional positioning information.


[ Previous | Next | Contents | Glossary | Home | Search ]