!!! Important note !!!: this package is now considered as deprecated in GtkAda 2.x. You should use the types and subprograms in the Pango hierarchy, which correctly support internationalization, right-to-left writings, easy resizing of fonts, truetype fonts....
For backward compatibility, a new subprogram From_Description has been added to this package, which gives access to the more advanced font handling.
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.
An easy 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.
But the easiest way to create a font is to use a Pango_Font_Description. See package Pango.Font for more details about this structure.
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 |
---|
subtype Gdk_Font is Gdk.Gdk_Font; | |
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 |
---|
function Get_Type return Glib.GType; | ||
Return the internal value associated with Gdk_Font.
| ||
procedure Load (Font : out Gdk_Font; Font_Name : String); | ||
Load a new font, given its name.
See From_Description below for another way of creating a Gdk_Font.
| ||
procedure Fontset_Load (Font : out Gdk_Font; Fontset_Name : String); | ||
Load a new font set. | ||
function From_Description (Font_Desc : Pango.Font.Pango_Font_Description) return Gdk.Font.Gdk_Font; | ||
Create a new Gdk_Font from the given Pango_Font_Description. | ||
procedure Ref (Font : Gdk_Font); | ||
Increment the reference counter for the font. | ||
procedure Unref (Font : Gdk_Font); | ||
Decrement the reference counter for the font. | ||
function Id (Font : Gdk_Font) return Gint; | ||
Return the X font id for the font. | ||
function Equal (Fonta, Fontb : Gdk_Font) return Boolean; | ||
Compare two fonts or two fontsets for equality. | ||
function Get_Ascent (Font : Gdk_Font) return Gint; | ||
Return the maximal ascent for the font. | ||
function Get_Descent (Font : Gdk_Font) return Gint; | ||
Return the maximal descent for the font. | ||
function String_Width (Font : Gdk_Font; Str : String) return Gint; | ||
Return the width in pixels that Str will occupy if drawn with Font. | ||
function String_Width (Font : Gdk_Font; Text : Gdk.Types.Gdk_WString) return Gint; | ||
Return the width in pixels that Text will occupy on the screen. | ||
function Char_Width (Font : Gdk_Font; Char : Character) return Gint; | ||
Return the width in pixels occupied by a single character on the screen. | ||
function Char_Width (Font : Gdk_Font; Char : Gdk.Types.Gdk_WChar) return Gint; | ||
Return the width in pixels occupied by a single wide-character.
| ||
function String_Measure (Font : Gdk_Font; Str : String) return Gint; | ||
Determine the distance from the origin to the rightmost portion of Str. | ||
function Char_Measure (Font : Gdk_Font; Char : Character) return Gint; | ||
Return the width in pixels of Char. | ||
function String_Height (Font : Gdk_Font; Str : String) return Gint; | ||
Return the height in pixels of the string. | ||
function Char_Height (Font : Gdk_Font; Char : Character) return Gint; | ||
Return the total height in pixels of a single character.
| ||
procedure String_Extents (Font : Gdk.Font.Gdk_Font; Str : String; Lbearing : out Gint; Rbearing : out Gint; Width : out Gint; Ascent : out Gint; Descent : out Gint); | ||
Return the metrics for a given text. | ||
procedure String_Extents (Font : Gdk_Font; Text : 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. |