Class: SDL2::TTF

Inherits:
Object
  • Object
show all
Defined in:
ttf.c

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) init



52
53
54
55
56
# File 'ttf.c', line 52

static VALUE TTF_s_init(VALUE self)
{
    HANDLE_TTF_ERROR(TTF_Init());
    return Qnil;
}

+ (Object) open



58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'ttf.c', line 58

static VALUE TTF_s_open(int argc, VALUE* argv, VALUE self)
{
    TTF_Font* font;
    VALUE fname, ptsize, index;
    rb_scan_args(argc, argv, "21", &fname, &ptsize, &index);

    font = TTF_OpenFontIndex(StringValueCStr(fname), NUM2INT(ptsize),
                             index == Qnil ? 0 : NUM2LONG(index));
    if (!font)
        TTF_ERROR();
    
    return TTF_new(font);
}

Instance Method Details

- (Object) destroy



72
73
74
75
76
77
78
79
# File 'ttf.c', line 72

static VALUE TTF_destroy(VALUE self)
{
    TTF* f = Get_TTF(self);
    if (f->font)
        TTF_CloseFont(f->font);
    f->font = NULL;
    return Qnil;
}

- (Boolean) destroy?

Returns:

  • (Boolean)

- (Boolean) face_is_fixed_width?

Returns:

  • (Boolean)

- (Object) render_blended



135
136
137
138
# File 'ttf.c', line 135

static VALUE TTF_render_blended(VALUE self, VALUE text, VALUE fg)
{
    return render(render_blended, self, text, fg, Qnil);
}

- (Object) render_shaded



130
131
132
133
# File 'ttf.c', line 130

static VALUE TTF_render_shaded(VALUE self, VALUE text, VALUE fg, VALUE bg)
{
    return render(TTF_RenderUTF8_Shaded, self, text, fg, bg);
}

- (Object) render_solid



125
126
127
128
# File 'ttf.c', line 125

static VALUE TTF_render_solid(VALUE self, VALUE text, VALUE fg)
{
    return render(render_solid, self, text, fg, Qnil);
}

- (Object) size_text



94
95
96
97
98
99
100
# File 'ttf.c', line 94

static VALUE TTF_size_text(VALUE self, VALUE text)
{
    int w, h;
    text = rb_str_export_to_enc(text, rb_utf8_encoding());
    HANDLE_TTF_ERROR(TTF_SizeUTF8(Get_TTF_Font(self), StringValueCStr(text), &w, &h));
    return rb_ary_new3(2, INT2NUM(w), INT2NUM(h));
}