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, _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
64       using this ID in other functions (see XGContextFromGC).   If  the  font
65       does 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
72       returns a pointer to the appropriate  XFontStruct  structure.   If  the
73       font name is not in the Host Portable Character Encoding, the result is
74       implementation-dependent.  If the font does not  exist,  XLoadQueryFont
75       returns NULL.
76
77       The  XFreeFont  function  deletes  the  association  between  the  font
78       resource 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
86       returns False if the property  was  not  defined  or  True  if  it  was
87       defined.   A  set of predefined atoms exists for font properties, which
88       can be found in This set contains the  standard  properties  associated
89       with a font.  Although it is not guaranteed, it is likely that the pre‐
90       defined font properties will be present.
91
92       The XUnloadFont function  deletes  the  association  between  the  font
93       resource 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  or a negative character width metric.  The core
163            protocol defines no support for vertical text.
164
165       ·    If  the  min_byte1  and   max_byte1   members   are   both   zero,
166            min_char_or_byte2 specifies the linear character index correspond‐
167            ing  to  the  first   element   of   the   per_char   array,   and
168            max_char_or_byte2 specifies the linear character index of the last
169            element.
170
171            If   either   min_byte1   or   max_byte1   are    nonzero,    both
172            min_char_or_byte2 and max_char_or_byte2 are less than 256, and the
173            2-byte character index values corresponding to the per_char  array
174            element N (counting from 0) are:
175
176                 byte1 = N/D + min_byte1
177                 byte2 = N\D + min_char_or_byte2
178            where:
179                    D = max_char_or_byte2 - min_char_or_byte2 + 1
180                    / = integer division
181                    \\ = integer modulus
182
183       ·    If  the per_char pointer is NULL, all glyphs between the first and
184            last character indexes inclusive have  the  same  information,  as
185            given by both min_bounds and max_bounds.
186
187       ·    If  all_chars_exist  is True, all characters in the per_char array
188            have nonzero bounding boxes.
189
190       ·    The default_char member specifies the character that will be  used
191            when  an  undefined  or  nonexistent  character  is  printed.  The
192            default_char is a 16-bit character (not a 2-byte character).   For
193            a  font  using 2-byte matrix format, the default_char has byte1 in
194            the most-significant byte and byte2 in the least significant byte.
195            If  the  default_char itself specifies an undefined or nonexistent
196            character, no printing is performed for an undefined  or  nonexis‐
197            tent character.
198
199       ·    The  min_bounds  and  max_bounds  members contain the most extreme
200            values of each individual XCharStruct component over all  elements
201            of  this  array (and ignore nonexistent characters).  The bounding
202            box of the  font  (the  smallest  rectangle  enclosing  the  shape
203            obtained by superimposing all of the characters at the same origin
204            [x,y]) has its upper-left coordinate at:
205                 [x + min_bounds.lbearing, y - max_bounds.ascent]
206
207            Its width is:
208                 max_bounds.rbearing - min_bounds.lbearing
209
210            Its height is:
211                 max_bounds.ascent + max_bounds.descent
212
213       ·    The ascent member is the logical extent  of  the  font  above  the
214            baseline  that  is  used  for  determining line spacing.  Specific
215            characters may extend beyond this.
216
217       ·    The descent member is the logical extent of the font at  or  below
218            the  baseline that is used for determining line spacing.  Specific
219            characters may extend beyond this.
220
221       ·    If the baseline is at Y-coordinate y, the logical  extent  of  the
222            font   is   inclusive   between   the  Y-coordinate  values  (y  -
223            font.ascent) and (y + font.descent - 1).  Typically,  the  minimum
224            interline  spacing  between  rows  of  text  is  given by ascent +
225            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)
229       described in terms of XCharStruct components is a  rectangle  with  its
230       upper-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
249       defines the extent of the top edge of the character ink from  the  ori‐
250       gin.   The  descent member defines the extent of the bottom edge of the
251       character ink from the origin.  The width member  defines  the  logical
252       width of 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
259                 defined 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.6.12                    XLoadFont(3)
Impressum