Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

NAME

XDrawText — draw 8-bit polytext strings. 

SYNOPSIS

XDrawText(display, drawable, gc, x, y, items, nitems) Display ∗display;  Drawable drawable;  GC gc;  int x, y;  XTextItem ∗items;  int nitems;

ARGUMENTS

displaySpecifies a connection to an X server; returned from XOpenDisplay(). 

drawableSpecifies the drawable. 

gcSpecifies the graphics context. 

x

ySpecify the x and y coordinates of the baseline starting position for the initial string, relative to the origin of the specified drawable. 

itemsSpecifies a pointer to an array of text items. 

nitemsSpecifies the number of text items in the items array. 

DESCRIPTION

XDrawText() is capable of drawing multiple strings on the same horizontal line and changing fonts between strings.  Each XTextItem structure contains a string, the number of characters in the string, the delta offset from the starting position for the string, and the font.  Each text item is processed in turn.  The font in each XTextItem is stored in the specified GC and used for subsequent text.  If the XTextItem.font is None, the font in the GC is used for drawing and is not changed.  Switching between fonts with different drawing directions is permitted. 

The delta in each XTextItem specifies the change in horizontal position before the string is drawn.  The delta is always added to the character origin and is not dependent on the draw direction of the font.  For example, if x = 40, y = 20, and items[0].delta = 8, the string specified by items[0].chars would be drawn starting at x = 48, y = 20.  The delta for the second string begins at the rbearing of the last character in the first string.  A negative delta would tend to overlay subsequent strings on the end of the previous string. 

Only the pixels selected in the font are drawn (the background member of the GC is not used to fill the bounding box). 

In all X releases, there is a limit to the number and size of strings that can be drawn in a single XDrawText() call, that varies according to the server.  To determine how much text you can draw in a single call, you find out your server’s maximum request size using XMaxRequestSize().  Subtract four, and then subtract ((strlen(string) + 2) / 4) for each string.  This is the maximum amount of text you can draw in a single XDrawText() call. 

XDrawText() uses the following elements in the specified GC: function, plane_mask, fill_style, font, subwindow_mode, clip_x_origin, clip_y_origin, and clip_mask.  This function also uses these graphics context mode-dependent components:  foreground, background, tile, stipple, ts_x_origin, and ts_y_origin. 

For more information, see Volume One, Chapter 6, Drawing Graphics and Text, and Chapter 5, The Graphics Context. 

STRUCTURES

typedef struct {
    char ∗chars;    /∗ pointer to string ∗/
    int nchars;     /∗ number of characters ∗/
    int delta;      /∗ delta between strings ∗/
    Font font;      /∗ font to print it in, None don’t change ∗/ } XTextItem;

ERRORS

BadDrawable
BadFont
BadGC
BadMatch

SEE ALSO

XDrawImageString(), XDrawImageString16(), XDrawString(), XDrawString16(), XDrawText16(), XQueryTextExtents(), XQueryTextExtents16(), XTextExtents(), XTextExtents16(), XTextWidth(), XTextWidth16(). 

Xlib Reference Manual

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026