class Cairo::FreeTypeFontFace

Public Class Methods

new(p1) click to toggle source
static VALUE
cr_freetype_font_face_initialize (VALUE self, VALUE path)
{
  FT_Face freetype_face;
  FT_Error error;
  cairo_font_face_t *face;
  cairo_status_t status;

  error = FT_New_Face (cr_freetype_library,
                       StringValueCStr(path),
                       0,
                       &freetype_face);
  cr_freetype_error_check (error, "failed to open FreeType font", path);
  cr_freetype_n_faces++;

  face = cairo_ft_font_face_create_for_ft_face (freetype_face, 0);
  cr_font_face_check_status (face);
  status =
    cairo_font_face_set_user_data (face,
                                   &cr_freetype_face_key,
                                   freetype_face,
                                   (cairo_destroy_func_t) cr_freetype_done_face);
  if (status != CAIRO_STATUS_SUCCESS) {
    cairo_font_face_destroy (face);
    FT_Done_Face (freetype_face);
    rb_cairo_check_status (status);
  }

  DATA_PTR (self) = face;

  return Qnil;
}