1XLoadFont(3)                    XLIB FUNCTIONS                    XLoadFont(3)
2
3
4

NAME

6       XLoadFont, XQueryFont, XLoadQueryFont, XFreeFont, XGetFontProperty,
7       XUnloadFont, XCharStruct, XFontProp, XChar2b, XFontStruct - load or
8       unload fonts and font metric structures
9

SYNTAX

11       Font XLoadFont(Display *display, char *name);
12
13       XFontStruct *XQueryFont(Display *display, XID font_ID);
14
15       XFontStruct *XLoadQueryFont(Display *display, char *name);
16
17       int XFreeFont(Display *display, XFontStruct *font_struct);
18
19       Bool XGetFontProperty(XFontStruct *font_struct, Atom atom, unsigned
20              long *value_return);
21
22       int XUnloadFont(Display *display, Font font);
23

ARGUMENTS

25       atom      Specifies the atom for the property name you want returned.
26
27       display   Specifies the connection to the X server.
28
29       font      Specifies the font.
30
31       font_ID   Specifies the font ID or the GContext ID.
32
33       font_struct
34                 Specifies the storage associated with the font.
35
36       gc        Specifies the GC.
37
38       name      Specifies the name of the font, which is a null-terminated
39                 string.
40
41       value_return
42                 Returns the value of the font property.
43

DESCRIPTION

45       The XLoadFont function loads the specified font and returns its associ‐
46       ated font ID.  If the font name is not in the Host Portable Character
47       Encoding, the result is implementation-dependent.  Use of uppercase or
48       lowercase does not matter.  When the characters ``?'' and ``*'' are
49       used in a font name, a pattern match is performed and any matching font
50       is used.  In the pattern, the ``?'' character will match any single
51       character, and the ``*'' character will match any number of characters.
52       A structured format for font names is specified in the X Consortium
53       standard X Logical Font Description Conventions.  If XLoadFont was
54       unsuccessful at loading the specified font, a BadName error results.
55       Fonts are not associated with a particular screen and can be stored as
56       a component of any GC.  When the font is no longer needed, call XUn‐
57       loadFont.
58
59       XLoadFont can generate BadAlloc and BadName errors.
60
61       The XQueryFont function returns a pointer to the XFontStruct structure,
62       which contains information associated with the font.  You can query a
63       font or the font stored in a GC.  The font ID stored in the XFontStruct
64       structure will be the GContext ID, and you need to be careful when
65       using this ID in other functions (see XGContextFromGC).  If the font
66       does not exist, XQueryFont returns NULL.  To free this data, use XFree‐
67       FontInfo.
68
69       XLoadQueryFont can generate a BadAlloc error.
70
71       The XLoadQueryFont function provides the most common way for accessing
72       a font.  XLoadQueryFont both opens (loads) the specified font and
73       returns a pointer to the appropriate XFontStruct structure.  If the
74       font name is not in the Host Portable Character Encoding, the result is
75       implementation-dependent.  If the font does not exist, XLoadQueryFont
76       returns NULL.
77
78       The XFreeFont function deletes the association between the font
79       resource ID and the specified font and frees the XFontStruct structure.
80       The font itself will be freed when no other resource references it.
81       The data and the font should not be referenced again.
82
83       XFreeFont can generate a BadFont error.
84
85       Given the atom for that property, the XGetFontProperty function returns
86       the value of the specified font property.  XGetFontProperty also
87       returns False if the property was not defined or True if it was
88       defined.  A set of predefined atoms exists for font properties, which
89       can be found in <X11/Xatom.h>.  This set contains the standard proper‐
90       ties associated with a font.  Although it is not guaranteed, it is
91       likely that the predefined font properties will be present.
92
93       The XUnloadFont function deletes the association between the font
94       resource ID and the specified font.  The font itself will be freed when
95       no other resource references it.  The font should not be referenced
96       again.
97
98       XUnloadFont can generate a BadFont error.
99

STRUCTURES

101       The XFontStruct structure contains all of the information for the font
102       and consists of the font-specific information as well as a pointer to
103       an array of XCharStruct structures for the characters contained in the
104       font.  The XFontStruct, XFontProp, and XCharStruct structures contain:
105
106       typedef struct {
107            short lbearing;     /* origin to left edge of raster */
108            short rbearing;     /* origin to right edge of raster */
109            short width;   /* advance to next char's origin */
110            short ascent;  /* baseline to top edge of raster */
111            short descent; /* baseline to bottom edge of raster */
112            unsigned short attributes;    /* per char flags (not predefined) */
113       } XCharStruct;
114
115       typedef struct {
116            Atom name;
117            unsigned long card32;
118       } XFontProp;
119
120       typedef struct {    /* normal 16 bit characters are two bytes */
121           unsigned char byte1;
122           unsigned char byte2;
123       } XChar2b;
124
125       typedef struct {
126            XExtData *ext_data; /* hook for extension to hang data */
127            Font fid; /* Font id for this font */
128            unsigned direction; /* hint about the direction font is painted */
129            unsigned min_char_or_byte2;   /* first character */
130            unsigned max_char_or_byte2;   /* last character */
131            unsigned min_byte1; /* first row that exists */
132            unsigned max_byte1; /* last row that exists */
133            Bool all_chars_exist;    /* flag if all characters have nonzero size */
134            unsigned default_char;   /* char to print for undefined character */
135            int n_properties;   /* how many properties there are */
136            XFontProp *properties;   /* pointer to array of additional properties */
137            XCharStruct min_bounds;  /* minimum bounds over all existing char */
138            XCharStruct max_bounds;  /* maximum bounds over all existing char */
139            XCharStruct *per_char;   /* first_char to last_char information */
140            int ascent;    /* logical extent above baseline for spacing */
141            int descent;   /* logical decent below baseline for spacing */
142       } XFontStruct;
143
144       X supports single byte/character, two bytes/character matrix, and
145       16-bit character text operations.  Note that any of these forms can be
146       used with a font, but a single byte/character text request can only
147       specify a single byte (that is, the first row of a 2-byte font).  You
148       should view 2-byte fonts as a two-dimensional matrix of defined charac‐
149       ters: byte1 specifies the range of defined rows and byte2 defines the
150       range of defined columns of the font.  Single byte/character fonts have
151       one row defined, and the byte2 range specified in the structure defines
152       a range of characters.
153
154       The bounding box of a character is defined by the XCharStruct of that
155       character.  When characters are absent from a font, the default_char is
156       used.  When fonts have all characters of the same size, only the infor‐
157       mation in the XFontStruct min and max bounds are used.
158
159       The members of the XFontStruct have the following semantics:
160
161       ·    The direction member can be either FontLeftToRight or FontRight‐
162            ToLeft.  It is just a hint as to whether most XCharStruct elements
163            have a positive (FontLeftToRight) or a negative (FontRightToLeft)
164            character width metric.  The core protocol defines no support for
165            vertical text.
166
167       ·    If the min_byte1 and max_byte1 members are both zero,
168            min_char_or_byte2 specifies the linear character index correspond‐
169            ing to the first element of the per_char array, and
170            max_char_or_byte2 specifies the linear character index of the last
171            element.
172
173            If either min_byte1 or max_byte1 are nonzero, both
174            min_char_or_byte2 and max_char_or_byte2 are less than 256, and the
175            2-byte character index values corresponding to the per_char array
176            element N (counting from 0) are:
177
178                 byte1 = N/D + min_byte1
179                 byte2 = N\D + min_char_or_byte2
180            where:
181                    D = max_char_or_byte2 - min_char_or_byte2 + 1
182                    / = integer division
183                    \\ = integer modulus
184
185       ·    If the per_char pointer is NULL, all glyphs between the first and
186            last character indexes inclusive have the same information, as
187            given by both min_bounds and max_bounds.
188
189       ·    If all_chars_exist is True, all characters in the per_char array
190            have nonzero bounding boxes.
191
192       ·    The default_char member specifies the character that will be used
193            when an undefined or nonexistent character is printed.  The
194            default_char is a 16-bit character (not a 2-byte character).  For
195            a font using 2-byte matrix format, the default_char has byte1 in
196            the most-significant byte and byte2 in the least significant byte.
197            If the default_char itself specifies an undefined or nonexistent
198            character, no printing is performed for an undefined or nonexis‐
199            tent character.
200
201       ·    The min_bounds and max_bounds members contain the most extreme
202            values of each individual XCharStruct component over all elements
203            of this array (and ignore nonexistent characters).  The bounding
204            box of the font (the smallest rectangle enclosing the shape
205            obtained by superimposing all of the characters at the same origin
206            [x,y]) has its upper-left coordinate at:
207                 [x + min_bounds.lbearing, y - max_bounds.ascent]
208
209            Its width is:
210                 max_bounds.rbearing - min_bounds.lbearing
211
212            Its height is:
213                 max_bounds.ascent + max_bounds.descent
214
215       ·    The ascent member is the logical extent of the font above the
216            baseline that is used for determining line spacing.  Specific
217            characters may extend beyond this.
218
219       ·    The descent member is the logical extent of the font at or below
220            the baseline that is used for determining line spacing.  Specific
221            characters may extend beyond this.
222
223       ·    If the baseline is at Y-coordinate y, the logical extent of the
224            font is inclusive between the Y-coordinate values (y -
225            font.ascent) and (y + font.descent - 1).  Typically, the minimum
226            interline spacing between rows of text is given by ascent +
227            descent.
228
229       For a character origin at [x,y], the bounding box of a character (that
230       is, the smallest rectangle that encloses the character's shape)
231       described in terms of XCharStruct components is a rectangle with its
232       upper-left corner at:
233
234       [x + lbearing, y - ascent]
235
236       Its width is:
237
238       rbearing - lbearing
239
240       Its height is:
241
242       ascent + descent
243
244       The origin for the next character is defined to be:
245
246       [x + width, y]
247
248       The lbearing member defines the extent of the left edge of the charac‐
249       ter ink from the origin.  The rbearing member defines the extent of the
250       right edge of the character ink from the origin.  The ascent member
251       defines the extent of the top edge of the character ink from the ori‐
252       gin.  The descent member defines the extent of the bottom edge of the
253       character ink from the origin.  The width member defines the logical
254       width of the character.
255

DIAGNOSTICS

257       BadAlloc  The server failed to allocate the requested resource or
258                 server memory.
259
260       BadFont   A value for a Font or GContext argument does not name a
261                 defined Font.
262
263       BadName   A font or color of the specified name does not exist.
264

SEE ALSO

266       XCreateGC(3), XListFonts(3), XSetFontPath(3)
267       Xlib - C Language X Interface
268
269
270
271X Version 11                     libX11 1.6.7                     XLoadFont(3)
Impressum