Font Management

A very important part of PROforma concerns the manipulation and displaying of vector fonts. The vector fonts which are used in PROforma are a direct descendant of the Adobe Type I font format, but optimised for efficient access, and low memory consumption. Programs exist to convert Adobe Type 1 fonts for PROforma (pfb2pff).


Font Loading

Fonts have to be loaded upon request of the client, and can also be released from memory by the client. Fonts only take a little more memory than they occupy on disk. Fonts are always referenced by their name. Font names are case dependant ! If a font is loaded by several gstates, it is only kept in memory once. So a font is not released from memory if there is at least one gstate which has that font loaded (or the font is resident - resident fonts are never released). A font which is not resident is always removed from memory when there are no more gstates which have loaded that font.

Resident fonts never have to be loaded by a gstate. They are always available (so they are always in the fontlist).

PFFontLoad
Load the given font file into memory, to make that font available to the client. This command will automatically select the just loaded font (the current fontsize is not affected by this call). This command needs a fontname. The corresponding filename is searched in the fontmap. So only fonts which are in the fontmap can be used. Font files are searched 'as is', and on the configured path.
PFFontUnLoad
Stop using the given font. After PFFontUnLoad the current font is no longer defined. If the font is not loaded by any other gstate (and the font is not resident), then the memory which this font occupies will be released. This actually allows PROforma to release the font. The client can no longer use that font, unless it is loaded again.
PFFontSelect
Select the font with given name as current font. The new font will be at the current fontsize.
PFFontScale
Scale the current font to the given point size. Scaling a font is always relative with the CTM.

Font Information

PFFontNameGet
Get name of current font.
PFFontFamilyGet
Get name of font family of current font.
PFFontVersionGet
Get version of current font.
PFFontWeightGet
Get weight of current font.
PFFontNoticeGet
Get notice of current font. This usually includes details about creator and/or copyright on the font.
PFCharAvailable
Routine to allow the client to know whether a character (with given unicode) is available in the current font. Note that the character is only searched in the current font. It may actually be displayed when the character is displayed because the character may be extracted from the builtin font.
PFWidth, PFStringWidth
Get the width of a string.
PFWidthKern, PFStringWidthKern
Get the width of a string, when displayed with kerning.
PFFontBbox, PFPFontBbox
Get the FontBbox. This allows you to find out the maximum amount a character can extend to the right and top, and to the left and bottom.
PFPFontBbox works slightly different. It tries to approximate the fontbbox in pixels by determining a bbox in which the letters 'W', 'f', 'g', 'm' fit. As it is possible for some characters to extend further in any direction as these letters, you can also add an extra character to the approximation. In general, this returns a bbox which fits most characters (capitals with accents probably not though).

Available Fonts

Information about all the available fonts. This allows the client to know which fonts are loaded and can be used.

PFFontCount
Get the number of fonts which are loaded (in the fontlist).
PFFontNext
Select the next font in the list of fonts as the current font. If the last font in the list was the current, an error will be returned (and the current font is not changed).

And you can enquire about all the fonts which are in the fontmap.

PFFontCountAll
Get the number of fonts in the fontmap. Also makes sure that the next enquiry with PFNextFontName will return the first font in the fontmap.
PFFontNextName
Get the name of the next font in the fontmap.

Text display

PROforma always uses UniCode character codes. These character code are "short" in size (and not char). A char just didn't allow enough possible characters.

All the routines to display text (or get the width thereof) are available in two varaints. The first variant uses unicode characters directly (a unicode string is the same as a c string, \0 is used as end of string marker). The other variant (the commands which start with "PFString") use strings in the local character set (ordinary strings).

The requested characters are retrieved from the current font at the current fontsize. If the character is not available in the current font, the character will be retrieved from the builtin font. If the builtin font also doesn't contain the character, then an empty character (no width, not visible) is displayed.

PFShow, PFStringShow
Show the requested string at the current position. Characters are placed proportional. The current position will now be the place where the next character should be placed.
PFShowKern, PFStringShowKern
Show the requested string at the current position with kerning. The current position will now be the place where the next character should be placed.
PFShowX, PFStringShowX
Show the requested string at the current position. The advance width of the characters is overwritten with the given values. The vertical advance width is taken as zero. The current position will now be the place where the next character should be placed.
PFShowXY, PFStringShowXY
Show the requested string at the current position. The advance width of the characters is overwritten with the given values. The current position will now be the place where the next character should be placed.
PFShowTrack, PFStringShowTrack
Show the requested string at the current position. The current font size is used, but characters are positioned in such a way to make sure that the string has the given width (using tracking).
PFShowJust, PFStringShowJust
Same as PFShow (resp. PFStringShow), except that some whitespace is added or subtracted at the space characters, to make sure that the text is displayed with full justification. The requested width of the line has to be specified.
PFShowKernJust, PFStringShowKernJust
Same as PFShowKern (resp. PFStringShowKern), except that some whitespace is added or subtracted at the space characters, to make sure that the text is displayed with full justification. The requested width of the line has to be specified.

Normally, PROforma always attempts to be completely device independent. Unfortunately, when displaying text on screen, you often prefer quality above device independence. The main problem is that spaces are usually too small to seperate characters properly. Therefore, there are some special routines which force the distance between all characters to be consistent (one pixel). These commands should only be used on screen, as it would remove all character spacing on devices with a higher resolution.

As these commands are only ment to be used on screen devices, they use the PFP prefix. In fact, the string width commands actually return the width in pixels.

PFPShow, PFPStringShow
Show the string using one pixel spaces between all characters.
PFPWidth, PFPStringWidth
Get the width a string occupies when displayed with PFPShow or PFPStringShow commands. The width is given in pixels.

String handling

PFExtraEOS
All strings which are passed to PROforma are '\0' terminated c strings. However, it may in some cases be useful to have an extra symbol which can be interpretted as end of string marker. Such an extra marker can be specified with this command. You can reset the extra marker by setting it to '\0'
PFPrintEscape
When strings which have to be displayed are passed using the local character set, not all of the supported character set can be accessed. Therefore, PROforma allows an escape sequence to specify all the characters in the supported character set when normal strings are used. You are then allowed to specify the character by putting the (case dependent) name or (decimal) unicode between backslashes. However, as this behaviour is not always wanted, you can switch it on or off.

Supported character set

PFCharNameTable
To be able to use the supported character set, PROforma gives you access to a table which contains all the supported characters. Both the name and unicode of each character is given. Please note that the name of the supported characters is case dependent (for example to allow both Egrave and egrave as character names).
PFASCII2UnicodeTable
Although PROforma allows you to use the local character set for most of the font handling commands, it may sometimes be necessary to convert characters in the local character set to unicode. Therefore, there is this table which gives the unicode value for each character in the local character set.

Cache handling

Normally all font display operators try to use the font cache. However, as there are some problems with the usage of the font cache, the use of the font cache can also be switched off. This can be done because all font display operators work as if there is no clipping path when the cache is switched on !

PFCacheUse
Tell PROforma whether or not the fontcache should be used.

Charpaths

For drawing programs like LINEdesign it is interesting to be able to extract the outline of a character from a font as this allows the user to make some individual changes to the characters. Therefore this feature is supported by PROforma. And consists of a loop like :

select character which should be converted
DO
    get the next path operator
    process it
UNTIL end of character
Note: the PFCharPathInit and PFCharPathEl commands should only be used in such a loop, just as all the other iterators in PROforma (no other font operators shoud be used inside the loop).
PFCharPathInit
Select the character for which the outline will be extracted. Selects that character from the current font at the current size of that font.
PFCharPathEl
Get the next path element for that character. This can be a move, line, curve, width or end of character command (which can be interpreted as a PFPathDraw). The coordinates which are returned are absolute coordinates, only the character origin has to be added.

PROGS, Professional & Graphical Software
last edited December 4, 1996