static VALUE
cr_show_text_glyphs (VALUE self, VALUE rb_utf8, VALUE rb_glyphs,
                     VALUE rb_clusters, VALUE rb_cluster_flags)
{
  cairo_t *cr;
  const char *utf8;
  int utf8_len;
  cairo_glyph_t *glyphs = NULL;
  int num_glyphs = 0;
  cairo_text_cluster_t *clusters = NULL;
  int num_clusters = 0;
  cairo_text_cluster_flags_t cluster_flags;

  cr = _SELF;
  utf8 = RSTRING_PTR (rb_utf8);
  utf8_len = RSTRING_LEN (rb_utf8);
  rb_cairo__glyphs_from_ruby_object (rb_glyphs, &glyphs, &num_glyphs);
  rb_cairo__text_clusters_from_ruby_object (rb_clusters,
                                            &clusters, &num_clusters);
  cluster_flags = RVAL2CRTEXTCLUSTERFLAGS (rb_cluster_flags);
  cairo_show_text_glyphs (cr, utf8, utf8_len,
                          glyphs, num_glyphs,
                          clusters, num_clusters,
                          cluster_flags);
  if (glyphs)
    cairo_glyph_free (glyphs);
  if (clusters)
    cairo_text_cluster_free (clusters);

  return self;
}
示例#2
0
static VALUE
cr_user_font_face_text_to_glyphs_func_after (VALUE user_data)
{
  cr_user_font_face_invoke_data_t *data;
  cr_text_to_glyphs_after_hook_data_t *after_hook_data;
  VALUE text_to_glyphs_data;


  data = (cr_user_font_face_invoke_data_t *)user_data;
  after_hook_data = data->after_hook_data;
  text_to_glyphs_data = after_hook_data->text_to_glyphs_data;

  if (after_hook_data->glyphs)
    {
      VALUE rb_glyphs;

      rb_glyphs = rb_ivar_get (text_to_glyphs_data, cr_id_at_glyphs);
      rb_cairo__glyphs_from_ruby_object (rb_glyphs,
                                         after_hook_data->glyphs,
                                         after_hook_data->num_glyphs);
    }

  if (after_hook_data->clusters)
    {
      VALUE rb_clusters;

      rb_clusters = rb_ivar_get (text_to_glyphs_data, cr_id_at_clusters);
      rb_cairo__text_clusters_from_ruby_object (rb_clusters,
                                                after_hook_data->clusters,
                                                after_hook_data->num_clusters);
    }

  if (after_hook_data->cluster_flags)
    {
      VALUE rb_cluster_flags;

      rb_cluster_flags = rb_ivar_get (text_to_glyphs_data,
                                      cr_id_at_cluster_flags);
      *(after_hook_data->cluster_flags) =
        RVAL2CRTEXTCLUSTERFLAGS (rb_cluster_flags);
    }

  return data->result;
}