Class: Imlib2::Font

# Imlib2::Font (Class)

In: | imlib2.c
Parent: | Object

## Methods

add_path advance ascent descent fonts get_ascent get_descent get_maximum_ascent get_maximum_descent get_text_advance get_text_index_and_location get_text_inset get_text_location_at_index get_text_size index inset list list_fonts list_paths load location maximum_ascent maximum_descent new new paths remove_path size text_advance text_index text_index_and_location text_inset text_location text_location_at_index text_size

## Public Class methods

add_path(p1)

Add a path to the list of font paths.

Example:

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

fonts()

Return an array of all known fonts

Example:

      font_list = Imlib2::Font.list_fonts

list()

Return an array of all known fonts

Example:

      font_list = Imlib2::Font.list_fonts

list_fonts()

Return an array of all known fonts

Example:

      font_list = Imlib2::Font.list_fonts

list_paths()

Return an array of font paths.

Example:

      path_list = Imlib2::Font.list_paths

load(p1)

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'

new()

Constructor for Imlib2::Font

Currently just a placeholder.

new(p1)

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'

paths()

Return an array of font paths.

Example:

      path_list = Imlib2::Font.list_paths

remove_path(p1)

Remove a path from the list of font paths.

Example:

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

## Public Instance methods

advance(p1)

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]
      }

ascent()

Get font ascent.

Example:

      a = font.ascent

descent()

Get font descent.

Example:

      a = font.descent

get_ascent()

Get font ascent.

Example:

      a = font.ascent

get_descent()

Get font descent.

Example:

      a = font.descent

get_maximum_ascent()

Get font maximum ascent.

Example:

      a = font.maximum_ascent

get_maximum_descent()

Get font maximum descent.

Example:

      a = font.maximum_descent

get_text_advance(p1)

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_text_index_and_location(...)

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_text_inset(p1)

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_text_location_at_index(p1, p2)

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_text_size(p1)

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]
      }

index(...)

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

inset(p1)

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...'

location(p1, p2)

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

maximum_ascent()

Get font maximum ascent.

Example:

      a = font.maximum_ascent

maximum_descent()

Get font maximum descent.

Example:

      a = font.maximum_descent

size(p1)

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]
      }

text_advance(p1)

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]
      }

text_index(...)

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

text_index_and_location(...)

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

text_inset(p1)

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...'

text_location(p1, p2)

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

text_location_at_index(p1, p2)

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

text_size(p1)

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]