GtkAda Reference Manual - Package Pango.Font

[Contents] [Back] [Prev] [Up] [Next] [Forward]

# Package Pango.Font

This package provides high-level, system-independent handling of fonts. It supercedes the old Gdk.Font package, which should no longer be used.

Fonts are defined through several attributes, like their family, weight, size, style, ...

The Pango_Font_Description objects created by this package can either be used directly to draw text through Pango.Layout.Pango_Layout objects (and the associated Gdk.Drawable.Draw_Layout procedure), or by converting them to a Gdk_Font. The first method is the preferred one, and provides high-level handling of multi-line texts or tabs, when you have to handle this yourself in the second case.

- Pango.Font Types
- Pango.Font Subprograms

## Types

    type Pango_Font_Description is new Glib.C_Proxy;
    type Pango_Font_Metrics is new Glib.C_Proxy;
    type Pango_Language is new Glib.C_Proxy;
    type Property_Font_Description is new Desc_Properties.Property;

## Subprograms

    function Get_Type              return Glib.GType;
| Return the internal gtk+ type associated with font descriptions.
    function Copy
      (Desc               :        Pango_Font_Description)
       return Pango_Font_Description;
| Return a newly allocated font description. This Pango_Font_Description needs to be free'ed after use.
    function Equal
      (Desc1              :        Pango_Font_Description;
       Desc2              :        Pango_Font_Description)
       return Boolean;
| Return True if the two font descriptions are identical. Note that two font description may result in identical fonts being loaded, but still compare False.
    procedure Free
      (Desc               : in out Pango_Font_Description);
| Deallocate the given font description.
    function From_String
      (Str                :        String)
       return Pango_Font_Description;
| Create a new font description from the given string representation of the given form: "[FAMILY-LIST] [STYLE-OPTIONS] [SIZE]". Any one of the options may be omitted. FAMILY-LIST is a comma separated list (spaces are not allowed) of font families optionally terminated by a comma. If absent, the font family of the font that will be used is unspecified. STYLE_OPTIONS is a whitespace separated list of words where each word describes either style, variant, weight, or stretch. Any unspecified style option is defaulted to "Normal", which respectively corresponds to Pango_Style_Normal, Pango_Weight_Normal, Pango_Variant_Normal, and Pango_Stretch_Normal. SIZE is a decimal number describing the size of the font in points. If unspecified, a size of 0 will be used.
    function To_Font_Description
      (Family_Name        :        String := "";
       Style              :        Pango.Enums.Style
                           := Pango.Enums.Pango_Style_Normal;
       Variant            :        Pango.Enums.Variant
                           := Pango.Enums.Pango_Variant_Normal;
       Weight             :        Pango.Enums.Weight
                           := Pango.Enums.Pango_Weight_Normal;
       Stretch            :        Pango.Enums.Stretch
                           := Pango.Enums.Pango_Stretch_Normal;
       Size               :        Gint := 0)
       return Pango_Font_Description;
| Create a new font decription from the given parameters.
    function To_String
      (Desc               :        Pango_Font_Description)
       return String;
| Create a string representation of a font description. The format of the string produced follows the syntax used by From_String. The family-list in the string description will have a terminating comma only if the last word of the list is a valid style option.
    function To_Filename
      (Desc               :        Pango_Font_Description)
       return String;
| Create a filename representation of a font description. The filename is identical to the result from calling To_String, but with underscores instead of characters that are untypical in filenames, and in lower case only.
    function Get_Family
      (Desc               :        Pango_Font_Description)
       return String;
| Return the Family_Name of the given Pango_Font_Description. This is
    procedure Set_Family
      (Desc               :        Pango_Font_Description;
       Name               :        String);
| Set the Family_Name of the given Pango_Font_Description.
    function Get_Size
      (Desc               :        Pango_Font_Description)
       return Gint;
| Return value: the size for the font description in pango units. (PANGO_SCALE pango units equals one point). Returns 0 if Desc hasn't been initialized.
    procedure Set_Size
      (Desc               :        Pango_Font_Description;
       Size               :        Gint);
| Set the size for the font description in pango units. (PANGO_SCALE pango units equals one point)
### Languages
The following section provides types and subprograms to identify a specific script and language inside a font (Not all characters of a font are used for all languages)
    function Pango_Language_Get_Typereturn Glib.GType;
| Return the internal value used to identify a Pango_Language
    function From_String
      (Language           :        String)
       return Pango_Language;
| Take a RFC-3066 format language tag as a string and convert it to a Pango_Language pointer that can be efficiently copied (copy the pointer) and compared with other language tags (compare the pointer). Language is something like "fr" (french), "ar" (arabic), "en" (english), "ru" (russian), ... This function first canonicalizes the string by converting it to lowercase, mapping '_' to '-', and stripping all characters other than letters and '-'. The returned value need not be freed, it is stored internally by gtk+ in a hash-table.
### Metrics
The following subprograms can be used to retrieve the metrics associated with the font. Note that such metrics might depend on the specific script/language in use.
    function Get_Metrics
      (Font               : access Pango_Font_Record'Class;
       Language           :        Pango_Language := null)
       return Pango_Font_Metrics;
| Gets overall metric information for a font. Since the metrics may be substantially different for different scripts, a language tag can be provided to indicate that the metrics should be retrieved that correspond to the script(s) used by that language. The returned value must be Unref'ed by the caller. Language determines which script to get the metrics for, or null to indicate the metrics for the entire font.
    procedure Ref
      (Metrics            :        Pango_Font_Metrics);
    function Get_Ascent
      (Metrics            :        Pango_Font_Metrics)
       return Gint;
| Gets the ascent from a font metrics structure. The ascent is the distance from the baseline to the logical top of a line of text. (The logical top may be above or below the top of the actual drawn ink. It is necessary to lay out the text to figure where the ink will be). The returned value is expressed in pango units, and must be divided by Pango_Scale to get the value in pixels.
    function Get_Descent
      (Metrics            :        Pango_Font_Metrics)
       return Gint;
| Gets the descent from a font metrics structure. The descent is the distance from the baseline to the logical bottom of a line of text. (The logical bottom may be above or below the bottom of the actual drawn ink. It is necessary to lay out the text to figure where the ink will be.) The returned value is expressed in pango units, and must be divided by Pango_Scale to get the value in pixels.
    function Get_Approximate_Char_Width
      (Metrics            :        Pango_Font_Metrics)
       return Gint;
| Gets the approximate character width for a font metrics structure. This is merely a representative value useful, for example, for determining the initial size for a window. Actual characters in text will be wider and narrower than this. The returned value is expressed in pango units, and must be divided by Pango_Scale to get the value in pixels.
    function Get_Approximate_Digit_Width
      (Metrics            :        Pango_Font_Metrics)
       return Gint;
| Gets the approximate digit width for a font metrics structure. This is merely a representative value useful, for example, for determining the initial size for a window. Actual digits in text can be wider and narrower than this, though this value is generally somewhat more accurate than the result of Get_Approximate_Char_Width. The returned value is expressed in pango units, and must be divided by Pango_Scale to get the value in pixels.
    function Font_Metrics_Get_Type return Glib.GType;
| Return the internal value associated with a Pango_Font_Metrics
### Properties
See the package Glib.Properties for more information on how to use properties
    function Internal_Copy
      (F                  :        Pango_Font_Description)
       return System.Address;

[Contents] [Back] [Prev] [Up] [Next] [Forward]