pango 1.0.3 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/ext/pango/extconf.rb +3 -0
  2. data/ext/pango/rbpango.c +312 -12
  3. data/ext/pango/rbpango.h +33 -22
  4. data/ext/pango/rbpangoanalysis.c +98 -58
  5. data/ext/pango/rbpangoattribute.c +94 -85
  6. data/ext/pango/rbpangoattriterator.c +39 -28
  7. data/ext/pango/rbpangoattrlist.c +42 -32
  8. data/ext/pango/rbpangocairo.c +38 -172
  9. data/ext/pango/rbpangocairocontext.c +151 -0
  10. data/ext/pango/rbpangocolor.c +49 -38
  11. data/ext/pango/rbpangocontext.c +109 -102
  12. data/ext/pango/rbpangoconversions.h +111 -0
  13. data/ext/pango/rbpangocoverage.c +45 -37
  14. data/ext/pango/rbpangoengine.c +22 -12
  15. data/ext/pango/rbpangofont.c +52 -43
  16. data/ext/pango/rbpangofontdescription.c +102 -91
  17. data/ext/pango/rbpangofontface.c +32 -21
  18. data/ext/pango/rbpangofontfamily.c +31 -20
  19. data/ext/pango/rbpangofontmap.c +44 -36
  20. data/ext/pango/rbpangofontmetrics.c +41 -30
  21. data/ext/pango/rbpangofontset.c +32 -21
  22. data/ext/pango/rbpangofontsetsimple.c +34 -24
  23. data/ext/pango/rbpangoglyphinfo.c +48 -35
  24. data/ext/pango/rbpangoglyphitem.c +43 -33
  25. data/ext/pango/rbpangoglyphstring.c +59 -59
  26. data/ext/pango/rbpangogravity.c +34 -23
  27. data/ext/pango/rbpangoitem.c +43 -34
  28. data/ext/pango/rbpangolanguage.c +44 -34
  29. data/ext/pango/rbpangolayout.c +167 -160
  30. data/ext/pango/rbpangolayoutiter.c +70 -59
  31. data/ext/pango/rbpangolayoutline.c +106 -71
  32. data/ext/pango/rbpangologattr.c +42 -31
  33. data/ext/pango/rbpangomatrix.c +47 -35
  34. data/ext/pango/rbpangoprivate.h +53 -0
  35. data/ext/pango/rbpangorectangle.c +58 -49
  36. data/ext/pango/rbpangorenderer.c +81 -70
  37. data/ext/pango/rbpangoscript.c +37 -27
  38. data/ext/pango/rbpangoscriptiter.c +32 -22
  39. data/ext/pango/rbpangotabarray.c +48 -37
  40. metadata +12 -12
  41. data/ChangeLog +0 -721
  42. data/ext/pango/rbpangoinits.c +0 -72
  43. data/ext/pango/rbpangomain.c +0 -202
@@ -1,50 +1,60 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
- /************************************************
3
-
4
- rbpangofontsetsimple.c -
5
-
6
- $Author: mutoh $
7
- $Date: 2005/10/14 09:55:57 $
8
-
9
- Copyright (C) 2002,2003 Masao Mutoh
10
- ************************************************/
11
-
12
- #include "rbpango.h"
2
+ /*
3
+ * Copyright (C) 2011 Ruby-GNOME2 Project Team
4
+ * Copyright (C) 2002,2003 Masao Mutoh
5
+ *
6
+ * This library is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU Lesser General Public
8
+ * License as published by the Free Software Foundation; either
9
+ * version 2.1 of the License, or (at your option) any later version.
10
+ *
11
+ * This library is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with this library; if not, write to the Free Software
18
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
+ * MA 02110-1301 USA
20
+ */
21
+
22
+ #include "rbpangoprivate.h"
13
23
 
14
24
  #ifdef PANGO_ENABLE_BACKEND
15
25
 
16
- #define _SELF(self) (PANGO_FONTSET_SIMPLE(RVAL2GOBJ(self)))
17
- #define RVAL2LANG(v) ((PangoLanguage*)RVAL2BOXED(v, PANGO_TYPE_LANGUAGE))
26
+ #define RG_TARGET_NAMESPACE cFontsetSimple
27
+ #define _SELF(self) (RVAL2PANGOFONTSETSIMPLE(self))
18
28
 
19
29
  static VALUE
20
- fontset_simple_initialize(VALUE self, VALUE lang)
30
+ rg_initialize(VALUE self, VALUE lang)
21
31
  {
22
- G_INITIALIZE(self, pango_fontset_simple_new(RVAL2LANG(lang)));
32
+ G_INITIALIZE(self, pango_fontset_simple_new(RVAL2PANGOLANGUAGE(lang)));
23
33
  return Qnil;
24
34
  }
25
35
 
26
36
  static VALUE
27
- fontset_simple_append(VALUE self, VALUE font)
37
+ rg_append(VALUE self, VALUE font)
28
38
  {
29
- pango_fontset_simple_append(_SELF(self), PANGO_FONT(RVAL2GOBJ(font)));
39
+ pango_fontset_simple_append(_SELF(self), RVAL2PANGOFONT(font));
30
40
  return self;
31
41
  }
32
42
 
33
43
  static VALUE
34
- fontset_simple_size(VALUE self)
44
+ rg_size(VALUE self)
35
45
  {
36
46
  return INT2NUM(pango_fontset_simple_size(_SELF(self)));
37
47
  }
38
48
 
39
49
  #endif
40
50
  void
41
- Init_pango_fontset_simple()
51
+ Init_pango_fontset_simple(VALUE mPango)
42
52
  {
43
53
  #ifdef PANGO_ENABLE_BACKEND
44
- VALUE pFSimple = G_DEF_CLASS(PANGO_TYPE_FONTSET_SIMPLE, "FontsetSimple", mPango);
45
-
46
- rb_define_method(pFSimple, "initialize", fontset_simple_initialize, 1);
47
- rb_define_method(pFSimple, "append", fontset_simple_append, 1);
48
- rb_define_method(pFSimple, "size", fontset_simple_size, 0);
54
+ VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(PANGO_TYPE_FONTSET_SIMPLE, "FontsetSimple", mPango);
55
+
56
+ RG_DEF_METHOD(initialize, 1);
57
+ RG_DEF_METHOD(append, 1);
58
+ RG_DEF_METHOD(size, 0);
49
59
  #endif
50
60
  }
@@ -1,27 +1,40 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
- /************************************************
3
-
4
- rbpangoglyphinfo.c -
5
-
6
- $Author: ggc $
7
- $Date: 2007/07/13 16:07:33 $
8
-
9
- Copyright (C) 2005 Masao Mutoh
10
- ************************************************/
11
-
12
- #include "rbpango.h"
2
+ /*
3
+ * Copyright (C) 2011 Ruby-GNOME2 Project Team
4
+ * Copyright (C) 2005 Masao Mutoh
5
+ *
6
+ * This library is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU Lesser General Public
8
+ * License as published by the Free Software Foundation; either
9
+ * version 2.1 of the License, or (at your option) any later version.
10
+ *
11
+ * This library is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with this library; if not, write to the Free Software
18
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
+ * MA 02110-1301 USA
20
+ */
13
21
 
14
- #define _SELF(self) ((PangoGlyphInfo*)RVAL2BOXED(self, PANGO_TYPE_GLYPH_INFO))
22
+ #include "rbpangoprivate.h"
15
23
 
24
+ #define RG_TARGET_NAMESPACE cGlyphInfo
25
+ #define _SELF(self) (RVAL2PANGOGLYPHINFO(self))
16
26
 
17
27
  /**********************************/
18
- PangoGlyphInfo*
19
- pango_glyph_info_copy (const PangoGlyphInfo* info)
28
+ static PangoGlyphInfo *
29
+ pango_glyph_info_copy(const PangoGlyphInfo *info)
20
30
  {
21
- PangoGlyphInfo* data;
22
- g_return_val_if_fail (info != NULL, NULL);
31
+ PangoGlyphInfo *data;
32
+
33
+ g_return_val_if_fail(info != NULL, NULL);
34
+
23
35
  data = g_new(PangoGlyphInfo, 1);
24
36
  *data = *info;
37
+
25
38
  return data;
26
39
  }
27
40
 
@@ -39,27 +52,27 @@ pango_glyph_info_get_type(void)
39
52
  /**********************************/
40
53
 
41
54
  static VALUE
42
- gi_initialize(VALUE self)
55
+ rg_initialize(VALUE self)
43
56
  {
44
57
  G_INITIALIZE(self, g_new0(PangoGlyphInfo, 1));
45
58
  return Qnil;
46
59
  }
47
60
 
48
61
  static VALUE
49
- gi_glyph(VALUE self)
62
+ rg_glyph(VALUE self)
50
63
  {
51
64
  return UINT2NUM(_SELF(self)->glyph);
52
65
  }
53
66
 
54
67
  static VALUE
55
- gi_set_glyph(VALUE self, VALUE val)
68
+ rg_set_glyph(VALUE self, VALUE val)
56
69
  {
57
70
  _SELF(self)->glyph = NUM2UINT(val);
58
71
  return self;
59
72
  }
60
73
 
61
74
  static VALUE
62
- gi_geometry(VALUE self)
75
+ rg_geometry(VALUE self)
63
76
  {
64
77
  PangoGlyphGeometry geo = _SELF(self)->geometry;
65
78
 
@@ -68,7 +81,7 @@ gi_geometry(VALUE self)
68
81
  }
69
82
 
70
83
  static VALUE
71
- gi_set_geometry(VALUE self, VALUE width, VALUE x_offset, VALUE y_offset)
84
+ rg_set_geometry(VALUE self, VALUE width, VALUE x_offset, VALUE y_offset)
72
85
  {
73
86
  PangoGlyphGeometry geo = _SELF(self)->geometry;
74
87
 
@@ -83,30 +96,30 @@ gi_set_geometry(VALUE self, VALUE width, VALUE x_offset, VALUE y_offset)
83
96
  This method may be changed in the future following Pango implementation.
84
97
  */
85
98
  static VALUE
86
- gi_attr_is_cluster_start(VALUE self)
99
+ rg_cluster_start_p(VALUE self)
87
100
  {
88
101
  return CBOOL2RVAL(_SELF(self)->attr.is_cluster_start);
89
102
  }
90
103
 
91
104
  static VALUE
92
- gi_attr_set_is_cluster_start(VALUE self, VALUE val)
105
+ rg_set_cluster_start(VALUE self, VALUE val)
93
106
  {
94
107
  _SELF(self)->attr.is_cluster_start = RVAL2CBOOL(val);
95
108
  return self;
96
109
  }
97
110
 
98
111
  void
99
- Init_pango_glyph_info()
112
+ Init_pango_glyph_info(VALUE mPango)
100
113
  {
101
- VALUE pInfo = G_DEF_CLASS(PANGO_TYPE_GLYPH_INFO, "GlyphInfo", mPango);
102
-
103
- rb_define_method(pInfo, "initialize", gi_initialize, 0);
104
- rb_define_method(pInfo, "glyph", gi_glyph, 0);
105
- rb_define_method(pInfo, "set_glyph", gi_set_glyph, 1);
106
- rb_define_method(pInfo, "geometry", gi_geometry, 0);
107
- rb_define_method(pInfo, "set_geometry", gi_set_geometry, 3);
108
- rb_define_method(pInfo, "cluster_start?", gi_attr_is_cluster_start, 0);
109
- rb_define_method(pInfo, "set_cluster_start", gi_attr_set_is_cluster_start, 1);
110
-
111
- G_DEF_SETTERS(pInfo);
114
+ VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(PANGO_TYPE_GLYPH_INFO, "GlyphInfo", mPango);
115
+
116
+ RG_DEF_METHOD(initialize, 0);
117
+ RG_DEF_METHOD(glyph, 0);
118
+ RG_DEF_METHOD(set_glyph, 1);
119
+ RG_DEF_METHOD(geometry, 0);
120
+ RG_DEF_METHOD(set_geometry, 3);
121
+ RG_DEF_METHOD_P(cluster_start, 0);
122
+ RG_DEF_METHOD(set_cluster_start, 1);
123
+
124
+ G_DEF_SETTERS(RG_TARGET_NAMESPACE);
112
125
  }
@@ -1,18 +1,29 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
- /************************************************
3
-
4
- rbpangoglyphitem.c -
5
-
6
- $Author: ggc $
7
- $Date: 2006/06/22 19:52:54 $
8
-
9
- Copyright (C) 2002-2005 Masao Mutoh
10
- ************************************************/
11
-
12
- #include "rbpango.h"
2
+ /*
3
+ * Copyright (C) 2011 Ruby-GNOME2 Project Team
4
+ * Copyright (C) 2002-2005 Masao Mutoh
5
+ *
6
+ * This library is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU Lesser General Public
8
+ * License as published by the Free Software Foundation; either
9
+ * version 2.1 of the License, or (at your option) any later version.
10
+ *
11
+ * This library is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with this library; if not, write to the Free Software
18
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
+ * MA 02110-1301 USA
20
+ */
21
+
22
+ #include "rbpangoprivate.h"
13
23
 
14
24
  #if PANGO_CHECK_VERSION(1,2,0)
15
- #define _SELF(r) ((PangoGlyphItem*)RVAL2BOXED(r, PANGO_TYPE_GLYPH_ITEM))
25
+ #define RG_TARGET_NAMESPACE cGlyphItem
26
+ #define _SELF(r) (RVAL2PANGOGLYPHITEM(r))
16
27
 
17
28
  /**********************************/
18
29
  #ifndef HAVE_PANGO_GLYPH_ITEM_GET_TYPE
@@ -53,50 +64,50 @@ pango_glyph_item_get_type(void)
53
64
  /**********************************/
54
65
 
55
66
  static VALUE
56
- glyph_item_get_item(VALUE self)
67
+ rg_item(VALUE self)
57
68
  {
58
69
  PangoItem* item = _SELF(self)->item;
59
- return BOXED2RVAL(item, PANGO_TYPE_ITEM);
70
+ return PANGOITEM2RVAL(item);
60
71
  }
61
72
 
62
73
  static VALUE
63
- glyph_item_get_glyphs(VALUE self)
74
+ rg_glyphs(VALUE self)
64
75
  {
65
76
  PangoGlyphString* glyphs = _SELF(self)->glyphs;
66
- return BOXED2RVAL(glyphs, PANGO_TYPE_GLYPH_STRING);
77
+ return PANGOGLYPHSTRING2RVAL(glyphs);
67
78
  }
68
79
 
69
80
  static VALUE
70
- glyph_item_split(VALUE self, VALUE text, VALUE split_index)
81
+ rg_split(VALUE self, VALUE text, VALUE split_index)
71
82
  {
72
- return BOXED2RVAL(pango_glyph_item_split(_SELF(self), RVAL2CSTR(text),
73
- NUM2INT(split_index)), PANGO_TYPE_GLYPH_ITEM);
83
+ return PANGOGLYPHITEM2RVAL(pango_glyph_item_split(_SELF(self), RVAL2CSTR(text),
84
+ NUM2INT(split_index)));
74
85
  }
75
86
 
76
87
  static VALUE
77
- glyph_item_apply_attrs(VALUE self, VALUE text, VALUE attrs)
88
+ rg_appy_attrs(VALUE self, VALUE text, VALUE attrs)
78
89
  {
79
90
  GSList* list = pango_glyph_item_apply_attrs(_SELF(self), RVAL2CSTR(text),
80
- (PangoAttrList*)RVAL2BOXED(attrs, PANGO_TYPE_ATTR_LIST));
91
+ RVAL2PANGOATTRLIST(attrs));
81
92
 
82
93
  VALUE ret = rb_ary_new();
83
94
 
84
95
  while (list) {
85
- rb_ary_push(ret, BOXED2RVAL(list->data, PANGO_TYPE_GLYPH_ITEM));
96
+ rb_ary_push(ret, PANGOGLYPHITEM2RVAL(list->data));
86
97
  pango_glyph_item_free(list->data);
87
98
  list = list->next;
88
99
  }
89
-
100
+
90
101
  g_slist_free(list);
91
102
  return ret;
92
103
  }
93
104
 
94
105
  #if PANGO_CHECK_VERSION(1,6,0)
95
106
  static VALUE
96
- glyph_item_letter_space(VALUE self, VALUE text, VALUE log_attrs, VALUE letter_spacing)
107
+ rg_letter_space(VALUE self, VALUE text, VALUE log_attrs, VALUE letter_spacing)
97
108
  {
98
109
  pango_glyph_item_letter_space(_SELF(self), RVAL2CSTR(text),
99
- (PangoLogAttr*)RVAL2BOXED(log_attrs, PANGO_TYPE_LOG_ATTR),
110
+ RVAL2PANGOLOGATTR(log_attrs),
100
111
  NUM2INT(letter_spacing));
101
112
  return self;
102
113
  }
@@ -104,20 +115,19 @@ glyph_item_letter_space(VALUE self, VALUE text, VALUE log_attrs, VALUE letter_sp
104
115
  #endif
105
116
 
106
117
  void
107
- Init_pango_glyph_item()
118
+ Init_pango_glyph_item(VALUE mPango)
108
119
  {
109
120
  #if PANGO_CHECK_VERSION(1,2,0)
110
- VALUE pItem = G_DEF_CLASS(PANGO_TYPE_GLYPH_ITEM, "GlyphItem", mPango);
121
+ VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(PANGO_TYPE_GLYPH_ITEM, "GlyphItem", mPango);
111
122
 
112
- rb_define_method(pItem, "item", glyph_item_get_item, 0);
113
- rb_define_method(pItem, "glyphs", glyph_item_get_glyphs, 0);
123
+ RG_DEF_METHOD(item, 0);
124
+ RG_DEF_METHOD(glyphs, 0);
114
125
 
115
- rb_define_method(pItem, "split", glyph_item_split, 2);
116
- rb_define_method(pItem, "appy_attrs", glyph_item_apply_attrs, 2);
126
+ RG_DEF_METHOD(split, 2);
127
+ RG_DEF_METHOD(appy_attrs, 2);
117
128
 
118
129
  #if PANGO_CHECK_VERSION(1,6,0)
119
- rb_define_method(pItem, "letter_space", glyph_item_letter_space, 3);
130
+ RG_DEF_METHOD(letter_space, 3);
120
131
  #endif
121
132
  #endif
122
133
  }
123
-
@@ -1,34 +1,45 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
- /************************************************
3
-
4
- rbpangoglyphstring.c -
5
-
6
- $Author: ggc $
7
- $Date: 2007/07/13 16:07:33 $
8
-
9
- Copyright (C) 2002-2006 Masao Mutoh
10
- ************************************************/
11
-
12
- #include "rbpango.h"
13
-
14
- #define _SELF(self) ((PangoGlyphString*)(RVAL2BOXED(self, PANGO_TYPE_GLYPH_STRING)))
2
+ /*
3
+ * Copyright (C) 2011 Ruby-GNOME2 Project Team
4
+ * Copyright (C) 2002-2006 Masao Mutoh
5
+ *
6
+ * This library is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU Lesser General Public
8
+ * License as published by the Free Software Foundation; either
9
+ * version 2.1 of the License, or (at your option) any later version.
10
+ *
11
+ * This library is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with this library; if not, write to the Free Software
18
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
+ * MA 02110-1301 USA
20
+ */
21
+
22
+ #include "rbpangoprivate.h"
23
+
24
+ #define RG_TARGET_NAMESPACE cGlyphString
25
+ #define _SELF(self) (RVAL2PANGOGLYPHSTRING(self))
15
26
 
16
27
  static VALUE
17
- rglyph_initialize(VALUE self)
28
+ rg_initialize(VALUE self)
18
29
  {
19
30
  G_INITIALIZE(self, pango_glyph_string_new());
20
31
  return Qnil;
21
32
  }
22
33
 
23
34
  static VALUE
24
- rglyph_set_size(VALUE self, VALUE len)
35
+ rg_set_size(VALUE self, VALUE len)
25
36
  {
26
37
  pango_glyph_string_set_size(_SELF(self), NUM2INT(len));
27
38
  return self;
28
39
  }
29
40
 
30
41
  static VALUE
31
- rglyph_extents(int argc, VALUE *argv, VALUE self)
42
+ rg_extents(int argc, VALUE *argv, VALUE self)
32
43
  {
33
44
  VALUE font, start_index, end_index;
34
45
  PangoRectangle ink_rect;
@@ -38,29 +49,29 @@ rglyph_extents(int argc, VALUE *argv, VALUE self)
38
49
 
39
50
  if (NIL_P(start_index)){
40
51
  pango_glyph_string_extents(_SELF(self),
41
- PANGO_FONT(RVAL2GOBJ(font)),
52
+ RVAL2PANGOFONT(font),
42
53
  &ink_rect, &logical_rect);
43
54
  } else {
44
55
  pango_glyph_string_extents_range(_SELF(self),
45
56
  NUM2INT(start_index), NUM2INT(end_index),
46
- PANGO_FONT(RVAL2GOBJ(font)),
57
+ RVAL2PANGOFONT(font),
47
58
  &ink_rect, &logical_rect);
48
59
  }
49
60
 
50
- return rb_assoc_new(BOXED2RVAL(&ink_rect, PANGO_TYPE_RECTANGLE),
51
- BOXED2RVAL(&logical_rect, PANGO_TYPE_RECTANGLE));
61
+ return rb_assoc_new(PANGORECTANGLE2RVAL(&ink_rect),
62
+ PANGORECTANGLE2RVAL(&logical_rect));
52
63
  }
53
64
 
54
65
  #if PANGO_CHECK_VERSION(1,14,0)
55
66
  static VALUE
56
- rglyph_get_width(VALUE self)
67
+ rg_width(VALUE self)
57
68
  {
58
69
  return INT2NUM(pango_glyph_string_get_width(_SELF(self)));
59
70
  }
60
71
  #endif
61
72
 
62
73
  static VALUE
63
- rglyph_index_to_x(VALUE self, VALUE text, VALUE analysis, VALUE index, VALUE trailing)
74
+ rg_index_to_x(VALUE self, VALUE text, VALUE analysis, VALUE index, VALUE trailing)
64
75
  {
65
76
  int x_pos;
66
77
  StringValue(text);
@@ -70,14 +81,14 @@ rglyph_index_to_x(VALUE self, VALUE text, VALUE analysis, VALUE index, VALUE tra
70
81
  * pango_glyph_string_index_to_x */
71
82
  (char *)RSTRING_PTR(text),
72
83
  RSTRING_LEN(text),
73
- (PangoAnalysis*)RVAL2BOXED(analysis, PANGO_TYPE_ANALYSIS),
84
+ RVAL2PANGOANALYSIS(analysis),
74
85
  NUM2INT(index), RVAL2CBOOL(trailing),
75
86
  &x_pos);
76
87
  return INT2NUM(x_pos);
77
88
  }
78
89
 
79
90
  static VALUE
80
- rglyph_x_to_index(VALUE self, VALUE text, VALUE analysis, VALUE x_pos)
91
+ rg_x_to_index(VALUE self, VALUE text, VALUE analysis, VALUE x_pos)
81
92
  {
82
93
  int index;
83
94
  int trailing;
@@ -88,41 +99,30 @@ rglyph_x_to_index(VALUE self, VALUE text, VALUE analysis, VALUE x_pos)
88
99
  * pango_glyph_string_index_to_x */
89
100
  (char *)RSTRING_PTR(text),
90
101
  RSTRING_LEN(text),
91
- (PangoAnalysis*)RVAL2BOXED(analysis, PANGO_TYPE_ANALYSIS),
102
+ RVAL2PANGOANALYSIS(analysis),
92
103
  NUM2INT(x_pos),
93
104
  &index, &trailing);
94
105
  return rb_assoc_new(INT2NUM(index), CBOOL2RVAL(trailing));
95
106
  }
96
107
 
97
108
  static VALUE
98
- rglyph_get_logical_widgths(VALUE self, VALUE text, VALUE embedding_level)
109
+ rg_get_logical_widths(VALUE self, VALUE rbtext, VALUE rbembedding_level)
99
110
  {
100
- int *logical_widths = NULL;
101
- int len, array_len, i;
102
- const char *gtext;
103
- VALUE ret;
104
-
105
- gtext = RVAL2CSTR(text);
106
- len = RSTRING_LEN(text);
107
-
108
- array_len = g_utf8_strlen(gtext, len);
109
-
110
- logical_widths = g_new(PangoGlyphUnit, array_len);
111
-
112
- pango_glyph_string_get_logical_widths(_SELF(self), gtext, len,
113
- NUM2INT(embedding_level),
111
+ PangoGlyphString *glyphs = _SELF(self);
112
+ const char *text = RVAL2CSTR(rbtext);
113
+ long length = RSTRING_LEN(rbtext);
114
+ int embedding_level = NUM2INT(rbembedding_level);
115
+ glong n = g_utf8_strlen(text, length);
116
+ int *logical_widths = g_new(int, n);
117
+
118
+ pango_glyph_string_get_logical_widths(glyphs, text, length, embedding_level,
114
119
  logical_widths);
115
120
 
116
- ret = rb_ary_new();
117
- for (i = 0; i < array_len; i++){
118
- rb_ary_push(ret, INT2NUM(logical_widths[i]));
119
- }
120
-
121
- return ret;
121
+ return GINTS2RVAL_FREE(logical_widths, n);
122
122
  }
123
123
 
124
124
  static VALUE
125
- rglyph_get_glyphs(VALUE self)
125
+ rg_glyphs(VALUE self)
126
126
  {
127
127
  int i;
128
128
  PangoGlyphInfo** glyphs = &_SELF(self)->glyphs;
@@ -131,27 +131,27 @@ rglyph_get_glyphs(VALUE self)
131
131
  VALUE ret = rb_ary_new();
132
132
  for (i = 0; i < _SELF(self)->num_glyphs; i++) {
133
133
  rb_ary_push(ret,
134
- rb_assoc_new(BOXED2RVAL(glyphs[i], PANGO_TYPE_GLYPH_INFO),
134
+ rb_assoc_new(PANGOGLYPHINFO2RVAL(glyphs[i]),
135
135
  INT2NUM(log_clusters[i])));
136
136
  }
137
137
  return ret;
138
138
  }
139
139
 
140
140
  void
141
- Init_pango_glyph_string()
141
+ Init_pango_glyph_string(VALUE mPango)
142
142
  {
143
- VALUE pGlyph = G_DEF_CLASS(PANGO_TYPE_GLYPH_STRING, "GlyphString", mPango);
143
+ VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(PANGO_TYPE_GLYPH_STRING, "GlyphString", mPango);
144
144
 
145
- rb_define_method(pGlyph, "initialize", rglyph_initialize, 0);
146
- rb_define_method(pGlyph, "set_size", rglyph_set_size, 1);
147
- rb_define_method(pGlyph, "extents", rglyph_extents, -1);
145
+ RG_DEF_METHOD(initialize, 0);
146
+ RG_DEF_METHOD(set_size, 1);
147
+ RG_DEF_METHOD(extents, -1);
148
148
  #if PANGO_CHECK_VERSION(1,14,0)
149
- rb_define_method(pGlyph, "width", rglyph_get_width, 0);
149
+ RG_DEF_METHOD(width, 0);
150
150
  #endif
151
- rb_define_method(pGlyph, "index_to_x", rglyph_index_to_x, 4);
152
- rb_define_method(pGlyph, "x_to_index", rglyph_x_to_index, 3);
153
- rb_define_method(pGlyph, "get_logical_widths", rglyph_get_logical_widgths, 2);
154
- rb_define_method(pGlyph, "glyphs", rglyph_get_glyphs, 0);
151
+ RG_DEF_METHOD(index_to_x, 4);
152
+ RG_DEF_METHOD(x_to_index, 3);
153
+ RG_DEF_METHOD(get_logical_widths, 2);
154
+ RG_DEF_METHOD(glyphs, 0);
155
155
 
156
- G_DEF_SETTERS(pGlyph);
156
+ G_DEF_SETTERS(RG_TARGET_NAMESPACE);
157
157
  }