Class: Cairo::ScaledFont

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

Instance Method Summary collapse

Constructor Details

#initializeObject



70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'ext/cairo/rb_cairo_scaled_font.c', line 70

static VALUE
cr_scaled_font_initialize (VALUE self, VALUE face, VALUE matrix,
                           VALUE ctm, VALUE options)
{
  cairo_scaled_font_t *font;

  font = cairo_scaled_font_create (RVAL2CRFONTFACE (face),
                                   RVAL2CRMATRIX (matrix),
                                   RVAL2CRMATRIX (ctm),
                                   RVAL2CRFONTOPTIONS (options));
  cr_scaled_font_check_status (font);
  DATA_PTR (self) = font;
  return Qnil;
}

Instance Method Details

#ctmObject



171
172
173
174
175
176
177
178
# File 'ext/cairo/rb_cairo_scaled_font.c', line 171

static VALUE
cr_scaled_font_get_ctm (VALUE self)
{
  cairo_matrix_t ctm;
  cairo_scaled_font_get_font_matrix (_SELF (self), &ctm);
  cr_scaled_font_check_status (_SELF (self));
  return CRMATRIX2RVAL (&ctm);
}

#extentsObject



85
86
87
88
89
90
91
92
# File 'ext/cairo/rb_cairo_scaled_font.c', line 85

static VALUE
cr_scaled_font_extents (VALUE self)
{
  cairo_font_extents_t extents;
  cairo_scaled_font_extents (_SELF (self), &extents);
  cr_scaled_font_check_status (_SELF (self));
  return CRFONTEXTENTS2RVAL (&extents);
}

#font_faceObject



153
154
155
156
157
158
159
160
# File 'ext/cairo/rb_cairo_scaled_font.c', line 153

static VALUE
cr_scaled_font_get_font_face (VALUE self)
{
  cairo_font_face_t *face;
  face = cairo_scaled_font_get_font_face (_SELF (self));
  cr_scaled_font_check_status (_SELF (self));
  return CRFONTFACE2RVAL (face);
}

#font_matrixObject



162
163
164
165
166
167
168
169
# File 'ext/cairo/rb_cairo_scaled_font.c', line 162

static VALUE
cr_scaled_font_get_font_matrix (VALUE self)
{
  cairo_matrix_t font_matrix;
  cairo_scaled_font_get_font_matrix (_SELF (self), &font_matrix);
  cr_scaled_font_check_status (_SELF (self));
  return CRMATRIX2RVAL (&font_matrix);
}

#font_optionsObject



180
181
182
183
184
185
186
187
188
189
190
# File 'ext/cairo/rb_cairo_scaled_font.c', line 180

static VALUE
cr_scaled_font_get_font_options (VALUE self)
{
  cairo_font_options_t *options;

  options = cairo_font_options_create();
  cairo_scaled_font_get_font_options (_SELF (self), options);
  cr_scaled_font_check_status (_SELF (self));
  rb_cairo_check_status (cairo_font_options_status (options));
  return CRFONTOPTIONS2RVAL (options);
}

#glyph_extentsObject



104
105
106
107
108
109
110
111
112
113
114
115
# File 'ext/cairo/rb_cairo_scaled_font.c', line 104

static VALUE
cr_scaled_font_glyph_extents (VALUE self, VALUE rb_glyphs)
{
  cairo_text_extents_t extents;
  cairo_glyph_t *glyphs;
  int count;

  RB_CAIRO__GLYPHS_TO_ARRAY (rb_glyphs, glyphs, count);
  cairo_scaled_font_glyph_extents (_SELF (self), glyphs, count, &extents);
  cr_scaled_font_check_status (_SELF (self));
  return CRTEXTEXTENTS2RVAL (&extents);
}

#scale_matrixObject



193
194
195
196
197
198
199
200
201
# File 'ext/cairo/rb_cairo_scaled_font.c', line 193

static VALUE
cr_scaled_font_get_scale_matrix (VALUE self)
{
  cairo_matrix_t matrix;

  cairo_scaled_font_get_scale_matrix (_SELF (self), &matrix);
  cr_scaled_font_check_status (_SELF (self));
  return CRMATRIX2RVAL (&matrix);
}

#text_extentsObject



94
95
96
97
98
99
100
101
102
# File 'ext/cairo/rb_cairo_scaled_font.c', line 94

static VALUE
cr_scaled_font_text_extents (VALUE self, VALUE utf8)
{
  cairo_text_extents_t extents;
  cairo_scaled_font_text_extents (_SELF (self), StringValueCStr (utf8),
                                  &extents);
  cr_scaled_font_check_status (_SELF (self));
  return CRTEXTEXTENTS2RVAL (&extents);
}

#text_to_glyphsObject



118
119
120
121
122
123
124
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
# File 'ext/cairo/rb_cairo_scaled_font.c', line 118

static VALUE
cr_scaled_font_text_to_glyphs (VALUE self, VALUE rb_x, VALUE rb_y, VALUE rb_utf8)
{
  double x, y;
  const char *utf8;
  int utf8_len;
  cairo_glyph_t *glyphs = NULL;
  int num_glyphs;
  cairo_text_cluster_t *clusters = NULL;
  int num_clusters;
  cairo_text_cluster_flags_t cluster_flags;
  cairo_status_t status;
  VALUE rb_glyphs, rb_clusters;

  x = NUM2DBL (rb_x);
  y = NUM2DBL (rb_y);
  utf8 = RSTRING_PTR (rb_utf8);
  utf8_len = RSTRING_LEN (rb_utf8);

  status = cairo_scaled_font_text_to_glyphs (_SELF (self),
                                             x, y, utf8, utf8_len,
                                             &glyphs, &num_glyphs,
                                             &clusters, &num_clusters,
                                             &cluster_flags);
  rb_cairo_check_status (status);

  rb_glyphs = rb_cairo__glyphs_to_ruby_object (glyphs, num_glyphs);
  cairo_glyph_free (glyphs);
  rb_clusters = rb_cairo__text_clusters_to_ruby_object (clusters, num_clusters);
  cairo_text_cluster_free (clusters);

  return rb_ary_new3 (3, rb_glyphs, rb_clusters, INT2NUM (cluster_flags));
}