This chapter describes the treatment of fonts by the graPHIGS API It includes a discussion of font files, font directories, and font inquiry subroutines.
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:
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:
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:
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.
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
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.