1 <!-- ##### SECTION Title ##### -->
4 <!-- ##### SECTION Short_Description ##### -->
5 Loading and manipulating fonts
7 <!-- ##### SECTION Long_Description ##### -->
9 The #GdkFont data type represents a font for drawing on
10 the screen. These functions provide support for
11 loading fonts, and also for determining the dimensions
12 of characters and strings when drawn with a particular
17 Fonts in X are specified by a
18 <firstterm>X Logical Font Description</firstterm>.
19 The following description is considerably simplified.
20 For definitive information about XLFD's see the
21 X reference documentation. A X Logical Font Description (XLFD)
22 consists of a sequence of fields separated (and surrounded by) '-'
23 characters. For example, Adobe Helvetica Bold 12 pt, has the
25 <informalexample><programlisting>
26 "-adobe-helvetica-bold-r-normal--12-120-75-75-p-70-iso8859-1"
27 </programlisting></informalexample>
31 The fields in the XLFD are:
33 <informaltable pgwide="1" frame="none">
34 <tgroup cols="2"><colspec colwidth="2*"/><colspec colwidth="8*"/>
38 <entry>Foundry</entry>
39 <entry>the company or organization where the font originated.</entry>
44 <entry>the font family (a group of related font designs).</entry>
49 <entry>A name for the font's typographic weight
50 For example, 'bold' or 'medium').</entry>
55 <entry>The slant of the font. Common values are 'R' for Roman,
56 'I' for italoc, and 'O' for oblique.</entry>
60 <entry>Set Width</entry>
61 <entry>A name for the width of the font. For example,
62 'normal' or 'condensed'.</entry>
66 <entry>Add Style</entry>
67 <entry>Additional information to distinguish a font from
68 other fonts of the same family.</entry>
72 <entry>Pixel Size</entry>
73 <entry>The body size of the font in pixels.</entry>
77 <entry>Point Size</entry>
78 <entry>The body size of the font in 10ths of a point.
79 (A <firstterm>point</firstterm> is 1/72.27 inch) </entry>
83 <entry>Resolution X</entry>
84 <entry>The horizontal resolution that the font was designed for.</entry>
88 <entry>Resolution Y</entry>
89 <entry>The vertical resolution that the font was designed for .</entry>
93 <entry>Spacing</entry>
94 <entry>The type of spacing for the font - can be 'p' for proportional,
95 'm' for monospaced or 'c' for charcell.</entry>
99 <entry>Average Width</entry>
100 <entry>The average width of a glyph in the font. For monospaced
101 and charcell fonts, all glyphs in the font have this width</entry>
105 <entry>Charset Registry</entry>
106 <entry>The registration authority that owns the encoding for
107 the font. Together with the Charset Encoding field, this
108 defines the character set for the font.</entry>
112 <entry>Charset Encoding</entry>
113 <entry>An identifier for the particular character set encoding.</entry>
116 </tbody></tgroup></informaltable>
120 When specifying a font via a X logical Font Description,
121 '*' can be used as a wildcard to match any portion of
122 the XLFD. For instance, the above example could
124 <informalexample><programlisting>
125 "-*-helvetica-bold-r-normal--*-120-*-*-*-*-iso8859-1"
126 </programlisting></informalexample>
128 It is generally a good idea to use wildcards for any
129 portion of the XLFD that your program does not care
130 about specifically, since that will improve the
131 chances of finding a matching font.
135 A <firstterm>fontset</firstterm> is a list of fonts
136 that is used for drawing international text that may
137 contain characters from a number of different character
138 sets. It is represented by a list of XLFD's.
142 The font for a given character set is determined by going
143 through the list of XLFD's in order. For each one, if
144 the registry and and encoding fields match the desired
145 character set, then that font is used, otherwise if
146 the XLFD contains wild-cards for the registry and encoding
147 fields, the registry and encoding for the desired character
148 set are substituted in and a lookup is done. If a match is found
149 that font is used. Otherwise, processing continues
150 on to the next font in the list.
154 The functions for determining the metrics of a string
155 come in several varieties that can take a number
156 of forms of string input:
160 <term>8-bit string</term>
162 When using functions like gdk_string_width() that
163 take a <type>gchar *</type>, if the font is of type
164 %GDK_FONT_FONT and is an 8-bit font, then each
165 <type>gchar</type> indexes the glyphs in the font directly.
169 <term>16-bit string</term>
171 For functions taking a <type>gchar *</type>, if the
172 font is of type %GDK_FONT_FONT, and is a 16-bit
173 font, then the <type>gchar *</type> argument is
174 interpreted as a <type>guint16 *</type> cast to
175 a <type>gchar *</type> and each <type>guint16</type>
176 indexes the glyphs in the font directly.
180 <term>Multibyte string</term>
182 For functions taking a <type>gchar *</type>, if the
183 font is of type %GDK_FONT_FONTSET, then the input
184 string is interpreted as a <firstterm>multibyte</firstterm>
185 encoded according to the current locale. (A multibyte
186 string is one in which each character may consist
187 of one or more bytes, with different lengths for different
188 characters in the string). They can be converted to and
189 from wide character strings (see below) using
190 gdk_wcstombs() and gdk_mbstowcs().) The string will
191 be rendered using one or more different fonts from
196 <term>Wide character string</term>
198 For a number of the text-measuring functions, GDK
199 provides a variant (such as gdk_text_width_wc()) which
200 takes a <type>GdkWChar *</type> instead of a
201 <type>gchar *</type>. The input is then taken to
202 be a wide character string in the encoding of the
203 current locale. (A wide character string is a string
204 in which each character consists of several bytes,
205 and the width of each character in the string is
213 GDK provides functions to determine a number of different
214 measurements (metrics) for a given string. (Need diagram
221 The vertical distance from the origin of the drawing
222 opereration to the top of the drawn character.
228 The vertical distance from the origin of the drawing
229 opereration to the bottom of the drawn character.
233 <term>left bearing</term>
235 The horizontal distance from the origin of the drawing
236 operation to the left-most part of the drawn character.
240 <term>right bearing</term>
242 The horizontal distance from the origin of the drawing
243 operation to the right-most part of the drawn character.
247 <term>width bearing</term>
249 The horizontal distance from the origin of the drawing
250 operation to the correct origin for drawing another
251 string to follow the current one. Depending on the
252 font, this could be greater than or less than the
259 <!-- ##### SECTION See_Also ##### -->
264 <!-- ##### SECTION Stability_Level ##### -->
267 <!-- ##### SECTION Image ##### -->
270 <!-- ##### STRUCT GdkFont ##### -->
272 The <structname>GdkFont</structname> structure represents a font or fontset. It
273 contains the following public fields. A new <structname>GdkFont</structname>
274 structure is returned by gdk_font_load() or gdk_fontset_load(),
275 and is reference counted with gdk_font_ref() and gdk_font_unref()
278 @type: a value of type #GdkFontType which indicates
279 whether this font is a single font or a fontset.
280 @ascent: the maximum distance that the font, when drawn,
281 ascends above the baseline.
282 @descent: the maximum distance that the font, when drawn,
283 descends below the baseline.
285 <!-- ##### ENUM GdkFontType ##### -->
287 Indicates the type of a font. The possible values
291 @GDK_FONT_FONT: the font is a single font.
292 @GDK_FONT_FONTSET: the font is a fontset.
294 <!-- ##### FUNCTION gdk_font_load ##### -->
302 <!-- ##### FUNCTION gdk_font_load_for_display ##### -->
312 <!-- ##### FUNCTION gdk_fontset_load ##### -->
320 <!-- ##### FUNCTION gdk_fontset_load_for_display ##### -->
330 <!-- ##### FUNCTION gdk_font_from_description ##### -->
339 <!-- ##### FUNCTION gdk_font_from_description_for_display ##### -->
349 <!-- ##### FUNCTION gdk_font_get_display ##### -->
358 <!-- ##### FUNCTION gdk_font_ref ##### -->
366 <!-- ##### FUNCTION gdk_font_unref ##### -->
373 <!-- ##### FUNCTION gdk_font_id ##### -->
381 <!-- ##### FUNCTION gdk_font_equal ##### -->
390 <!-- ##### FUNCTION gdk_string_extents ##### -->
403 <!-- ##### FUNCTION gdk_text_extents ##### -->
417 <!-- ##### FUNCTION gdk_text_extents_wc ##### -->
431 <!-- ##### FUNCTION gdk_string_width ##### -->
440 <!-- ##### FUNCTION gdk_text_width ##### -->
450 <!-- ##### FUNCTION gdk_text_width_wc ##### -->
460 <!-- ##### FUNCTION gdk_char_width ##### -->
469 <!-- ##### FUNCTION gdk_char_width_wc ##### -->
478 <!-- ##### FUNCTION gdk_string_measure ##### -->
487 <!-- ##### FUNCTION gdk_text_measure ##### -->
497 <!-- ##### FUNCTION gdk_char_measure ##### -->
506 <!-- ##### FUNCTION gdk_string_height ##### -->
515 <!-- ##### FUNCTION gdk_text_height ##### -->
525 <!-- ##### FUNCTION gdk_char_height ##### -->
534 <!-- ##### TYPEDEF GdkWChar ##### -->
536 Specifies a wide character type, used to represent character codes.
537 This is needed since some native languages have character sets which have
538 more than 256 characters (Japanese and Chinese, for example).
541 Wide character values between 0 and 127 are always identical in meaning to
542 the ASCII character codes. The wide character value 0 is often used to
543 terminate strings of wide characters in a similar way to normal strings
547 An alternative to wide characters is multi-byte characters, which extend
548 normal char strings to cope with larger character sets. As the name suggests,
549 multi-byte characters use a different number of bytes to store different
550 character codes. For example codes 0-127 (i.e. the ASCII codes) often
551 use just one byte of memory, while other codes may use 2, 3 or even 4 bytes.
552 Multi-byte characters have the advantage that they can often be used in an
553 application with little change, since strings are still represented as arrays
554 of char values. However multi-byte strings are much easier to manipulate since
555 the character are all of the same size.
558 Applications typically use wide characters to represent character codes
559 internally, and multi-byte strings when saving the characters to a file.
560 The gdk_wcstombs() and gdk_mbstowcs() functions can be used to convert from
561 one representation to the other.
564 See the 'Extended Characters' section of the GNU C Library Reference Manual
565 for more detailed information on wide and multi-byte characters.
569 <!-- ##### FUNCTION gdk_wcstombs ##### -->
577 <!-- ##### FUNCTION gdk_mbstowcs ##### -->