Class: Cairo::FreeTypeFontFace

Inherits:
FontFace
  • Object
show all
Defined in:
ext/cairo/rb_cairo_font_face.c

Instance Method Summary collapse

Methods inherited from FontFace

freetype_supported?, quartz_supported?

Constructor Details

#initializeObject



242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
# File 'ext/cairo/rb_cairo_font_face.c', line 242

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