summaryrefslogtreecommitdiff
path: root/docs/reference/gdk/tmpl/fonts.sgml
blob: 25efd2dc48a7a9c6975a1e029ffac61852128477 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
<!-- ##### SECTION Title ##### -->
Fonts

<!-- ##### SECTION Short_Description ##### -->
Loading and manipulating fonts

<!-- ##### SECTION Long_Description ##### -->
<para>
The #GdkFont data type represents a font for drawing on
the screen. These functions provide support for
loading fonts, and also for determining the dimensions
of characters and strings when drawn with a particular
font.
</para>

<para>
Fonts in X are specified by a
<firstterm>X Logical Font Description</firstterm>. 
The following description is considerably simplified.
For definitive information about XLFD's see the 
X reference documentation. A X Logical Font Description (XLFD)
consists of a sequence of fields separated (and surrounded by) '-'
characters. For example, Adobe Helvetica Bold 12 pt, has the
full description: 
<informalexample><programlisting>
"-adobe-helvetica-bold-r-normal--12-120-75-75-p-70-iso8859-1"
</programlisting></informalexample>
</para>

<para>
The fields in the XLFD are:

<informaltable pgwide="1" frame="none">
<tgroup cols="2"><colspec colwidth="2*"/><colspec colwidth="8*"/>
<tbody>

<row>
<entry>Foundry</entry>
<entry>the company or organization where the font originated.</entry>
</row>

<row>
<entry>Family</entry>
<entry>the font family (a group of related font designs).</entry>
</row>

<row>
<entry>Weight</entry>
<entry>A name for the font's typographic weight
For example, 'bold' or 'medium').</entry>
</row>

<row>
<entry>Slant</entry>
<entry>The slant of the font. Common values are 'R' for Roman,
'I' for italoc, and 'O' for oblique.</entry>
</row>

<row>
<entry>Set Width</entry>
<entry>A name for the width of the font. For example,
'normal' or 'condensed'.</entry>
</row>

<row>
<entry>Add Style</entry>
<entry>Additional information to distinguish a font from
other fonts of the same family.</entry>
</row>

<row>
<entry>Pixel Size</entry>
<entry>The body size of the font in pixels.</entry>
</row>

<row>
<entry>Point Size</entry>
<entry>The body size of the font in 10ths of a point.
(A <firstterm>point</firstterm> is 1/72.27 inch) </entry>
</row>

<row>
<entry>Resolution X</entry>
<entry>The horizontal resolution that the font was designed for.</entry>
</row>

<row>
<entry>Resolution Y</entry>
<entry>The vertical resolution that the font was designed for .</entry>
</row>

<row>
<entry>Spacing</entry>
<entry>The type of spacing for the font - can be 'p' for proportional,
'm' for monospaced or 'c' for charcell.</entry>
</row>

<row>
<entry>Average Width</entry>
<entry>The average width of a glyph in the font. For monospaced
and charcell fonts, all glyphs in the font have this width</entry>
</row>

<row>
<entry>Charset Registry</entry>
<entry>The registration authority that owns the encoding for
the font. Together with the Charset Encoding field, this
defines the character set for the font.</entry>
</row>

<row>
<entry>Charset Encoding</entry>
<entry>An identifier for the particular character set encoding.</entry>
</row>

</tbody></tgroup></informaltable>
</para>

<para>
When specifying a font via a X logical Font Description,
'*' can be used as a wildcard to match any portion of
the XLFD. For instance, the above example could
also be specified as
<informalexample><programlisting>
"-*-helvetica-bold-r-normal--*-120-*-*-*-*-iso8859-1"
</programlisting></informalexample>

It is generally a good idea to use wildcards for any
portion of the XLFD that your program does not care
about specifically, since that will improve the
chances of finding a matching font.
</para>

<para>
A <firstterm>fontset</firstterm> is a list of fonts
that is used for drawing international text that may
contain characters from a number of different character
sets. It is represented by a list of XLFD's. 
</para>

<para>
The font for a given character set is determined by going
through the list of XLFD's in order. For each one, if
the registry and and encoding fields match the desired
character set, then that font is used, otherwise if
the XLFD contains wild-cards for the registry and encoding
fields, the registry and encoding for the desired character
set are substituted in and a lookup is done. If a match is found
that font is used. Otherwise, processing continues
on to the next font in the list.
</para>

<para>
The functions for determining the metrics of a string
come in several varieties that can take a number
of forms of string input:

<variablelist>
  <varlistentry>
    <term>8-bit string</term>
    <listitem><para>
    When using functions like gdk_string_width() that
    take a <type>gchar *</type>, if the font is of type
    %GDK_FONT_FONT and is an 8-bit font, then each
    <type>gchar</type> indexes the glyphs in the font directly.
    </para></listitem>
  </varlistentry>
  <varlistentry>
    <term>16-bit string</term>
    <listitem><para>
    For functions taking a <type>gchar *</type>, if the
    font is of type %GDK_FONT_FONT, and is a 16-bit
    font, then the <type>gchar *</type> argument is
    interpreted as a <type>guint16 *</type> cast to
    a <type>gchar *</type> and each <type>guint16</type>
    indexes the glyphs in the font directly.
    </para></listitem>
  </varlistentry>
  <varlistentry>
    <term>Multibyte string</term>
    <listitem><para>
    For functions taking a <type>gchar *</type>, if the
    font is of type %GDK_FONT_FONTSET, then the input
    string is interpreted as a <firstterm>multibyte</firstterm>
    encoded according to the current locale. (A multibyte
    string is one in which each character may consist
    of one or more bytes, with different lengths for different
    characters in the string). They can be converted to and
    from wide character strings (see below) using
    gdk_wcstombs() and gdk_mbstowcs().) The string will
    be rendered using one or more different fonts from
    the fontset.
    </para></listitem>
  </varlistentry>
  <varlistentry>
    <term>Wide character string</term>
    <listitem><para>
    For a number of the text-measuring functions, GDK
    provides a variant (such as gdk_text_width_wc()) which
    takes a <type>GdkWChar *</type> instead of a 
    <type>gchar *</type>. The input is then taken to
    be a wide character string in the encoding of the
    current locale. (A wide character string is a string
    in which each character consists of several bytes,
    and the width of each character in the string is 
    constant.)
    </para></listitem>
  </varlistentry>
</variablelist>
</para>

<para>
GDK provides functions to determine a number of different
measurements (metrics) for a given string. (Need diagram
here).

<variablelist>
  <varlistentry>
    <term>ascent</term>
    <listitem><para>
    The vertical distance from the origin of the drawing
    opereration to the top of the drawn character.
    </para></listitem>
  </varlistentry>
  <varlistentry>
    <term>descent</term>
    <listitem><para>
    The vertical distance from the origin of the drawing
    opereration to the bottom of the drawn character.
    </para></listitem>
  </varlistentry>
  <varlistentry>
    <term>left bearing</term>
    <listitem><para>
    The horizontal distance from the origin of the drawing
    operation to the left-most part of the drawn character.
    </para></listitem>
  </varlistentry>
  <varlistentry>
    <term>right bearing</term>
    <listitem><para>
    The horizontal distance from the origin of the drawing
    operation to the right-most part of the drawn character.
    </para></listitem>
  </varlistentry>
  <varlistentry>
    <term>width bearing</term>
    <listitem><para>
    The horizontal distance from the origin of the drawing
    operation to the correct origin for drawing another
    string to follow the current one. Depending on the
    font, this could be greater than or less than the 
    right bearing.
    </para></listitem>
  </varlistentry>
</variablelist>
</para>

<!-- ##### SECTION See_Also ##### -->
<para>

</para>

<!-- ##### SECTION Stability_Level ##### -->


<!-- ##### STRUCT GdkFont ##### -->
<para>
The <structname>GdkFont</structname> structure represents a font or fontset. It
contains the following public fields. A new <structname>GdkFont</structname>
structure is returned by gdk_font_load() or gdk_fontset_load(),
and is reference counted with gdk_font_ref() and gdk_font_unref()
</para>

@type: a value of type #GdkFontType which indicates
  whether this font is a single font or a fontset.
@ascent: the maximum distance that the font, when drawn,
  ascends above the baseline.
@descent: the maximum distance that the font, when drawn,
descends below the baseline.

<!-- ##### ENUM GdkFontType ##### -->
<para>
Indicates the type of a font. The possible values
are currently:
</para>

@GDK_FONT_FONT: the font is a single font.
@GDK_FONT_FONTSET: the font is a fontset.

<!-- ##### FUNCTION gdk_font_load ##### -->
<para>
</para>

@font_name: 
@Returns: 


<!-- ##### FUNCTION gdk_font_load_for_display ##### -->
<para>

</para>

@display: 
@font_name: 
@Returns: 


<!-- ##### FUNCTION gdk_fontset_load ##### -->
<para>
</para>

@fontset_name: 
@Returns: 


<!-- ##### FUNCTION gdk_fontset_load_for_display ##### -->
<para>

</para>

@display: 
@fontset_name: 
@Returns: 


<!-- ##### FUNCTION gdk_font_from_description ##### -->
<para>

</para>

@font_desc: 
@Returns: 


<!-- ##### FUNCTION gdk_font_from_description_for_display ##### -->
<para>

</para>

@display: 
@font_desc: 
@Returns: 


<!-- ##### FUNCTION gdk_font_get_display ##### -->
<para>

</para>

@font: 
@Returns: 


<!-- ##### FUNCTION gdk_font_ref ##### -->
<para>
</para>

@font: 
@Returns: 


<!-- ##### FUNCTION gdk_font_unref ##### -->
<para>
</para>

@font: 


<!-- ##### FUNCTION gdk_font_id ##### -->
<para>
</para>

@font: 
@Returns: 


<!-- ##### FUNCTION gdk_font_equal ##### -->
<para>
</para>

@fonta: 
@fontb: 
@Returns: 


<!-- ##### FUNCTION gdk_string_extents ##### -->
<para>
</para>

@font: 
@string: 
@lbearing: 
@rbearing: 
@width: 
@ascent: 
@descent: 


<!-- ##### FUNCTION gdk_text_extents ##### -->
<para>
</para>

@font: 
@text: 
@text_length: 
@lbearing: 
@rbearing: 
@width: 
@ascent: 
@descent: 


<!-- ##### FUNCTION gdk_text_extents_wc ##### -->
<para>
</para>

@font: 
@text: 
@text_length: 
@lbearing: 
@rbearing: 
@width: 
@ascent: 
@descent: 


<!-- ##### FUNCTION gdk_string_width ##### -->
<para>
</para>

@font: 
@string: 
@Returns: 


<!-- ##### FUNCTION gdk_text_width ##### -->
<para>
</para>

@font: 
@text: 
@text_length: 
@Returns: 


<!-- ##### FUNCTION gdk_text_width_wc ##### -->
<para>
</para>

@font: 
@text: 
@text_length: 
@Returns: 


<!-- ##### FUNCTION gdk_char_width ##### -->
<para>
</para>

@font: 
@character: 
@Returns: 


<!-- ##### FUNCTION gdk_char_width_wc ##### -->
<para>
</para>

@font: 
@character: 
@Returns: 


<!-- ##### FUNCTION gdk_string_measure ##### -->
<para>
</para>

@font: 
@string: 
@Returns: 


<!-- ##### FUNCTION gdk_text_measure ##### -->
<para>
</para>

@font: 
@text: 
@text_length: 
@Returns: 


<!-- ##### FUNCTION gdk_char_measure ##### -->
<para>
</para>

@font: 
@character: 
@Returns: 


<!-- ##### FUNCTION gdk_string_height ##### -->
<para>
</para>

@font: 
@string: 
@Returns: 


<!-- ##### FUNCTION gdk_text_height ##### -->
<para>
</para>

@font: 
@text: 
@text_length: 
@Returns: 


<!-- ##### FUNCTION gdk_char_height ##### -->
<para>
</para>

@font: 
@character: 
@Returns: 


<!-- ##### TYPEDEF GdkWChar ##### -->
<para>
Specifies a wide character type, used to represent character codes.
This is needed since some native languages have character sets which have
more than 256 characters (Japanese and Chinese, for example).
</para>
<para>
Wide character values between 0 and 127 are always identical in meaning to
the ASCII character codes. The wide character value 0 is often used to
terminate strings of wide characters in a similar way to normal strings
using the char type.
</para>
<para>
An alternative to wide characters is multi-byte characters, which extend
normal char strings to cope with larger character sets. As the name suggests,
multi-byte characters use a different number of bytes to store different
character codes. For example codes 0-127 (i.e. the ASCII codes) often
use just one byte of memory, while other codes may use 2, 3 or even 4 bytes.
Multi-byte characters have the advantage that they can often be used in an
application with little change, since strings are still represented as arrays
of char values. However multi-byte strings are much easier to manipulate since
the character are all of the same size.
</para>
<para>
Applications typically use wide characters to represent character codes
internally, and multi-byte strings when saving the characters to a file.
The gdk_wcstombs() and gdk_mbstowcs() functions can be used to convert from
one representation to the other.
</para>
<para>
See the 'Extended Characters' section of the GNU C Library Reference Manual
for more detailed information on wide and multi-byte characters.
</para>


<!-- ##### FUNCTION gdk_wcstombs ##### -->
<para>
</para>

@src: 
@Returns: 


<!-- ##### FUNCTION gdk_mbstowcs ##### -->
<para>
</para>

@dest: 
@src: 
@dest_max: 
@Returns: