This is the base package for handling fonts. GtkAda knows about bitmap and vectorial fonts, and can draw both. The list of fonts available to you depends on what is installed on your system.
The name of the font is indicated in the standard X11 fashion, namely: (example extracted from the Xlib manual):
-adobe-courier-bold-o-normal--10-100-75-75-m-60-iso8859-1 where:
Any of the fields can have a '*' instead, so that the system will automatically find a font that matches the rest of the string, and won't care about that specific field.
But the easiest way to select a font is by using some external programs, for instance xfontsel, xlsfont, gfontsel, or even the font selection dialog example in the testgtk/ directory of the GtkAda distribution.
see section Package Gtk.Extra.PsFont for a package that processes postscript fonts, with their more usual names, and can easily convert them to standard Gdk_Font structures.
Some of the functions below should be used only for wide-character strings. This is needed for languages with more than 256 characters.
Wide character values between 0 and 127 are always identical in meaning to the ASCII character codes. 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.
On Unix systems, the external utility 'xfd' can be used to display all the characters in a font.
Types |
---|
type Gdk_Font is new Gdk.C_Proxy; | |
A font used to draw text.
This can represent a bitmap font, a scalable (vectorial) font, or
a fontset. A fontset is a list of comma-separated fonts, that permits
GtkAda to obtain the fonts needed for a variety of locales from a
single locale-independent base font name. The single base font name
should name a family of fonts whose members are encoded in the various
charsets needed by the locales of interest.
The algorithm used to select the font is described in the manual page
for XCreateFontSet(3X).
|
Subprograms |
---|
procedure Load (Font : out Gdk_Font; Font_Name : in String); | ||
Load a new font, given its name. | ||
procedure Fontset_Load (Font : out Gdk_Font; Fontset_Name : in String); | ||
Load a new font set. | ||
procedure Ref (Font : in Gdk_Font); | ||
Increment the reference counter for the font. | ||
procedure Unref (Font : in Gdk_Font); | ||
Decrement the reference counter for the font. | ||
function Id (Font : in Gdk_Font) return Gint; | ||
Return the X font id for the font. | ||
function Equal (Fonta, Fontb : in Gdk_Font) return Boolean; | ||
Compare two fonts or two fontsets for equality. | ||
function Get_Ascent (Font : in Gdk_Font) return Gint; | ||
Return the maximal ascent for the font. | ||
function Get_Descent (Font : in Gdk_Font) return Gint; | ||
Return the maximal descent for the font. | ||
function String_Width (Font : in Gdk_Font; Str : in String) return Gint; | ||
Return the width in pixels that Str will occupy if drawn with Font. | ||
function Text_Width (Font : in Gdk_Font; Text : in String) return Gint; | ||
This is the same function as String_Width. | ||
function Text_Width (Font : in Gdk_Font; Text : in Gdk.Types.Gdk_WString) return Gint; | ||
Return the width in pixels that Text will occupy on the screen. | ||
function Char_Width (Font : in Gdk_Font; Char : in Character) return Gint; | ||
Return the width in pixels occupied by a single character on the screen. | ||
function Char_Width (Font : in Gdk_Font; Char : in Gdk.Types.Gdk_WChar) return Gint; | ||
Return the width in pixels occupied by a single wide-character.
| ||
function String_Measure (Font : in Gdk_Font; Str : in String) return Gint; | ||
Determine the distance from the origin to the rightmost portion of Str. | ||
function Text_Measure (Font : in Gdk_Font; Text : in String) return Gint; | ||
Same function a String_Measure. | ||
function Char_Measure (Font : in Gdk_Font; Char : in Character) return Gint; | ||
Return the width in pixels of Char. | ||
procedure String_Extents (Font : in Gdk.Font.Gdk_Font; Str : in String; Lbearing : out Gint; Rbearing : out Gint; Width : out Gint; Ascent : out Gint; Descent : out Gint); | ||
Return the metrics for a given text. | ||
procedure Text_Extents (Font : in Gdk_Font; Text : in String; Lbearing : out Gint; Rbearing : out Gint; Width : out Gint; Ascent : out Gint; Descent : out Gint); | ||
Return all the metrics for a given text. | ||
procedure Text_Extents (Font : in Gdk_Font; Text : in Gdk.Types.Gdk_WString; Lbearing : out Gint; Rbearing : out Gint; Width : out Gint; Ascent : out Gint; Descent : out Gint); | ||
Return all the metrics for a given wide-character string. | ||
function String_Height (Font : in Gdk_Font; Str : in String) return Gint; | ||
Return the height in pixels of the string. | ||
function Text_Height (Font : in Gdk_Font; Str : in String) return Gint; | ||
Same as String_Height. | ||
function Char_Height (Font : in Gdk_Font; Char : in Character) return Gint; | ||
Return the total height in pixels of a single character.
|