Jump Over Left Menu
Chapter 3: Output Primitives
Chapter 2 has given an overview of the structure facilities in PHIGS and how traversal of structures creates graphical output. In Section 2.3, the polyline structure element was described with two of its attributes as the minimum necessary to describe the concept of structure traversal.
This Chapter will describe the output primitives available in PHIGS and their associated attributes.
PHIGS introduces the concept of an aspect which describes how an output primitive is drawn. For example, linetype and line width scale factor are aspects of the polyline primitive. Entries in the PHIGS traversal state list define the attributes of the output primitive. The attributes define how the aspects of the output primitive are linked or bound to the output primitive. In the simplest case described so far, the attribute controlled by SET LINETYPE directly controls the line type aspect. More complex control is possible than in this simple example.
The coordinates used in the definition of structure elements are called modelling coordinates. The application can choose the coordinate system most appropriate to its needs. On structure traversal, modelling transformations may be applied to the coordinates so that the coordinates of the output primitive created are different from the coordinates in the structure element. PHIGS calls this coordinate system world coordinates.
Structure traversal occurs when a structure is posted to a workstation. The structure traversal creates a graphical scene in world coordinates which is viewed by the specified workstation. The viewing process itself is quite complex (particularly in 3D). Suffice it to say that the world coordinate scene is mapped to a picture in Normalized Projection Coordinates (NPC) and that picture or some part of it is displayed on the workstation. The transformation of coordinates is shown in Figure 3.1.
This viewing pipeline will be described in more detail in Chapter 7. The simplified 2D viewing pipeline will be described in Chapter 6. The need to describe the viewing pipeline here is related to when attributes are bound to the output primitives. In PHIGS, they can either be bound as part of the world coordinate scene or the binding can be delayed until the display is created from the NPC picture.
Figure 3.1: Transformation of coordinates
In the following sections, the structure elements associated with output primitives will be described giving the meaning of the output primitive created from the structure element on traversal. The description will be informal in that the function that creates the structure element will be described as though it created the output primitive directly whereas this only happens on traversal.
The output primitives in PHIGS are:
- polyline: which draws a sequence of connected line segments;
- polymarker: which marks a sequence of points with a symbol;
- fill area: which defines the boundary of an area to be displayed;
- fill area set: which defines the boundaries of a set of areas to be displayed as one;
- text: which draws a sequence of characters;
- annotation text: which draws a sequence of characters to annotate a drawing;
- cell array: which displays an image;
- generalized drawing primitive: which provides non-standard facilities in a standard way.
For the following examples, the boundary of the figures extends from 0 to 12 in the X-direction and 0 to 8 in the Y -direction. Only the first 5 output primitives will be described in this Chapter. The last 3 are described in Chapter 13.
3.2.1 The functions
Two functions are provided in PHIGS:
POLYLINE 3(N, XA, YA, ZA) POLYLINE(N, XA, Y A)
Each defines an output primitive consisting of a sequence of connected line segments. The second function is a 2D shorthand form of the first as far as the output primitive created is concerned. POLYLINE 3 defines a set of N-l line segments where (XA(1),YA(1),ZA(1)) is connected to (XA(2),YA(2),ZA(2)), which is connected to (XA(3),YA(3),ZA(3)) and so on until (XA(N-1), YA(N-1), ZA(N-1)) is connected to (XA(N), YA(N), ZA(N)).
POLYLINE defines the same sequence of line segments where it is assumed that the ZA values are all zero. As stated in the previous section, the coordinates are defined in modelling coordinates and are transformed by the traversal and viewing to an equivalent device coordinate form on the workstation. For example:
DATA XPL /2, 4, 6, 8, 10 / DATA YPL /l, 5, 2, 6, 4/ POLYLINE(5, XPL, YPL)
On traversal, the polyline generated will be as in Figure 3.2. The assumption is that the polyline defined in world coordinates is mapped onto an area of the display with the same aspect ratio.
Figure 3.2: A polyline
3.2.2 Polyline aspects and registration
The polyline has three aspects to control its appearance on a display and allow two similar polylines to be differentiated. They are linetype, linewidth scale factor and polyline colour index. The method of setting these aspects will be described in Chapter 4.
PHIGS has a standard scheme for organizing a set of choices of limited number such as linetype. A positive integer value starting at 1 defines the linetypes that are mandated to be available in an implementation. Larger values than this minimum set may be available. If these are defined, there are precise meanings assigned to them. The set of graphics standards (GKS, CGM, PHIGS etc) have a common registration scheme for these  . For example, the mandatory set in PHIGS is from 1 to 4 with linetype values greater than 4 available in the registered list. At this time, other linestyles are in the process of registration. The number implemented in a PHIGS product is one criterion for choosing between two implementations.
Some hardware will provide linestyles not in the registered list. Also, a PHIGS implementation may be aimed at a specific community where linestyles need to be implemented which are not of general interest. The implementor is allowed to use values less than or equal to zero to define these non-standard linetypes.
Only having 4 linetypes guaranteed in an implementation means that either the application has to be restricted to use only these possibilities or the application may not port from one environment to another. The PHIGS philosophy of not causing unnecessary errors during execution means that a decision needs to be made by an implementation if a requested linetype is unavailable at a workstation. PHIGS implementations default all non-available linetypes to be the same as linetype 1.
The complete table of linetypes for PHIGS is given below:
|â‰¥5||subject to registration|
Examples of the linetypes are shown in Figure 3.3.
Figure 3.3: Linetypes in PHIGS
3.2.4 Linewidth scale factor
Due to the large variability of output devices, PHIGS has taken the decision that it is not feasible to precisely define the width of a line in the modelling coordinates that define the points of the polyline. One problem is that the aspect ratio may be changed which makes it difficult to decide which of the 3 dimensions should be used to specify width. Secondly, several instances of the same set of polylines may be required at different sizes but with the same line thickness. In consequence, line thickness is defined relative to some notional line thickness that is regarded as normal on the device. For a plotter, this is likely to be the line thickness produced by drawing with the standard pens. For a vector refresh display, it would be the standard intensity line. For a raster device, it will be the number of pixels that produce a clear line on the display.
Linewidth is specified relative to this nominal linewidth. The value of linewidth scale factor can be less than or greater than 1 and is a real number. For example, linewidth scale factor can be set to 0.5 of the nominal linewidth or 2.5 times the nominal linewidth. The device is expected to take the nominal linewidth and multiply by the linewidth scale factor and attempt to draw the lines as close to that width as possible. Figure 3.4 gives some examples of linewidths that might be available where the second from the bottom might be the nominal linewidth.
Figure 3.4: Linewidth scale factors
3.2.5 Colour index
The third aspect of a polyline is its colour. In PHIGS, colour is specified indirectly by defining a colour index that points to a colour description. The polyline colour index is the aspect that is associated with polyline output primitives.
Because colour is quite closely connected to the device that will display the output, the table containing the colour descriptions is stored on the workstation. The number of entries in the table will depend on the workstation. Entries 0 and I always exist. Entry 0 is defined as the background colour of the display and entry 1 is initially set to the default foreground colour of the display. Individual colours can be specified using a number of different colour models. These are described in Section 4.6.
Initially, the polyline colour index is set to 1 and this will be associated with each polyline output primitive generated on traversal.
As the contents of the workstation colour table may be different on different workstations, a polyline colour index value may produce different colours on different workstations depending on the entries in the workstation colour tables. For the same colour to appear on each workstation for a specified index value, the colour description associated with that polyline colour index value must be the same on each workstation. Even then it will require the workstations to have similar colour displays.
Other primitives have their own colour aspect. For example, polymarkers have a polymarker colour index aspect. As there is a single colour table on a workstation, if the polyline and polymarker colour index aspects are the same, the same colour will be produced on a workstation.
If a polyline colour index value is set to a value that is not available on a workstation, polyline colour index 1 will be used instead.
Section 3.2 has described the polyline output primitive in some detail together with the three polyline aspects linetype, linewidth scale factor and polyline colour index. Polyline output primitives have other aspects (for example, identification) but as they are the same for all output primitive classes, they will be described later. The three aspects described here are unique to the polyline. However, the third is quite similar to the colour index aspects of other primitive classes.
The following sections will describe the other output primitive classes. Where the similarity with the polyline is close, only a brief description will be given and the fuller details can be inferred by reading the polyline description.
3.3.1 The functions
Two functions are provided in PHIGS:
POLYMARKER 3(N, XA, YA, ZA) POLYMARKER(N, XA, Y A)
The parameters are the same as for the polyline and again define a sequence of points. POLYMARKER is a shorthand for POLYMARKER 3 (see Section 3.2.1). POLYMARKER 3 defines a set of N points to be identified by a marker. A marker is a symbol with a well-defined origin (not necessarily the centre). All N points are marked with the same symbol. As for the polyline, the coordinates of the points are defined in modelling coordinates.
Using the same data values defined in Section 3.2.1, the function:
POLYMARKER(5, XPL, YPL)
might, on traversal, generate the polymarker as in Figure 3.5.
Figure 3.5: A polymarker
3.3.2 Polymarker aspects
Polymarkers in PHIGS have three aspects that can control their appearance on a display and allow similar polymarkers to be differentiated. They are marker type, markersize scale factor and polymarker colour index.
The overall philosophy for defining the aspects is the same as for polyline aspects (see Section 3.2).
3.3.3 Marker type
The complete table of marker types for PHIGS is given below:
|â‰¥6||subject to registration|
Examples of the marker types are given in Figure 3.6. This output would be produced by five separate invocations of the polymarker function each defining a single point.
Figure 3.6: Marker types in PHIGS
Marker type 1 is the smallest available dot and may well be difficult to see without looking carefully. We have deliberately increased its size in Figure 3.6 so that it is visible! Registration and implementation dependent marker types are handled in the same way as linetypes (see Section 3.2.2).
3.3.4 Markersize scale factor
PHIGS does not treat marker size as a geometric value that is settable in modelling coordinates. Instead, it is assumed that the device has some notional size for markers. The aspect markersize scale factor defines the size of the marker relative to this notional size. Consequently, its definition is very similar to linewidth scale factor described in Section 3.2.4. Some examples of different values of markersize scale factor are given in Figure 3.7. These markers are 3, 5, 7, 9, and 11 times the nominal marker size for this device.
The scale factor can be less than 1. If the implementation has defined the notional marker size greater than the minimum that it can draw, the smaller size marker will be output. Because an implementation only has to approximate to the marker size (some devices may only be capable of drawing markers at certain sizes), the aspect should not be used when precise sizing is required. In this case. defining the glyph as a structure using polylines, fill area or fill area set is more appropriate.
Figure 3.7: Markersize scale factors
Again, the display in Figure 3.7 would require five separate polymarker function invocations. All the points in a single polymarker function invocation will have their type and size the same.
3.3.5 Polymarker colour index
This is defined in exactly the same way as polyline colour index (see Section 3.2.5).
3.4 FILL AREA AND FILL AREA SET
3.4.1 The functions
PHIGS provides four functions:
FILL AREA 3(N, XA, YA, ZA) FILL AREA(N, XA, Y A) FILL AREA SET 3(N, IA, XA, Y A, ZA) FILL AREA SET(N, IA, XA, YA)
There are two output primitives, fill area and fill area set, each having a shorthand form for the case on the Z=0 plane. Both define an area to be filled with some rendering or pattern. Fill area specifies a single boundary to be filled whereas fill area set specifies a set of boundaries. The major reason for including fill area is for compatibility with GKS. However, it is a simpler primitive to use. The two primitives share a set of aspects but fill area set has some additional ones that control the appearance of the boundary edges.
The parameters for fill area are similar to those for polyline and polymarker defining a sequence of points where the last point is normally the same as the first point. If that is not the case, an additional point is added to the sequence at the end which is the same as the first point. This ensures that the sequence of points always defines a closed boundary.
Whereas polyline and polymarker are true 3-dimensional primitives with no constraints on the points, this is not the case for fill area or fill area set. Both area primitives define boundaries which are in a single plane. If by accident, the application defines a fill area or fill area set where the points are not all in a single plane, the implementation is allowed to interpret it how it likes. For example, it could let the first few points define the plane and project all the other points onto that plane or it could be more sophisticated and attempt to make the best fit by reasoning which points are incorrect.
Figure 3.8: A fill area
If insufficient points are given to define a plane (less than 3), no error will occur but nothing will be visible on the display either. A simple example of fill area is:
DATA XFA/ 1, 3, 5, 7, 9, 1/ DATA YFA/ 1, 4.5, 4.5, 2, 1, 1/ FILL AREA(6, XFA, YFA)
On traversal, the fill area drawn might be as in Figure 3.8. The exact form will depend on the aspect settings defining the interior.
Fill area set has the points (XA(I),YA(I),ZA(I)) for the first area defined by the values 1=1 to IA(1). The second area is defined by the points from IA(1)+1 to IA(2) and so on until the last area is defined by the sequence of points from IA(N-1)+1 to IA(N). For example:
DATA XFAS /3, 6, 6, 3, 3, 2, 7, 7, 2, 2, 4, 5, 5, 4, 4/ DATA YFAS /23,23, 18, 18, 23, 16, 16, 9, 9, 16, 7, 7, 4, 4, 7/ DATA IA /5,10,15/ DO 10 I=1,5 XFAS(I)=0.333*XFAS(I) YFAS(I)=0.333*YFAS(I) 10 CONTINUE FILL AREA SET(3, IA, XFAS, YFAS)
Figure 3.9 shows, on the left, the three rectangles defined as a fill area set in the program above. The remaining parts of the diagram are described later. The reduction in size of the coordinates in the example is just to allow integer values to be used in the data declarations.
Figure 3.9: Fill area set example
3.4.2 Definition of interior
So far, the description has assumed that it is straightforward to decide what is inside the boundary and that is true when the boundary does not intersect itself. However, as soon as that is allowed, and it is in PHIGS, it is necessary to precisely define the inside and outside of the boundary as only the inside will be filled.
PHIGS defines the inside by a rule called the even-odd rule. Note that this is not the only rule that could be used and, for example, the X window system has two rules that can be used for specifying the inside.
The even-odd rule states that a point is inside the boundary if a line drawn from infinity to the point hits the boundary an odd number of times.
If the line happens to touch the boundary or intersects with the boundary at a point where it crosses itself, care must be taken to make sure the count remains correct. The best solution is to choose a line from infinity that only intersects with the boundary at straightforward positions!
Figure 3.10 shows a reentrant boundary and indicates which points are inside and outside.
Figure 3.10: Even-odd rule
Clearly the even-odd rule works equally well for the multiple boundaries of fill area set. For example, if fill area set defines two boundaries which are concentric circles, the inside is the portion between the two circles. The inside of the inner circle is outside the boundary!
If the three rectangles defined as a fill area set in Section 3.4.1 have the top rectangle moved downwards and the bottom rectangle moved upwards, the effect of the even-odd rule is shown by the area rendered as solid in the other pictures in Figure 3.9.
3.4.3 Area aspects
Fill area and fill area set have six common aspects that control the appearance of the interior of the boundary. The main aspect is interior style which defines the type of rendering required. The remaining aspects are appropriate for some subset of the styles.
The area can be rendered in basically three ways, a solid colour, a hatch style or a pattern. The interior colour index aspect is used by the first two to define the colour of the solid area or the hatch lines. As both hatching and patterning can be done in a variety of ways, an interior style index aspect indicates which style has been chosen. Hatch styles are implementation dependent and the interior style index does not mandate which style is associated with which index. Much more control is defined for patterns. The interior style index for patterns points to a pattern array of colour index values to be mapped onto the area to be filled. Thus it does not use the interior colour index value. The three aspects pattern size, pattern reference point and pattern vectors define the size and orientation of the pattern. These apply to all pattern styles but are not used by solid or hatch styles.
The interior colour index aspect and the entries in the pattern array are defined in the same way as the colour index values for polylines and polymarkers. Each workstation provides a colour description for each index value.
3.4.4 Interior style
The interior style aspect has the values HATCH and PATTERN to specify which filling is required. The hatching used is specified by the interior style index. Figure 3.11 gives some examples of possible hatch styles. None are mandated and the style available in an implementation for a specific interior style index is not defined. The user must therefore consult the reference manual for the PHIGS product he is using.
Figure 3.11: Hatch styles in PHIGS
The solid colour is specified by the interior style aspect having one of the values HOLLOW, SOLID or EMPTY. SOLID fills the interior with a uniform colour defined by the colour index value. HOLLOW is a quick and dirty rendering which just draws the outline of the fill area. It is provided as a quick debug aid. the way the boundary is represented is up to the workstation or implementation to define. There is no necessity for it to take account of, say, the polyline aspects like linetype. If the aspect is defined as EMPTY, no filling occurs and no boundary line is drawn. Its only use is if there is an HLHSR method (see Section 4.7.3) defined which allows the fill area to occlude parts of a picture behind this fill area.
The most complex fill area style is interior style PATTERN. In this case, the type of pattern is defined by the interior style index which points to an array of colour indices.
3.4.5 Pattern aspects
For interior style PATTERN, the interior style index, sometimes called the pattern index, is a pointer into a pattern table which defines the set of patterns available to render the area to be filled.
Figure 3.12: Pattern size and origin
The pattern is a 2-dimensional array of colour index values which define the repetitive pattern with which to render the area. Clearly, this does not completely define the form of the rendering as it is necessary to specify the origin from which the pattern is to start and the size of the pattern cells.
The size of the pattern is defined by:
SET PATIERN SIZE(PW, PH)
This specifies the size of the rectangle in modelling coordinates that is to be rendered with one complete pattern. As the modelling coordinates can be transformed on traversal, this can be a quadrilateral in normalized projection coordinates.
The 2D shorthand form for the definition of the origin is:
SET PATTERN REFERENCE POINT(PRPX, PRPY)
The pattern is assumed to be parallel to the X and Y-axes in modelling coordinates thus PRP is the origin of the pattern and (PW,PH) defines its size as shown in Figure 3.12. In 3 dimensions, it is necessary to define both the origin for the pattern and the directions of the X and Y axes in the pattern of the fill area. The function provided is:
SET PATTERN REFERENCE POINT AND VECTORS (PRPX, PRPY, PRPZ, PAX, PAY, PAZ)
The origin is defined by (PRPX, PRPY, PRPZ). The orientation of the pattern is determined by the two pattern reference vectors. The X-direction (width) is defined by the points (PRPX, PRPY, PRPZ) and (PRPX+PAX(1), PRPY+PAY(1), PRPZ+PAZ(1)). The Y-direction (height) by (PRPX, PRPY, PRPZ) and (PRPX+PAX(2), PRPY+PAY(2), PRPZ+PAZ(2)). The pattern width and height specified by SET PATTERN SIZE are measured along these directions. Mapping pixels on the display to a particular colour is defined as follows. If the centre of a pixel is within a pattern cell, the colour appropriate to that cell is used. An example of setting up a pattern is as follows:
DATA XFA /2, 8, 8, 2, 2/ DATA YFA /6, 6, 2, 2, 6/ DATA ZFA /O, 0, 0, 0, 0/ DATA PAX /1, O/ DATA PAY /0, 1 / DATA PAZ /O, O/ SET PATTERN SIZE(3, 2) SET PATTERN REFERENCE POINT AND VECTORS(3, 3, 0, PAX, PAY, PAZ) FILL AREA 3(5, XFA, YFA, ZFA)
Even if the same pattern is used, the same area can have significantly different rendering depending on the size of the pattern cell and how its origin relates to the area to be filled as can be seen in Figure 3.13.
The main problem in the definition occurs if the origin or vectors do not occur in the plane of the fill area or fill area set. In this case, the points are projected onto the fill area or fill area set plane along a normal to that plane. Again, this ensures that it is difficult in PHIGS to generate an error in the definition of the pattern.
Figure 3.13: Example pattern size and reference point
3.4.6 Edge aspects
The major difference between fill area and fill area set is that fill area set has aspects which define how the boundary of the fill area set is rendered. For fill area, no boundary is drawn unless fill area style HOLLOW is specified.
For fill area set, additional aspects provided are edge flag, edgetype, edgewidth scale factor and edge colour index. The edge flag can be set to ON and OFF. If set ON, the edge is rendered according to the other aspects. The meaning of these is similar to the meaning of the polyline aspects. Edgetype corresponds to linetype, edge width scale factor to linewidth scale factor and edge colour index to polyline colour index.
Edges are drawn on top of the interior. Conceptually, the two are disjoint. Thus, an edge drawn as a dashed line may be displayed with the boundary of a HOLLOW fill area being visible between dashes. If a fill area set is clipped with the edge flag set to ON, the new edges generated by the clipping will not be rendered. It is only those unclipped parts of the original boundary that will be rendered.
While it is quite easy to draw a polyline around a fill area by just one extra function invocation, it may require a series of polyline functions to do the same for fill area set. This is one of the reasons for adding the edge boundary to fill area set.
3.5.1 The functions
PHIGS provides two functions:
TEXT 3(PX, PY, PZ, TDXA, TDYA, TDZA, CHARS) TEXT (PX, PY, CHARS)
Each defines output consisting of a sequence of characters, specified by CHARS, located with reference to a point called the text position. The second function is a 2D shorthand form of the first where output is with reference to the text position (PX,PY,0) in the Z=0 plane. Depending on the attribute settings, the text position could be the start, centre or end of the text string and the text could be orientated at any angle. A simple example, producing Figure 3.14, is:
TEXT(l, 3, 'Example String')
Figure 3.14: Simple text example
The greater complexity of the TEXT 3 function is because, in 3D, it is necessary to specify the plane on which the characters are to be output. The text position (PX,PY,PZ) is a point in this plane. The direction vector (TDXA(1), TDYA(1), TDZA(1)) defines the positive X-axis and (TDXA(2), TDYA(2), TDZA(2)) defines the positive Y-axis in the plane. As it is possible to define direction vectors that are not quite perpendicular to each other, the PHIGS system assumes that the two direction vectors are used to define the plane through (PX,PY,PZ) Once this is established. the first direction vector defines the X-axis. The positive Y-axis is then defined as the axis in the plane perpendicular to the X-axis that is nearest in direction to the second direction vector. The size and orientation of text in this plane is defined using a Text Local Coordinate system with the same metric as modelling coordinates. CHARS defines the string of characters to be output. An example of output from TEXT 3 would be:
TDXA(1)=COS(0.3*PI) TDYA(l)=0 TDZA(1)=-SIN(0.3*PI) TDXA(2)=0 TDYA(2)=1 TDZA(2)=O TEXT 3(X, Y, Z, TDXA, TDYA, TDZA, 'String')
which, on traversal, would produce the output shown in Figure 3.15 if viewed in perspective slightly from above.
Figure 3.15: Example of TEXT 3
If the second direction vector had TDYA(2) set to -1, the Y-axis would have been in the opposite direction and the output would have been inverted as shown in Figure 3.16.
3.5.2 Text aspects
Text is the most complex of the output primitives in PHIGS with nine aspects to control the appearance on the display. Five aspects, character height, character expansion factor, character spacing, text path and text font define a text extent rectangle that encloses the character string in the text plane. The coordinates of the text extent rectangle are defined in the text local coordinate system. The aspect character up vector specifies the orientation of this text extent rectangle relative to the text local coordinate system axes. The aspect text alignment positions the text extent rectangle relative to the text position. Finally, text colour index defines the colour in the same way as polyline colour index (see Section 3.2.5). The text precision aspect allows some of the above aspects to be ignored.
Figure 3.16: Inverted text by changing Y axis direction
The text extent rectangle in the text plane will be transformed by any modelling transformations defined during traversal and will be clipped as required. In consequence, the most general case will be that the text extent rectangle is transformed to a parallelogram by the modelling transformation. This may result in the text being sheared.
3.5.3 Font specification
Any PHIGS implementation will provide the user with a number of differentiable character fonts. The font designer specifies the shape of each character relative to some local 2D coordinate system. Fonts can either be monospaced (all characters have the same width) or proportional (width depends on the character form). The font designer must specify a number of positions for each character in the font as shown in Figure 3.17.
The height of a character is defined as the distance from the base line to the cap line. The width of a character is defined as the distance from the left line to the right line. Normally, the font will be defined such that characters abutted together will have sufficient space between them for comfortable reading. Thus the width is usually greater than the width of the character form itself.
Figure 3.17: Character definition within a font
The text font aspect is a number which specifies the font to be used on a workstation to draw the characters. Fonts numbered 1 and 2 have to be provided. Fonts numbered greater than 2 are subject to the Registration scheme. An implementation can define any number of fonts using zero or negative numbers that are local to the implementation. Implementations frequently have a large number of fonts available (40 or more) so it is a point to look at when choosing an implementation. Font number 1 has to be a monospaced font and font number 2 must be differentiable from it. Both must define the characters in the ISO 646 standard. The requirements for both fonts 1 and 2 to be available was a late addition to the standard and earlier implementations of PHIGS sometimes do not comply with this requirement.
3.5.4 Defining the text extent rectangle
The TEXT or TEXT 3 function defines the sequence of characters to be output on the display. The text font aspect defines the font to be used. Different fonts define the relative widths of characters differently so it is necessary to define the text font to be used in order to identify the precise character bodies of the characters in the text string to be displayed.
The character height aspect defines the height of the character bodies to be displayed. The character body in the font description is expanded equally in both the X and Y directions until the specified character height is obtained.
The character expansion factor aspect provides additional expansion in the X-direction. If a value of 2.0 is specified, the width of the character body is doubled while leaving the height the same. Examples of different character expansions are given in Figure 3.18.
Figure 3.18: Character expansion factor
The character spacing aspect specifies how much additional spacing is required between two adjacent character bodies. A positive value will insert additional spacing as a fraction of the character height. A negative value of character spacing will cause the adjacent character bodies to overlap. Whether the spacing is applied in the top-bottom or left-right direction of the characters depends on the setting of the text path aspect. Examples of different character spacing are given in Figure 3.19.
Figure 3.19: Character spacing
If the text path aspect is set to RIGHT, the second character body in the sequence of characters to be displayed is placed to the right of the first character body with the additional spacing in between if defined. The third character is placed to the right of the second and so on. If the text path aspect is set to LEFT, the second character body is placed to the left of the first character body and so on. In both cases, the height of the text extent rectangle is defined by the character height and extends from the top line to the bottom line. The width of the text extent rectangle extends from the left line of the left-most character to the right line of the right-most character.
If the text path aspect is set to DOWN, the second character body is placed below the first character with the additional spacing, if defined, in between. The third character body is placed below the second and so on. If the text path aspect is set to UP, the second character body is placed above the first character body and so on. In both cases, the height of the text extent rectangle is from the top-line of the top-most character to the bottom-line of the bottom-most character. The width is the same as the width of the widest character to be displayed.
As the fonts are defined separately on each workstation, the size of the text extent rectangle can be different on each workstation. This clearly causes problems if the application, say, is trying to surround the text with a rectangle drawn as a polyline. To ensure that this is possible, PHIGS insists that font number 1 is a monospaced font and that the aspect ratio for all the characters is the same for every workstation in the implementation. Consequently, if font number 1 is used, the rectangle around the text will appear the same on every workstation. If any other font is used, there is no guarantee, say, that the output on the display is the same as the output on an associated plotter which could have a different set of fonts defined.
The character up vector aspect defines the orientation of the text extent rectangle (and the enclosed text) to the local text coordinate system in the plane by specifying the direction of the rectangle's height with respect to the local text coordinate system. For example, if the character up vector is set to (0,1), the vector is along the Y-axis of the local text coordinate system and so the text extent rectangle is aligned with the axes of the local text coordinate system. If the character up vector is set to (1,0), the up direction is along the X-axis of the local text coordinate system so the text extent rectangle is rotated by 90Â° clockwise.
It should be remembered that just by setting the character up vector aspect to (0,1) does not guarantee that the text will be in its normal orientation. The text plane defined may be at an angle to the horizontal and a modelling transformation applied at traversal may also rotate the text.
The text primitive defines the text position. The text alignment aspect defines the position in the text extent rectangle that coincides with the text position. The alignment is relative to the coordinate system of the text extent rectangle, that is the Y -direction is the direction of the character up vector.
The text alignment aspect has a pair of values that control the positioning in the X and Y-directions. The X-component has four possible values, LEFT, CENTRE, RIGHT and NORMAL. The Y-component has six possible values, TOP, CAP, HALF, BASE, BOTTOM and NORMAL.
Figure 3.20: Horizontal text alignment
If the X-component has value LEFT, the left side of the text extent rectangle coincides with the text position. For RIGHT, the right side of the text extent rectangle coincides with the text position while for CENTRE the text position lies midway between the left and right sides of the text extent rectangle. Examples of alignment horizontally are given in Figure 3.20.
Figure 3.21: Vertical text alignment
If the Y -component has value TOP, the top of the text extent rectangle coincides with the text position and similarly if it has value BOTTOM, the bottom of the text extent rectangle coincides with the text position. The values CAP, HALF and BASE are really only useful for text defined with text path LEFT or RIGHT. However, they are defined in such a way that they are also well defined for text path UP and DOWN. If CAP is defined, the text position coincides with the cap-line of the top-most character (for LEFT and RIGHT paths this is all the characters). If BASE is defined, the text position coincides with the base-line of the bottom-most character. If HALF is defined, the text position coincides with the line half way between the half-lines of the top and bottom-most characters. In consequence, for text defined with text path set to LEFT or RIGHT, CAP, HALF, and BASE have their obvious meanings. Examples of vertical alignment are given in Figure 3.21. The NORMAL X and Y-alignment values define the most appropriate text alignment depending on the text path defined. The table below gives the values of NORMAL for the possible text paths.
Figure 3.22: Several text aspects specified together
Figure 3.22 shows an example where several text aspects have been set together. Figure 3.23 shows the effect of a modelling transformation which does an expansion in the X-direction and a contraction in the Y-direction on a text primitive when the character up vector is set to (-1,1). Note that this can distort the character forms even in 2D. It also places quite a demand on the workstation which has to render the text primitive on the display.
Figure 3.23: Effect of modelling transformation on text
Figure 3.24: Different text paths and aspects
Figure 3.24 shows the same text string Wife output with text position set to the four corners of a central square with the letter W at the corners. The character up vector aspect is set to (-1,1) throughout. The top left text string is defined with text path set to UP. The top right is with text path set to RIGHT and character spacing set to 2.0. The bottom right has the text path set to DOWN and character expansion set to 3.0 while the bottom left has the text path set to LEFT, the character height double the others and a different font selected.
3.5.7 Text precision
It is possible that a workstation will have difficulty in reproducing all the text aspects described above. For example, hardware fonts on workstations very rarely allow character shearing. On some simple workstations, it is only possible to output text horizontally.
The text precision aspect in conjunction with the text font aspect specifies how closely the workstation can represent the text output. If the text precision aspect is set to STROKE, the workstation is expected to use all the aspects correctly. In some cases, this may mean that the characters have to be output by software line drawing or area filling.
If the text precision aspect is set to CHAR, the text extent rectangle and the individual character bodies are calculated precisely. However, the individual characters may not be precisely defined within the character body. For example, the correct character height may be used for the character but the character will be vertical irrespective of the value of the character up vector. If the text precision is set to STRING, a text string of approximately the right height and width is output but its alignment, orientation and path direction may be incorrect. This quick and dirty text can be used in debugging when the STROKE precision text is expensive to produce. STRING precision text is frequently used for error messages and operator prompts that do not fom1 a major part of the graphical output and where precision is less necessary as long as it is readable.
Every workstation must support at least two STROKE precision fonts (numbers I and 2). It is also assumed that CHAR and STRING precision is available for these fonts (not difficult as drawing at STROKE precision is an allowable definition). For other fonts, there is no guarantee that all precisions are supported. If a requested font is not available, text font I will be used at STRING precision.