Class: RedBird::Font

Inherits:
Data
  • Object
show all
Defined in:
ext/red_bird/font.c,
ext/red_bird/font.c

Overview

This class represents a font; it is necessary for rendering any text.

Author:

  • Frederico Linhares

Instance Method Summary collapse

Constructor Details

#initialize(file_path, size) ⇒ Object

Parameters:

  • file_path (String)

    path to file containing the font.

  • size (Integer)

    size of text that will be rendered using this font.

Author:

  • Frederico Linhares



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'ext/red_bird/font.c', line 59

VALUE
bird_cFont_initialize(VALUE self, VALUE file_path, VALUE size)
{
  struct bird_font_data *ptr;

  SafeStringValue(file_path);
  RB_INTEGER_TYPE_P(size);

  TypedData_Get_Struct(self, struct bird_font_data, &bird_font_type, ptr);

  ptr->data = TTF_OpenFont(StringValueCStr(file_path), NUM2INT(size));
  if(!ptr->data)
  {
    rb_raise(rb_eArgError, "failed to load font: %s", TTF_GetError());
  }

  return self;
}