GDK Reference ManualA fontset 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. 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 subsituted 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. The functions for determining the metrics of a string come in several varieties that can take a number of forms of string input: 8-bit string When using functions like gdk_string_width() that take a gchar *, if the font is of type GDK_FONT_FONT and is an 8-bit font, then each gchar indexes the glyphs in the font directly. 16-bit string For functions taking a gchar *, if the font is of type GDK_FONT_FONT, and is a 16-bit font, then the gchar * argument is interpreted as a guint16 * cast to a gchar * and each guint16 indexes the glyphs in the font directly. Multibyte string For functions taking a gchar *, if the font is of type GDK_FONT_FONTSET, then the input string is interpreted as a multibyte 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. Wide character string For a number of the text-measuring functions, GTK+ provides a variant (such as gdk_text_width_wc()) which takes a GdkWChar * instead of a gchar *. 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.) GDK provides functions to determine a number of different measurements (metrics) for a given string. (Need diagram here). ascent The vertical distance from the origin of the drawing opereration to the top of the drawn character. descent The vertical distance from the origin of the drawing opereration to the bottom of the drawn character. left bearing The horizontal distance from the origin of the drawing operation to the left-most part of the drawn character. right bearing The horizontal distance from the origin of the drawing operation to the right-most part of the drawn character. width bearing 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. Details struct GdkFont
The GdkFont structure represents a font or fontset. It contains the following public fields. A new GdkFont structure is returned by gdk_font_load() or gdk_fontset_load(), and is reference counted with gdk_font_ref() and gdk_font_unref() 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
Indicates the type of a font. The possible values are currently: GDK_FONT_FONT the font is a single font. GDK_FONT_FONT the font is a fontset.
Loads a font. Currently, this function will always return a new font, however, in the future, it may be changed to look up the font in a cache. You should make no assumptions about the initial reference count. font_name : a XLFD describing the font to load. Returns : a GdkFont, or NULL if the font could not be loaded. 上一篇:GTK v1.2 Tutorial(英文) 下一篇:Java入门(12) 事件与错误处理 更多相关文章
|
推荐文章
精彩文章
|