Reference Manual

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

# Inti::Pango::FontDescription Class Reference

A PangoFontDescription C++ wrapper class. More...

`#include <inti/pango/font.h>`

Inheritance diagram for Inti::Pango::FontDescription:

List of all members.

## Public Member Functions

Constructors

- FontDescription ()
    Construct a new font description with all fields unset.
- FontDescription (const String &desc)
    Creates a new font description from a string representation.
- FontDescription (const String &family, int size, Style style=STYLE_NORMAL, Weight weight=WEIGHT_NORMAL)
    Construct a new font description with the specifed family, size, style and weight.
- FontDescription (PangoFontDescription *desc)
    Construct a new font description from an existing PangoFontDescription.
- FontDescription (PangoFontDescription *desc, bool copy)
    Construct a new font description from an existing PangoFontDescription.
- FontDescription (const FontDescription &src)
    Copy constructor.
- virtual ~FontDescription ()
    Destructor.
- FontDescription & operator= (const FontDescription &src)
    Assignment operator.

Accessors

- PangoFontDescription * pango_font_description () const
    Get a pointer to the PangoFontDescription structure.
- operator PangoFontDescription * () const
    Conversion operator; safely converts a FontDescription to a PangoFontDescription pointer.
- String get_family () const
    Gets the family name field of a font description (see set_family()).
- Style get_style () const
    Gets the style field of a font description (see set_style()).
- Variant get_variant () const
    Gets the variant field of a font description (see set_variant()).
- Weight get_weight () const
    Gets the weight field of a font description (see set_weight()).
- Stretch get_stretch () const
    Gets the stretch field of a font description (see set_stretch()).
- int get_size () const
    Gets the size field of a font description.
- FontMask get_set_fields () const
    Determines which fields in a font description have been set.
- bool equal (const FontDescription &other) const
    Compares this font description with other for equality.
- bool operator== (const FontDescription &other) const
    Equality operator; compares this font description with other for equality.
- bool operator!= (const FontDescription &other) const
    Inequality operator; compares this font description with other for inequality.

Methods

- unsigned int hash () const
    Computes a hash of a font description object suitable to be used, for example, as an argument to g_hash_table_new().
- String to_string () const
    Creates a string representation of the font description.
- String to_filename () const
    Creates a filename representation of a font description.
- void set_family (const String &family)
    Sets the family name field of a font description.
- void set_style (Style style)
    Sets the style field of a font description.
- void set_variant (Variant variant)
    Sets the variant field of a font description.
- void set_weight (Weight weight)
    Sets the weight field of a font description.
- void set_stretch (Stretch stretch)
    Sets the stretch field of a font description.
- void set_size (int size)
    Sets the size field of a font description.
- void unset_fields (FontMask to_unset)
    Unsets some of the fields in a font description.
- void merge (const FontDescription &desc_to_merge, bool replace_existing)
    Merges the fields that are set in desc_to_merge into the fields in the font description.
- bool better_match (const FontDescription &new_match, const FontDescription *old_match=0) const
    Determines if the style attributes of new_match are a closer match for the font description than old_match, or if old_match is null, determines if new_match is a match at all.

## Detailed Description

A PangoFontDescription C++ wrapper class.

FontDescription represents the description of an ideal font. These objects are used both to list what fonts are available on the system and also for specifying the characteristics of a font to load.

## Constructor & Destructor Documentation

Inti::Pango::FontDescription::FontDescription | ( | const String & | desc | ) |

Creates a new font description from a string representation.

Parameters:

  desc | A string representation of a font description.

See to_string() for a description of the format of the string representation. The family list in the string description will only have a terminating comma if the last word of the list is a valid style option.

Inti::Pango::FontDescription::FontDescription | ( | const String & | family,
|  | int | size,
|  | Style | style = STYLE_NORMAL,
|  | Weight | weight = WEIGHT_NORMAL
| ) |

Construct a new font description with the specifed family, size, style and weight.

Parameters:

  family | A string representing the family name.
  size | The size for the font description in pango units (see set_size()).
  style | The style for the font description.
  weight | The weight for the font description.

Inti::Pango::FontDescription::FontDescription | ( | PangoFontDescription * | desc | ) |

Construct a new font description from an existing PangoFontDescription.

Parameters:

  desc | A pointer to a PangoFontDescription.

The desc can be a newly created PangoFontDescription or an existing PangoFontDescription. The font description object created is a temporary object. It doesn't take over the ownership of PangoFontDescription and PangoFontDescription is not freed by the destructor.

Inti::Pango::FontDescription::FontDescription | ( | PangoFontDescription * | desc,
|  | bool | copy
| ) |

Construct a new font description from an existing PangoFontDescription.

Parameters:

  desc | A pointer to a PangoFontDescription.
  copy | Whether the FontDescription object should make a copy of PangoFontDescription or not.

The desc can be a newly created PangoFontDescription or an existing PangoFontDescription. If copy is true FontDescription will make a copy of PangoFontDescription. If copy is false FontDescription wont make a copy but instead takes over the ownership of PangoFontDescription. Either way, the destructor will free PangoFontDescription when the FontDescription object is destroyed. This constructor is used by G::Boxed::wrap() to wrap PangoFontDescription objects in a C++ wrapper.

Inti::Pango::FontDescription::FontDescription | ( | const FontDescription & | src | ) |

Copy constructor.

Parameters:

  src | The source FontDescription.

## Member Function Documentation

bool Inti::Pango::FontDescription::better_match | ( | const FontDescription & | new_match,
|  | const FontDescription * | old_match = 0
| ) | const

Determines if the style attributes of new_match are a closer match for the font description than old_match, or if old_match is null, determines if new_match is a match at all.

Parameters:

  new_match | A FontDescription.
  old_match | A FontDescription, or null.

Approximate matching is done for weight and style; other attributes must match exactly.

bool Inti::Pango::FontDescription::equal | ( | const FontDescription & | other | ) | const

Compares this font description with other for equality.

Parameters:

  other: | Another FontDescription.

Returns:
  true if the two font descriptions are proveably identical.

Two font descriptions may result in identical fonts being loaded, but still compare false.

String Inti::Pango::FontDescription::get_family | ( |  | ) | const

Gets the family name field of a font description (see set_family()).

Returns:
  The family name field, or null if not previously set.

FontMask Inti::Pango::FontDescription::get_set_fields | ( |  | ) | const

Determines which fields in a font description have been set.

Returns:
  A bitmask with bits set corresponding to the fields in desc that have been set.

int Inti::Pango::FontDescription::get_size | ( |  | ) | const

Gets the size field of a font description.

Returns:
  The size field for the font description in pango units.

There are PANGO_SCALE pango units in one device unit - for fonts, font points are the device unit. Returns 0 if the stretch field has not previously been set. get_set_fields() to find out if the field was explicitely set or not.

Stretch Inti::Pango::FontDescription::get_stretch | ( |  | ) | const

Gets the stretch field of a font description (see set_stretch()).

Returns:
  The stretch field for the font description.

Use get_set_fields() to find out if the field was explicitely set or not.

Style Inti::Pango::FontDescription::get_style | ( |  | ) | const

Gets the style field of a font description (see set_style()).

Returns:
  The style field for the font description.

Use get_set_fields() to find out if the field was explicitely set or not.

Variant Inti::Pango::FontDescription::get_variant | ( |  | ) | const

Gets the variant field of a font description (see set_variant()).

Returns:
  The variant field for the font description.

Use get_set_fields() to find out if the field was explicitely set or not.

Weight Inti::Pango::FontDescription::get_weight | ( |  | ) | const

Gets the weight field of a font description (see set_weight()).

Returns:
  The weight field for the font description.

Use get_set_fields() to find out if the field was explicitely set or not.

unsigned int Inti::Pango::FontDescription::hash | ( |  | ) | const

Computes a hash of a font description object suitable to be used, for example, as an argument to g_hash_table_new().

Returns:
  The hash value.

void Inti::Pango::FontDescription::merge | ( | const FontDescription & | desc_to_merge,
|  | bool | replace_existing
| ) |

Merges the fields that are set in desc_to_merge into the fields in the font description.

Parameters:

  desc_to_merge | The font description to merge from.
  replace_existing | If true, replace fields in the font description with the corresponding values from desc_to_merge, even if they are already exist.

If replace_existing is false, only fields in desc that are not already set are affected. If true, then fields that are already set will be replaced as well.

bool Inti::Pango::FontDescription::operator!= | ( | const FontDescription & | other | ) | const

Inequality operator; compares this font description with other for inequality.

Parameters:

  other: | Another FontDescription.

Returns:
  true if the two font descriptions are not identical.

Two font descriptions may result in identical fonts being loaded, but still compare false.

FontDescription& Inti::Pango::FontDescription::operator= | ( | const FontDescription & | src | ) |

Assignment operator.

Parameters:

  src | The source FontDescription.

bool Inti::Pango::FontDescription::operator== | ( | const FontDescription & | other | ) | const

Equality operator; compares this font description with other for equality.

Parameters:

  other: | Another FontDescription.

Returns:
  true if the two font descriptions are proveably identical.

Two font descriptions may result in identical fonts being loaded, but still compare false.

void Inti::Pango::FontDescription::set_family | ( | const String & | family | ) |

Sets the family name field of a font description.

Parameters:

  family | A string representing the family name.

The family name represents a family of related font styles, and will resolve to a particular FontFamily. In some uses of FontDescription, it is also possible to use a comma separated list of family names for this field.

void Inti::Pango::FontDescription::set_size | ( | int | size | ) |

Sets the size field of a font description.

Parameters:

  size | The size for the font description in pango units.

There are PANGO_SCALE Pango units in one device unit (device unit is a point, for font sizes).

void Inti::Pango::FontDescription::set_stretch | ( | Stretch | stretch | ) |

Sets the stretch field of a font description.

Parameters:

  stretch | The stretch for the font description.

The stretch field specifies how narrow or wide the font should be.

void Inti::Pango::FontDescription::set_style | ( | Style | style | ) |

Sets the style field of a font description.

Parameters:

  style | The style for the font description.

The Pango::Style enumeration describes whether the font is slanted and the manner in which it is slanted; it can be either STYLE_NORMAL, STYLE_ITALIC, or STYLE_OBLIQUE. Most fonts will either have a italic style or an oblique style, but not both, and font matching in Pango will match italic specifications with oblique fonts and vice-versa if an exact match is not found.

void Inti::Pango::FontDescription::set_variant | ( | Variant | variant | ) |

Sets the variant field of a font description.

Parameters:

  variant | The variant type for the font description.

The Variant can either be VARIANT_NORMAL or VARIANT_SMALL_CAPS.

void Inti::Pango::FontDescription::set_weight | ( | Weight | weight | ) |

Sets the weight field of a font description.

Parameters:

  weight | The weight for the font description.

The weight field specifies how bold or light the font should be. In addition to the values of the Pango::Weight enumeration, other intermediate numeric values are possible.

String Inti::Pango::FontDescription::to_filename | ( |  | ) | const

Creates a filename representation of a font description.

Returns:
  A string that can be used as a filename.

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.

String Inti::Pango::FontDescription::to_string | ( |  | ) | const

Creates a string representation of the font description.

Returns:
  The string representation.

The string representation is in the form "[FAMILY-LIST] [STYLE-OPTIONS] [SIZE]", where FAMILY-LIST is a comma separated list of families optionally terminated by a comma, STYLE_OPTIONS is a whitespace separated list of words where each WORD describes one of style, variant, weight, or stretch, and SIZE is an decimal number (size in points). Any one of the options may be absent. If FAMILY-LIST is absent, then the family_name field of the resulting font description will be initialized to null. If STYLE-OPTIONS is missing, then all style options will be set to the default values. If SIZE is missing, the size in the resulting font description will be set to 0.

void Inti::Pango::FontDescription::unset_fields | ( | FontMask | to_unset | ) |

Unsets some of the fields in a font description.

Parameters:

  to_unset | The bitmask of fields in the desc to unset.

Note that this merely marks the fields cleared, it does not clear the settings for those fields.

The documentation for this class was generated from the following file:

- font.h

Main Page - Footer