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

NAME

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

SYNTAX

11       Font XLoadFont(Display *display, _Xconst char *name);
12
13       XFontStruct *XQueryFont(Display *display, XID font_ID);
14
15       XFontStruct *XLoadQueryFont(Display *display, _Xconst 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 used  in
49       a  font  name,  a  pattern  match is performed and any matching font is
50       used.  In the pattern, the “?” character will match any single  charac‐
51       ter,  and  the  “*”  character  will match any number of characters.  A
52       structured format for font names is specified in the X Consortium stan‐
53       dard  X  Logical Font Description Conventions.  If XLoadFont was unsuc‐
54       cessful at loading the specified font, a BadName error results.   Fonts
55       are not associated with a particular screen and can be stored as a com‐
56       ponent of any GC.  When the font is no longer needed, call XUnloadFont.
57
58       XLoadFont can generate BadAlloc and BadName errors.
59
60       The XQueryFont function returns a pointer to the XFontStruct structure,
61       which  contains  information associated with the font.  You can query a
62       font or the font stored in a GC.  The font ID stored in the XFontStruct
63       structure  will be the GContext ID, and you need to be careful when us‐
64       ing this ID in other functions (see XGContextFromGC).  If the font does
65       not  exist,  XQueryFont  returns  NULL.   To free this data, use XFree‐
66       FontInfo.
67
68       XLoadQueryFont can generate a BadAlloc error.
69
70       The XLoadQueryFont function provides the most common way for  accessing
71       a  font.   XLoadQueryFont both opens (loads) the specified font and re‐
72       turns a pointer to the appropriate XFontStruct structure.  If the  font
73       name  is not in the Host Portable Character Encoding, the result is im‐
74       plementation-dependent.  If the font does not exist, XLoadQueryFont re‐
75       turns NULL.
76
77       The  XFreeFont  function  deletes  the association between the font re‐
78       source ID and the specified font and frees the  XFontStruct  structure.
79       The  font  itself  will  be freed when no other resource references it.
80       The data and the font should not be referenced again.
81
82       XFreeFont can generate a BadFont error.
83
84       Given the atom for that property, the XGetFontProperty function returns
85       the  value  of  the specified font property.  XGetFontProperty also re‐
86       turns False if the property was not defined or True if it was  defined.
87       A  set  of  predefined  atoms  exists for font properties, which can be
88       found in X11/Xatom.h.  This set contains the standard properties  asso‐
89       ciated  with  a font.  Although it is not guaranteed, it is likely that
90       the predefined font properties will be present.
91
92       The XUnloadFont function deletes the association between the  font  re‐
93       source  ID  and the specified font.  The font itself will be freed when
94       no other resource references it.  The font  should  not  be  referenced
95       again.
96
97       XUnloadFont can generate a BadFont error.
98

STRUCTURES

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

DIAGNOSTICS

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

SEE ALSO

264       XCreateGC(3), XListFonts(3), XSetFontPath(3)
265       Xlib - C Language X Interface
266
267
268
269X Version 11                    libX11 1.7.3.1                    XLoadFont(3)
Impressum