1XLoadFont(3X11) XLIB FUNCTIONS XLoadFont(3X11)
2
3
4
6 XLoadFont, XQueryFont, XLoadQueryFont, XFreeFont, XGetFontProperty,
7 XUnloadFont, XCharStruct, XFontProp, XChar2b, XFontStruct - load or
8 unload fonts and font metric structures
9
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
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
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
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
181 where:
182
183 D = max_char_or_byte2 - min_char_or_byte2 + 1
184 / = integer division
185 \ = integer modulus
186
187 · If the per_char pointer is NULL, all glyphs between the first and
188 last character indexes inclusive have the same information, as
189 given by both min_bounds and max_bounds.
190
191 · If all_chars_exist is True, all characters in the per_char array
192 have nonzero bounding boxes.
193
194 · The default_char member specifies the character that will be used
195 when an undefined or nonexistent character is printed. The
196 default_char is a 16-bit character (not a 2-byte character). For
197 a font using 2-byte matrix format, the default_char has byte1 in
198 the most-significant byte and byte2 in the least significant byte.
199 If the default_char itself specifies an undefined or nonexistent
200 character, no printing is performed for an undefined or nonexis‐
201 tent character.
202
203 · The min_bounds and max_bounds members contain the most extreme
204 values of each individual XCharStruct component over all elements
205 of this array (and ignore nonexistent characters). The bounding
206 box of the font (the smallest rectangle enclosing the shape
207 obtained by superimposing all of the characters at the same origin
208 [x,y]) has its upper-left coordinate at:
209 [x + min_bounds.lbearing, y - max_bounds.ascent]
210
211 Its width is:
212 max_bounds.rbearing - min_bounds.lbearing
213
214 Its height is:
215 max_bounds.ascent + max_bounds.descent
216
217 · The ascent member is the logical extent of the font above the
218 baseline that is used for determining line spacing. Specific
219 characters may extend beyond this.
220
221 · The descent member is the logical extent of the font at or below
222 the baseline that is used for determining line spacing. Specific
223 characters may extend beyond this.
224
225 · If the baseline is at Y-coordinate y, the logical extent of the
226 font is inclusive between the Y-coordinate values (y -
227 font.ascent) and (y + font.descent - 1). Typically, the minimum
228 interline spacing between rows of text is given by ascent +
229 descent.
230
231 For a character origin at [x,y], the bounding box of a character (that
232 is, the smallest rectangle that encloses the character's shape)
233 described in terms of XCharStruct components is a rectangle with its
234 upper-left corner at:
235
236 [x + lbearing, y - ascent]
237
238 Its width is:
239
240 rbearing - lbearing
241
242 Its height is:
243
244 ascent + descent
245
246 The origin for the next character is defined to be:
247
248 [x + width, y]
249
250 The lbearing member defines the extent of the left edge of the charac‐
251 ter ink from the origin. The rbearing member defines the extent of the
252 right edge of the character ink from the origin. The ascent member
253 defines the extent of the top edge of the character ink from the ori‐
254 gin. The descent member defines the extent of the bottom edge of the
255 character ink from the origin. The width member defines the logical
256 width of the character.
257
259 BadAlloc The server failed to allocate the requested resource or
260 server memory.
261
262 BadFont A value for a Font or GContext argument does not name a
263 defined Font.
264
265 BadName A font or color of the specified name does not exist.
266
268 XCreateGC(3X11), XListFonts(3X11), XSetFontPath(3X11)
269 Xlib - C Language X Interface
270
271
272
273X Version 11 libX11 1.0.3 XLoadFont(3X11)