Class: Cairo::ToyFontFace

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

Instance Method Summary collapse

Methods inherited from FontFace

quartz_supported?

Constructor Details

#initializeObject



125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'ext/cairo/rb_cairo_font_face.c', line 125

static VALUE
cr_toy_font_face_initialize (int argc, VALUE *argv, VALUE self)
{
  cairo_font_face_t *face;
  VALUE rb_family, rb_slant, rb_weight;
  const char *family;
  cairo_font_slant_t slant;
  cairo_font_weight_t weight;

  rb_scan_args (argc, argv, "03", &rb_family, &rb_slant, &rb_weight);

  if (NIL_P (rb_family))
    {
      family = "";
    }
  else if (rb_cairo__is_kind_of (rb_family, rb_cString))
    {
      family = RSTRING_PTR (rb_family);
    }
  else if (rb_cairo__is_kind_of (rb_family, rb_cSymbol))
    {
      family = rb_id2name (SYM2ID (rb_family));
    }
  else
    {
      rb_raise (rb_eArgError,
                "family name should be nil, String or Symbol: %s",
                rb_cairo__inspect (rb_family));
    }

  if (NIL_P (rb_slant))
    slant = CAIRO_FONT_SLANT_NORMAL;
  else
    slant = RVAL2CRFONTSLANT (rb_slant);

  if (NIL_P (rb_weight))
    weight = CAIRO_FONT_WEIGHT_NORMAL;
  else
    weight = RVAL2CRFONTWEIGHT (rb_weight);

  face = cairo_toy_font_face_create (family, slant, weight);
  cr_font_face_check_status (face);
  DATA_PTR (self) = face;

  return Qnil;
}

Instance Method Details

#familyObject



172
173
174
175
176
# File 'ext/cairo/rb_cairo_font_face.c', line 172

static VALUE
cr_toy_font_face_get_family (VALUE self)
{
  return CSTR2RVAL (cairo_toy_font_face_get_family (_SELF));
}

#slantObject



178
179
180
181
182
# File 'ext/cairo/rb_cairo_font_face.c', line 178

static VALUE
cr_toy_font_face_get_slant (VALUE self)
{
  return INT2NUM (cairo_toy_font_face_get_slant (_SELF));
}

#weightObject



184
185
186
187
188
# File 'ext/cairo/rb_cairo_font_face.c', line 184

static VALUE
cr_toy_font_face_get_weight (VALUE self)
{
  return INT2NUM (cairo_toy_font_face_get_weight (_SELF));
}