next up previous contents index
Next: Creating XPM-Files from t1lib-Glyphs Up: The X11-Interface Previous: Initialization of the X11-Interface   Contents   Index

Rastering Functions

In analogy to the standard rastering functions the t1lib X11 interface provides six functions for generating character and string bitmaps, rectangles as well as their antialiased equivalents:

 GLYPH *T1_SetCharX( Drawable d, GC gc, int mode, int x, int y,
                     int FontID, char charcode,
                     float size, T1_TMATRIX *transform)

to 0pt

 GLYPH *T1_SetStringX( Drawable d, GC gc, int mode, int x, int y,
                       int FontID, char *string, int len,
                       long spaceoff, int modflag,
                       float size, T1_TMATRIX *transform)

to 0pt

 GLYPH *T1_SetRectX( Drawable d, GC gc, int mode, int x_dest, int y_dest,
                     int FontID, float size,
                     float width, float height,
                     T1_TMATRIX *transform)

to 0pt

 GLYPH *T1_AASetCharX( Drawable d, GC gc, int mode, int x, int y,
                       int FontID, char charcode,
                       float size, T1_TMATRIX *transform)

to 0pt

 GLYPH *T1_AASetStringX( Drawable d, GC gc, int mode, int x, int y,
                         int FontID, char *string, int len,
                         long spaceoff, int modflag,
                         float size, T1_TMATRIX *transform)

to 0pt

 GLYPH *T1_AASetRectX( Drawable d, GC gc, int mode, int x_dest, int y_dest,
                       int FontID, float size,
                       float width, float height,
                       T1_TMATRIX *transform)

to 0pt

Instead of explaining everything in detail, we will discuss only those items that are different from the standard rastering. For discussion of the parameters FontID, charcode, string, len, spaceoff, modflag, size and transform see [*].

The drawable parameter specifies the X11 drawable into which the text will be drawn. It may be either a pixmap or a window.

gc is the graphics context in which the operation should take place. Obviously, the most importamt components of the graphics context are the current foreground and background color. t1lib uses these colors to draw the text/background.

The value of mode determines whether opaque or transparent mode is used. In opaque mode all pixels including background pixels are drawn. This means the whole area of the bounding box of the character/string is painted. In transparent mode, only non-background pixels are drawn so that underlying graphics are minimum affected. One could imagine that as drawing the text on a transparent slide and overlay the result with the existent graphics. Using transparent mode should be somewhat slower, especially for the antialiasing functions since the information which pixels are background and which not has to be generated first. Moreover, the clipmask of the current graphics context is modified when drawing text in transparent mode.

x and y define the position coordinates where the origin of the text will be located in the drawable. t1lib does no checking of this position so that bad positioned text might not appear at all in the drawable without getting an error--it is simply clipped to the limits of the drawable.

The non-antialiasing functions will take the fore- and background color from the specified graphics context. The antialiasing rastering functions work a little different. They also respect the current foreground and background color. The ``graylevel'' colors are computed on the fly and allocated in the colormap specified by the user in the call to T1_SetX11Params(). The term graylevel has been quoted since these are in fact no graylevels at all. They are just discrete colors from a smooth bleed between the foreground and the background color. The colors are computed the following according to the following scheme:

  1. The current foreground and background color are split into their respective RGB components, lets call them , , , , and .
  2. Intermediate values are computed between each pair of color components -, - and - by making a linear interpolation.
  3. For each newly created RGB-triple (currently 3) a pixel color is allocated in the colormap specified by the user in a way that the pixel colors match the theoretical values best.

A general comment on antialiasing: If using transparent mode antialiasing may produce the opposite effect of what is wanted, depending on the color of the underlying graphics. You can use the program xglyph to check the effect: Start xglyph and prior to doing anything else click on button . The resulting glyph is antialiased against the background color white but the real background due to transparency is quite different from white. Consequently the glyph seems to be surrounded by a thin light gray border.


next up previous contents index
Next: Creating XPM-Files from t1lib-Glyphs Up: The X11-Interface Previous: Initialization of the X11-Interface   Contents   Index
2005-01-12