|The GFONT Procedure|
To create a font, you must create a data set that contains font information. Typically, you use a DATA step to create a SAS data set from which the GFONT procedure generates the font. The data set is referred to as the font data set and you can specify it with the DATA= argument.
To produce the font, invoke the GFONT procedure and specify the data set that contains the font information. In addition you can include options to modify the design and appearance of the font. For example, the following statement uses the data set FONTDATA to generate the font MYLOGO:
proc gfont data=fontdata name=mylogo;
For a demonstration of the font creation process, see Creating Figures for a Symbol Font.
procedure uses three types of data sets: the
font data set, the kern data set, and the space data set. Each type of data
set must contain certain variables and meet certain requirements. The following
sections explain what each data set contains, how it is built, and what the
requirements of the variables are.
The font data set consists of a series of observations that include the horizontal and vertical coordinate values and line segment numbers that the GFONT procedure uses to generate each character. In addition, each observation must include a character code that is associated with the font character and is used to specify the font character in a text string. The font data set also determines whether the font is stroked or polygon. A font data set that generates a polygon font produces an outline font by default. You can use the FILLED option with the same data set to generate a filled font.
The variables in the font data set must be assigned certain names and types. The table below summarizes the characteristics of the variables which are described further in Font Data Set Variables.
|Variable||Description||Type||Length||Valid Values||With Stroked Fonts||With Polygon Fonts|
|CHAR||the character code associated with the font character||character||1 or 2||keyboard characters or hexadecimal values||required||required|
|LP||the type of line segment being drawn, either a line or a polygon||character||1||L or P||optional||required|
|PTYPE||the type of data in the observation||character||1||V or C or W||optional||optional|
|SEGMENT||the number of the line segment or polygon being drawn||numeric||number||required||required|
|X||the horizontal coordinate||numeric||number||required||required|
|Y||the vertical coordinate||numeric||number||required||required|
The CHAR variable takes any character as its value, including characters that you can enter from your keyboard and hexadecimal values from '00'x to 'FF'x. (If you use hexadecimal values as CHAR values, your font may not work correctly under a key map that is different from the one under which the font was created because positions that are not defined in one key map may be defined in another.)
When you specify the code character in a text string, the associated font character is drawn. For example, if you create a Roman alphabet font, typically the characters you specify for CHAR are keyboard characters that match the character in the font. All of the observations that build the letter A have a CHAR value of A. When you specify 'A' in a text string this produces A in the output.
However, if you build a symbol font, the symbols may not have corresponding keyboard characters. In that case, you select a character or hexadecimal value to represent each symbol in the font and assign it to CHAR. For example, in the Special font, the letter G is assigned as the code for the fleur-de-lis symbol. When you specify the code in a text string, the associated symbol displays.
If the CODELEN= option is set to 2, the values for CHAR represent two characters, such as AA, or a four-digit hexadecimal value, such as '00A5'x.
Every group of line segments with an LP value of P is designated as a polygon; if the observations do not draw a completely closed figure, the program closes the figure automatically. For example, the following observations do not contain an LP variable. They produce a shape like the one in Using an LP Value of Line.
Using an LP Value of Line
Using an LP Value of Polygon
Mixing LP Values of Line and Polygon
|V||normal point in the line segment|
|C||center of a circular arc joining two V points|
|W||width value for CHARSPACETYPE=DATA.|
If the GFONT procedure encounters the sequence V-C-V in consecutive observations, it draws an arc that connects the two V points and has its center at the C point. If a circle cannot be centered at C and pass through both V points, the results are unpredictable. Arcs are limited to 106 degrees or less.
If you specify an observation with a PTYPE value of W, it must always be the first observation for a character. Instead of providing digitizing data to the procedure, the observation gives the minimum and maximum X values for the character. Note that in this case, the Y variable observation actually contains the maximum X value. Usually, these values include a little extra space for intercharacter spacing. Use a PTYPE of W only if you have specified CHARSPACETYPE=DATA; otherwise, the points are ignored. For more information on intercharacter spacing, see the description of the CHARSPACETYPE= option .
If you do not specify a PTYPE variable in the font data set, all points are assumed to be V-type points.
The following observations illustrate how the PTYPE variable is used to draw an arc similar to Using the PTYPE Variable to Create an Arc. (After the figure was generated, a grid was overlaid on it to show the location of the points.) A comment following each observation explains its function.
|1||a||1||40||60||P||W||define width of character as 20 font units, which is the number of units from left margin, 40, to right margin, 60|
|2||a||1||45||40||P||V||start line segment at position 45,40|
|3||a||1||45||50||P||V||draw a line to position 45,50, which is start point of arc|
|4||a||1||45||40||P||C||draw an arc whose center is at 45,40|
|5||a||1||55||40||P||V||finish drawing the arc at 55,40|
Using the PTYPE Variable to Create an Arc
proc gfont data=arc name=arcfig charspacetype=data filled ;
When the GFONT procedure draws a stroked character with more than one line segment (for example, the letter E), or a polygon character with a hole (for example, the letter A), it needs to know when one line stops and where the next line begins. There are two ways to do this, as follows:
Use this method for characters that are composed of two polygons, such as a question mark (?). If you draw a polygon with a hole in it, such as the letter A, use the second method.
The first method is preferred, unless you are creating a polygon character with a hole in it. In this case, you should separate the lines with a missing value and keep the same segment numbers. (Note that if you use separate line segments when you create a polygon with a hole, the results may be unpredictable.) For example, observations such as the following from a data set called BOXES were used to draw the hollow square in Drawing Nested Polygons. The data points that form the figure are laid out on a grid shown next to the square.
Note that observation 5, which has missing values for X and Y, separates the observations that draw the inner box from those that draw the outer box and that the segment number is the same for all the observations. Drawing Nested Polygons was generated with a GFONT statement like the following:
proc gfont data=boxes name=boxes filled;
Note that the FILLED option is included and that only the space between the two squares is filled.
Drawing Nested Polygons
Note: When you specify PTYPE=W, both X and Y contain horizontal coordinate
You can create a font data set by digitizing the shape of the characters or figures either manually or with special digitizing equipment. To create a font data set by digitizing the characters manually, follow these steps:
If the polygon has a hole in it, as in the letter O, keep the line segment number and separate the lines with a missing value. Use the same value for CHAR for all of the observations that describe one character.
This process is illustrated in Creating Figures for a Symbol Font.
The kern data set consists of observations that specify how much space to add or remove between any two characters when they appear in combination. This process, called kerning, increases or decreases space between the characters. Kerning usually is applied to certain pairs of characters that, because of their shape, have too much space between them. Reducing the space between characters may allow part of one character to extend over the body of the next. Examples of some combinations that should be kerned are AT, AV, AW, TA, VA, and WA.
You can apply kerning to the intercharacter spacing
that you specify with the CHARSPACETYPE= option (except for uniform fonts).
You can refine the kerning of your characters as little or as much as you
like. You assign the kern data set with the KERNDATA= option.
The kern data set must contain these variables:
Each observation in a kern data set names the pair of characters to be kerned and the amount of space to be added or deleted between them. To create a kern data set, follow these steps:
data kern1; input char1 $ char2 $ xadj; datalines; A T -4 D A -3 T A -4 ;
proc gfont data=fontdata name=font2 charspacetype=data kerndata=kern1 nodisplay; run;
Comparison of Kerned and Unkerned Text illustrates how you can use the KERNDATA= option to create a font in which the space between specified pairs of letters is reduced. The characters A, D, and T are shown as the word DATA. The first line uses the unkerned font, FONT1, and the second line uses the kerned font, FONT2. Note that the characters in FONT2 are spaced more closely than the characters in FONT1.
The following title statements specify the kerned and unkerned fonts and are used with the GSLIDE procedure to produce Comparison of Kerned and Unkerned Text:
title2 lspace=6 f=font1 h=10 j=l 'DATA'; title3 lspace=4 f=font2 h=10 j=l 'DATA';
Comparison of Kerned and Unkerned Text
As the height (point size) of a font increases, less space is required between letters in relation to their height. If the point size decreases, more space may be needed. The space data set tells the GFONT procedure how much to increase or decrease the intercharacter spacing for a given point size. Like kerning, spacing is added to or subtracted from the intercharacter spacing that is specified by the CHARSPACETYPE= option. However, kerning applies the adjustment to specified pairs of characters, while spacing is applied uniformly to all characters.
Values that are specified in the space data set are
added to the normal intercharacter spacing and any kerning data. Normal intercharacter
spacing is determined by the CHARSPACETYPE= option.
The space data set must contain these variables:
Each observation in a space data set specifies a point size (SIZE) and the amount of space (ADJ) to be added or subtracted between characters when a font of that point size is requested. When you specify a point size that is not in the space data set, the adjustment for the next smaller size is used. To create a space data set, follow these steps:
data space1; input size adj; datalines; 6 40 12 0 18 -40 24 -90 30 -150 36 -300 42 -620 ;
proc gfont data=reflib.fontdata name=font3 charspacetype=data spacedata=space1 nodisplay; run;
Comparison of Text with and without Spacing Adjustments illustrates how to use the SPACEDATA= option to generate a font in which intercharacter spacing is adjusted according to the height of the characters. The characters A, D, and T are shown as the word DATA. Each pair of lines displays the word DATA and at the same size uses first the font with spacing adjustment (FONT3) and then the original font (FONT1). Note that as the size of the characters increases, the space between them decreases.
The following title statements are used with the GSLIDE procedure to produce Comparison of Text with and without Spacing Adjustments:
title2; title3 f=font3 h=.25in j=l 'DATA'; /* 18 points */ title4 f=font1 h=.25in j=l 'DATA'; title5; title6 f=font3 h=.50in j=l 'DATA'; /* 36 points */ title7 f=font1 h=.50in j=l 'DATA'; title8; title9 f=font3 h=1.0in j=l 'DATA'; /* 72 points */ title10 f=font1 h=1.0in j=l 'DATA';
Comparison of Text with and without Spacing Adjustments
Top of Page
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.