Imlib2::Font (Class)

In: imlib2.c
Parent: Object

Public Class methods

Add a path to the list of font paths.

Example:

  Imlib2::Font.add_path '/usr/lib/X11/fonts/Truetype'

Return an array of all known fonts

Example:

  font_list = Imlib2::Font.list_fonts

Return an array of all known fonts

Example:

  font_list = Imlib2::Font.list_fonts

Return an array of all known fonts

Example:

  font_list = Imlib2::Font.list_fonts

Return an array of font paths.

Example:

  path_list = Imlib2::Font.list_paths

Returns a new Imlib2::Font

Note: the specified font must be in the font path. See Imlib2::Font::list_paths() for a list of font paths, and Imlib2::Font::list_fonts() for a list of fonts.

Examples:

  font = Imlib2::Font.new 'helvetica/24'
  font = Imlib2::Font.load 'helvetica/24'

Constructor for Imlib2::Font

Currently just a placeholder.

Returns a new Imlib2::Font

Note: the specified font must be in the font path. See Imlib2::Font::list_paths() for a list of font paths, and Imlib2::Font::list_fonts() for a list of fonts.

Examples:

  font = Imlib2::Font.new 'helvetica/24'
  font = Imlib2::Font.load 'helvetica/24'

Return an array of font paths.

Example:

  path_list = Imlib2::Font.list_paths

Remove a path from the list of font paths.

Example:

  Imlib2::Font.remove_path '/usr/lib/X11/fonts/Truetype'

Public Instance methods

Get the horizontal and vertical advance of the given string using this font.

Example:

  font = Imlib2::Font.new 'verdana/36'
  advances = font.advance "what's my advance?"
  ['horizontal', 'vertical'].each_index { |i, v|
    puts 'text ' << v << ' advance = ' << advances[i]
  }

Get font ascent.

Example:

  a = font.ascent

Get font descent.

Example:

  a = font.descent

Get font ascent.

Example:

  a = font.ascent

Get font descent.

Example:

  a = font.descent

Get font maximum ascent.

Example:

  a = font.maximum_ascent

Get font maximum descent.

Example:

  a = font.maximum_descent

Get the horizontal and vertical advance of the given string using this font.

Example:

  font = Imlib2::Font.new 'verdana/36'
  advances = font.advance "what's my advance?"
  ['horizontal', 'vertical'].each_index { |i, v|
    puts 'text ' << v << ' advance = ' << advances[i]
  }

Get the character index of the pixel at the given coordinates using this font.

Example:

  x, y, char_w, char_h = font.index "index\nstring\n", 5, 5

Get the inset of the given string using this font

Example:

  font = Imlib2::Font.new 'palatino/9'
  inset = font.inset 'wonder what the inset for this string is...'

Get the character coordinates of the at the given index using this font.

Example:

  x, y, char_w, char_h = font.index "index\nstring\n", 8

Get the width and height of the given string using this font.

Example:

  font = Imlib2::Font.new 'helvetica/12'
  size = font.size 'how big am i?'
  ['width', 'height'].each_index { |i, v|
    puts 'text ' << v << ' = ' << size[i]
  }

Get the character index of the pixel at the given coordinates using this font.

Example:

  x, y, char_w, char_h = font.index "index\nstring\n", 5, 5

Get the inset of the given string using this font

Example:

  font = Imlib2::Font.new 'palatino/9'
  inset = font.inset 'wonder what the inset for this string is...'

Get the character coordinates of the at the given index using this font.

Example:

  x, y, char_w, char_h = font.index "index\nstring\n", 8

Get font maximum ascent.

Example:

  a = font.maximum_ascent

Get font maximum descent.

Example:

  a = font.maximum_descent

Get the width and height of the given string using this font.

Example:

  font = Imlib2::Font.new 'helvetica/12'
  size = font.size 'how big am i?'
  ['width', 'height'].each_index { |i, v|
    puts 'text ' << v << ' = ' << size[i]
  }

Get the horizontal and vertical advance of the given string using this font.

Example:

  font = Imlib2::Font.new 'verdana/36'
  advances = font.advance "what's my advance?"
  ['horizontal', 'vertical'].each_index { |i, v|
    puts 'text ' << v << ' advance = ' << advances[i]
  }

Get the character index of the pixel at the given coordinates using this font.

Example:

  x, y, char_w, char_h = font.index "index\nstring\n", 5, 5

Get the character index of the pixel at the given coordinates using this font.

Example:

  x, y, char_w, char_h = font.index "index\nstring\n", 5, 5

Get the inset of the given string using this font

Example:

  font = Imlib2::Font.new 'palatino/9'
  inset = font.inset 'wonder what the inset for this string is...'

Get the character coordinates of the at the given index using this font.

Example:

  x, y, char_w, char_h = font.index "index\nstring\n", 8

Get the character coordinates of the at the given index using this font.

Example:

  x, y, char_w, char_h = font.index "index\nstring\n", 8

Get the width and height of the given string using this font.

Example:

  font = Imlib2::Font.new 'helvetica/12'
  size = font.size 'how big am i?'
  ['width', 'height'].each_index { |i, v|
    puts 'text ' << v << ' = ' << size[i]
  }

[Validate]