pango 0.20.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. data/ChangeLog +662 -0
  2. data/README +33 -0
  3. data/Rakefile +86 -0
  4. data/extconf.rb +68 -0
  5. data/sample/attribute.rb +82 -0
  6. data/sample/break.rb +26 -0
  7. data/sample/gdk_layout.rb +27 -0
  8. data/sample/glyphstring.rb +61 -0
  9. data/sample/item.rb +35 -0
  10. data/sample/label.rb +23 -0
  11. data/sample/layout.rb +102 -0
  12. data/sample/pango_cairo.rb +66 -0
  13. data/sample/parse.rb +33 -0
  14. data/sample/sample.txt +10 -0
  15. data/sample/script.rb +21 -0
  16. data/src/lib/pango.rb +60 -0
  17. data/src/makeinits.rb +48 -0
  18. data/src/rbpango.c +27 -0
  19. data/src/rbpango.h +97 -0
  20. data/src/rbpangoanalysis.c +197 -0
  21. data/src/rbpangoattribute.c +557 -0
  22. data/src/rbpangoattriterator.c +137 -0
  23. data/src/rbpangoattrlist.c +104 -0
  24. data/src/rbpangocairo.c +229 -0
  25. data/src/rbpangocolor.c +121 -0
  26. data/src/rbpangocontext.c +341 -0
  27. data/src/rbpangocoverage.c +104 -0
  28. data/src/rbpangoengine.c +65 -0
  29. data/src/rbpangofont.c +123 -0
  30. data/src/rbpangofontdescription.c +300 -0
  31. data/src/rbpangofontface.c +71 -0
  32. data/src/rbpangofontfamily.c +74 -0
  33. data/src/rbpangofontmap.c +104 -0
  34. data/src/rbpangofontmetrics.c +85 -0
  35. data/src/rbpangofontset.c +68 -0
  36. data/src/rbpangofontsetsimple.c +53 -0
  37. data/src/rbpangoglyphinfo.c +119 -0
  38. data/src/rbpangoglyphitem.c +129 -0
  39. data/src/rbpangoglyphstring.c +162 -0
  40. data/src/rbpangogravity.c +43 -0
  41. data/src/rbpangoinits.c +71 -0
  42. data/src/rbpangoitem.c +110 -0
  43. data/src/rbpangolanguage.c +88 -0
  44. data/src/rbpangolayout.c +593 -0
  45. data/src/rbpangolayoutiter.c +202 -0
  46. data/src/rbpangolayoutline.c +256 -0
  47. data/src/rbpangologattr.c +107 -0
  48. data/src/rbpangomain.c +213 -0
  49. data/src/rbpangomatrix.c +155 -0
  50. data/src/rbpangorectangle.c +178 -0
  51. data/src/rbpangorenderer.c +204 -0
  52. data/src/rbpangoscript.c +80 -0
  53. data/src/rbpangoscriptiter.c +91 -0
  54. data/src/rbpangotabarray.c +128 -0
  55. data/src/rbpangoversion.h +24 -0
  56. data/test/pango-test-utils.rb +9 -0
  57. data/test/run-test.rb +27 -0
  58. data/test/test-attribute.rb +19 -0
  59. data/test/test-language.rb +7 -0
  60. data/test/test_layout.rb +20 -0
  61. metadata +158 -0
@@ -0,0 +1,119 @@
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"
13
+
14
+ #define _SELF(self) ((PangoGlyphInfo*)RVAL2BOXED(self, PANGO_TYPE_GLYPH_INFO))
15
+
16
+
17
+ /**********************************/
18
+ PangoGlyphInfo*
19
+ pango_glyph_info_copy (const PangoGlyphInfo* info)
20
+ {
21
+ PangoGlyphInfo* data;
22
+ g_return_val_if_fail (info != NULL, NULL);
23
+ data = g_new(PangoGlyphInfo, 1);
24
+ *data = *info;
25
+ return data;
26
+ }
27
+
28
+ GType
29
+ pango_glyph_info_get_type(void)
30
+ {
31
+ static GType our_type = 0;
32
+
33
+ if (our_type == 0)
34
+ our_type = g_boxed_type_register_static ("PangoGlyphInfo",
35
+ (GBoxedCopyFunc)pango_glyph_info_copy,
36
+ (GBoxedFreeFunc)g_free);
37
+ return our_type;
38
+ }
39
+ /**********************************/
40
+
41
+ static VALUE
42
+ gi_initialize(self)
43
+ VALUE self;
44
+ {
45
+ G_INITIALIZE(self, g_new0(PangoGlyphInfo, 1));
46
+ return Qnil;
47
+ }
48
+
49
+ static VALUE
50
+ gi_glyph(self)
51
+ VALUE self;
52
+ {
53
+ return UINT2NUM(_SELF(self)->glyph);
54
+ }
55
+
56
+ static VALUE
57
+ gi_set_glyph(self, val)
58
+ VALUE self, val;
59
+ {
60
+ _SELF(self)->glyph = NUM2UINT(val);
61
+ return self;
62
+ }
63
+
64
+ static VALUE
65
+ gi_geometry(self)
66
+ VALUE self;
67
+ {
68
+ PangoGlyphGeometry geo = _SELF(self)->geometry;
69
+
70
+ return rb_ary_new3(3, INT2NUM(geo.width),
71
+ INT2NUM(geo.x_offset), INT2NUM(geo.y_offset));
72
+ }
73
+
74
+ static VALUE
75
+ gi_set_geometry(self, width, x_offset, y_offset)
76
+ VALUE self;
77
+ {
78
+ PangoGlyphGeometry geo = _SELF(self)->geometry;
79
+
80
+ geo.width = NUM2INT(width);
81
+ geo.x_offset = NUM2INT(x_offset);
82
+ geo.y_offset = NUM2INT(y_offset);
83
+
84
+ return self;
85
+ }
86
+
87
+ /*
88
+ This method may be changed in the future following Pango implementation.
89
+ */
90
+ static VALUE
91
+ gi_attr_is_cluster_start(self)
92
+ VALUE self;
93
+ {
94
+ return CBOOL2RVAL(_SELF(self)->attr.is_cluster_start);
95
+ }
96
+
97
+ static VALUE
98
+ gi_attr_set_is_cluster_start(self, val)
99
+ VALUE self, val;
100
+ {
101
+ _SELF(self)->attr.is_cluster_start = RVAL2CBOOL(val);
102
+ return self;
103
+ }
104
+
105
+ void
106
+ Init_pango_glyph_info()
107
+ {
108
+ VALUE pInfo = G_DEF_CLASS(PANGO_TYPE_GLYPH_INFO, "GlyphInfo", mPango);
109
+
110
+ rb_define_method(pInfo, "initialize", gi_initialize, 0);
111
+ rb_define_method(pInfo, "glyph", gi_glyph, 0);
112
+ rb_define_method(pInfo, "set_glyph", gi_set_glyph, 1);
113
+ rb_define_method(pInfo, "geometry", gi_geometry, 0);
114
+ rb_define_method(pInfo, "set_geometry", gi_set_geometry, 3);
115
+ rb_define_method(pInfo, "cluster_start?", gi_attr_is_cluster_start, 0);
116
+ rb_define_method(pInfo, "set_cluster_start", gi_attr_set_is_cluster_start, 1);
117
+
118
+ G_DEF_SETTERS(pInfo);
119
+ }
@@ -0,0 +1,129 @@
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"
13
+
14
+ #if PANGO_CHECK_VERSION(1,2,0)
15
+ #define _SELF(r) ((PangoGlyphItem*)RVAL2BOXED(r, PANGO_TYPE_GLYPH_ITEM))
16
+
17
+ /**********************************/
18
+ #ifndef HAVE_PANGO_GLYPH_ITEM_GET_TYPE
19
+ static PangoGlyphItem*
20
+ glyph_item_copy(ref)
21
+ const PangoGlyphItem* ref;
22
+ {
23
+ PangoGlyphItem* new_ref;
24
+ g_return_val_if_fail (ref != NULL, NULL);
25
+ new_ref = g_new(PangoGlyphItem, 1);
26
+ *new_ref = *ref;
27
+ return new_ref;
28
+ }
29
+
30
+ # ifndef HAVE_PANGO_GLYPH_ITEM_FREE
31
+ void
32
+ pango_glyph_item_free(PangoGlyphItem* glyph_item)
33
+ {
34
+ if (glyph_item->item)
35
+ pango_item_free(glyph_item->item);
36
+ if (glyph_item->glyphs)
37
+ pango_glyph_string_free(glyph_item->glyphs);
38
+ g_free(glyph_item);
39
+ }
40
+ # endif
41
+
42
+ GType
43
+ pango_glyph_item_get_type(void)
44
+ {
45
+ static GType our_type = 0;
46
+
47
+ if (our_type == 0)
48
+ our_type = g_boxed_type_register_static ("PangoGlyphItem",
49
+ (GBoxedCopyFunc)glyph_item_copy,
50
+ (GBoxedFreeFunc)pango_glyph_item_free);
51
+ return our_type;
52
+ }
53
+ #endif
54
+ /**********************************/
55
+
56
+ static VALUE
57
+ glyph_item_get_item(self)
58
+ VALUE self;
59
+ {
60
+ PangoItem* item = _SELF(self)->item;
61
+ return BOXED2RVAL(item, PANGO_TYPE_ITEM);
62
+ }
63
+
64
+ static VALUE
65
+ glyph_item_get_glyphs(self)
66
+ VALUE self;
67
+ {
68
+ PangoGlyphString* glyphs = _SELF(self)->glyphs;
69
+ return BOXED2RVAL(glyphs, PANGO_TYPE_GLYPH_STRING);
70
+ }
71
+
72
+ static VALUE
73
+ glyph_item_split(self, text, split_index)
74
+ VALUE self, text, split_index;
75
+ {
76
+ return BOXED2RVAL(pango_glyph_item_split(_SELF(self), RVAL2CSTR(text),
77
+ NUM2INT(split_index)), PANGO_TYPE_GLYPH_ITEM);
78
+ }
79
+
80
+ static VALUE
81
+ glyph_item_apply_attrs(self, text, attrs)
82
+ VALUE self, text, attrs;
83
+ {
84
+ GSList* list = pango_glyph_item_apply_attrs(_SELF(self), RVAL2CSTR(text),
85
+ (PangoAttrList*)RVAL2BOXED(attrs, PANGO_TYPE_ATTR_LIST));
86
+
87
+ VALUE ret = rb_ary_new();
88
+
89
+ while (list) {
90
+ rb_ary_push(ret, BOXED2RVAL(list->data, PANGO_TYPE_GLYPH_ITEM));
91
+ pango_glyph_item_free(list->data);
92
+ list = list->next;
93
+ }
94
+
95
+ g_slist_free(list);
96
+ return ret;
97
+ }
98
+
99
+ #if PANGO_CHECK_VERSION(1,6,0)
100
+ static VALUE
101
+ glyph_item_letter_space(self, text, log_attrs, letter_spacing)
102
+ VALUE self, text, log_attrs, letter_spacing;
103
+ {
104
+ pango_glyph_item_letter_space(_SELF(self), RVAL2CSTR(text),
105
+ (PangoLogAttr*)RVAL2BOXED(log_attrs, PANGO_TYPE_LOG_ATTR),
106
+ NUM2INT(letter_spacing));
107
+ return self;
108
+ }
109
+ #endif
110
+ #endif
111
+
112
+ void
113
+ Init_pango_glyph_item()
114
+ {
115
+ #if PANGO_CHECK_VERSION(1,2,0)
116
+ VALUE pItem = G_DEF_CLASS(PANGO_TYPE_GLYPH_ITEM, "GlyphItem", mPango);
117
+
118
+ rb_define_method(pItem, "item", glyph_item_get_item, 0);
119
+ rb_define_method(pItem, "glyphs", glyph_item_get_glyphs, 0);
120
+
121
+ rb_define_method(pItem, "split", glyph_item_split, 2);
122
+ rb_define_method(pItem, "appy_attrs", glyph_item_apply_attrs, 2);
123
+
124
+ #if PANGO_CHECK_VERSION(1,6,0)
125
+ rb_define_method(pItem, "letter_space", glyph_item_letter_space, 3);
126
+ #endif
127
+ #endif
128
+ }
129
+
@@ -0,0 +1,162 @@
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)))
15
+
16
+ static VALUE
17
+ rglyph_initialize(self)
18
+ VALUE self;
19
+ {
20
+ G_INITIALIZE(self, pango_glyph_string_new());
21
+ return Qnil;
22
+ }
23
+
24
+ static VALUE
25
+ rglyph_set_size(self, len)
26
+ VALUE self, len;
27
+ {
28
+ pango_glyph_string_set_size(_SELF(self), NUM2INT(len));
29
+ return self;
30
+ }
31
+
32
+ static VALUE
33
+ rglyph_extents(argc, argv, self)
34
+ int argc;
35
+ VALUE *argv;
36
+ VALUE self;
37
+ {
38
+ VALUE font, start_index, end_index;
39
+ PangoRectangle ink_rect;
40
+ PangoRectangle logical_rect;
41
+
42
+ rb_scan_args(argc, argv, "12", &font, &start_index, &end_index);
43
+
44
+ if (NIL_P(start_index)){
45
+ pango_glyph_string_extents(_SELF(self),
46
+ PANGO_FONT(RVAL2GOBJ(font)),
47
+ &ink_rect, &logical_rect);
48
+ } else {
49
+ pango_glyph_string_extents_range(_SELF(self),
50
+ NUM2INT(start_index), NUM2INT(end_index),
51
+ PANGO_FONT(RVAL2GOBJ(font)),
52
+ &ink_rect, &logical_rect);
53
+ }
54
+
55
+ return rb_assoc_new(BOXED2RVAL(&ink_rect, PANGO_TYPE_RECTANGLE),
56
+ BOXED2RVAL(&logical_rect, PANGO_TYPE_RECTANGLE));
57
+ }
58
+
59
+ #if PANGO_CHECK_VERSION(1,14,0)
60
+ static VALUE
61
+ rglyph_get_width(self)
62
+ VALUE self;
63
+ {
64
+ return INT2NUM(pango_glyph_string_get_width(_SELF(self)));
65
+ }
66
+ #endif
67
+
68
+ static VALUE
69
+ rglyph_index_to_x(self, text, analysis, index, trailing)
70
+ VALUE self, text, analysis, index, trailing;
71
+ {
72
+ int x_pos;
73
+ StringValue(text);
74
+
75
+ pango_glyph_string_index_to_x(_SELF(self),
76
+ RVAL2CSTR(text),
77
+ RSTRING_LEN(text),
78
+ (PangoAnalysis*)RVAL2BOXED(analysis, PANGO_TYPE_ANALYSIS),
79
+ NUM2INT(index), RVAL2CBOOL(trailing),
80
+ &x_pos);
81
+ return INT2NUM(x_pos);
82
+ }
83
+
84
+ static VALUE
85
+ rglyph_x_to_index(self, text, analysis, x_pos)
86
+ VALUE self, text, analysis, x_pos;
87
+ {
88
+ int index;
89
+ int trailing;
90
+
91
+ StringValue(text);
92
+ pango_glyph_string_x_to_index(_SELF(self),
93
+ RVAL2CSTR(text), RSTRING_LEN(text),
94
+ (PangoAnalysis*)RVAL2BOXED(analysis, PANGO_TYPE_ANALYSIS),
95
+ NUM2INT(x_pos),
96
+ &index, &trailing);
97
+ return rb_assoc_new(INT2NUM(index), CBOOL2RVAL(trailing));
98
+ }
99
+
100
+ static VALUE
101
+ rglyph_get_logical_widgths(self, text, embedding_level)
102
+ VALUE self, text, embedding_level;
103
+ {
104
+ int* logical_widths = NULL;
105
+ int len, array_len, i;
106
+ char* gtext;
107
+ VALUE ret;
108
+
109
+ gtext = RVAL2CSTR(text);
110
+ len = RSTRING_LEN(text);
111
+
112
+ array_len = g_utf8_strlen(gtext, len);
113
+
114
+ logical_widths = g_new(PangoGlyphUnit, array_len);
115
+
116
+ pango_glyph_string_get_logical_widths(_SELF(self), gtext, len,
117
+ NUM2INT(embedding_level),
118
+ logical_widths);
119
+
120
+ ret = rb_ary_new();
121
+ for (i = 0; i < array_len; i++){
122
+ rb_ary_push(ret, INT2NUM(logical_widths[i]));
123
+ }
124
+
125
+ return ret;
126
+ }
127
+
128
+ static VALUE
129
+ rglyph_get_glyphs(self)
130
+ VALUE self;
131
+ {
132
+ int i;
133
+ PangoGlyphInfo** glyphs = &_SELF(self)->glyphs;
134
+ gint* log_clusters = _SELF(self)->log_clusters;
135
+
136
+ VALUE ret = rb_ary_new();
137
+ for (i = 0; i < _SELF(self)->num_glyphs; i++) {
138
+ rb_ary_push(ret,
139
+ rb_assoc_new(BOXED2RVAL(glyphs[i], PANGO_TYPE_GLYPH_INFO),
140
+ INT2NUM(log_clusters[i])));
141
+ }
142
+ return ret;
143
+ }
144
+
145
+ void
146
+ Init_pango_glyph_string()
147
+ {
148
+ VALUE pGlyph = G_DEF_CLASS(PANGO_TYPE_GLYPH_STRING, "GlyphString", mPango);
149
+
150
+ rb_define_method(pGlyph, "initialize", rglyph_initialize, 0);
151
+ rb_define_method(pGlyph, "set_size", rglyph_set_size, 1);
152
+ rb_define_method(pGlyph, "extents", rglyph_extents, -1);
153
+ #if PANGO_CHECK_VERSION(1,14,0)
154
+ rb_define_method(pGlyph, "width", rglyph_get_width, 0);
155
+ #endif
156
+ rb_define_method(pGlyph, "index_to_x", rglyph_index_to_x, 4);
157
+ rb_define_method(pGlyph, "x_to_index", rglyph_x_to_index, 3);
158
+ rb_define_method(pGlyph, "get_logical_widths", rglyph_get_logical_widgths, 2);
159
+ rb_define_method(pGlyph, "glyphs", rglyph_get_glyphs, 0);
160
+
161
+ G_DEF_SETTERS(pGlyph);
162
+ }
@@ -0,0 +1,43 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbpangogravity.c -
5
+
6
+ $Author: ito $
7
+ $Date: 2010/01/17 03:00:50 $
8
+
9
+ ************************************************/
10
+
11
+ #include "rbpango.h"
12
+
13
+
14
+ #if PANGO_CHECK_VERSION(1,16,0)
15
+ static VALUE
16
+ to_rotation(VALUE self, VALUE gravity)
17
+ {
18
+ return rb_float_new(pango_gravity_to_rotation(RVAL2GENUM(gravity, PANGO_TYPE_GRAVITY)));
19
+ }
20
+
21
+ static VALUE
22
+ is_vertical(VALUE self, VALUE gravity)
23
+ {
24
+ return CBOOL2RVAL(PANGO_GRAVITY_IS_VERTICAL(RVAL2GENUM(gravity, PANGO_TYPE_GRAVITY)));
25
+ }
26
+ #endif
27
+
28
+ void
29
+ Init_pango_gravity()
30
+ {
31
+ #if PANGO_CHECK_VERSION(1,16,0)
32
+ VALUE mGravity = rb_define_module_under(mPango, "Gravity");
33
+
34
+ rb_define_singleton_method(mGravity, "to_rotation", to_rotation, 1);
35
+ rb_define_singleton_method(mGravity, "vertical?", is_vertical, 1);
36
+
37
+ G_DEF_CLASS(PANGO_TYPE_GRAVITY, "Gravity", mGravity);
38
+ G_DEF_CONSTANTS(mGravity, PANGO_TYPE_GRAVITY, "PANGO_GRAVITY_");
39
+ G_DEF_CLASS(PANGO_TYPE_GRAVITY_HINT, "Hint", mGravity);
40
+ G_DEF_CONSTANTS(mGravity, PANGO_TYPE_GRAVITY_HINT, "PANGO_GRAVITY_");
41
+ #endif
42
+ }
43
+