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,202 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbpangolayoutiter.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
+ #define _SELF(r) ((PangoLayoutIter*)RVAL2BOXED(r, PANGO_TYPE_LAYOUT_ITER))
15
+
16
+ /**********************************/
17
+ #ifndef HAVE_PANGO_LAYOUT_ITER_GET_TYPE
18
+ static PangoLayoutIter*
19
+ layout_iter_copy(ref)
20
+ const PangoLayoutIter* ref;
21
+ {
22
+ #if PANGO_CHECK_VERSION(1,6,0)
23
+ PangoLayoutIter* new_ref;
24
+ g_return_val_if_fail (ref != NULL, NULL);
25
+ /* This may be broken on pango-1.2.x, but
26
+ for backward compatibility. */
27
+ new_ref = g_new(PangoLayoutIter, 1);
28
+ *new_ref = *ref;
29
+ return new_ref;
30
+ #else
31
+ return (PangoLayoutIter*)ref;
32
+ #endif
33
+ }
34
+
35
+ GType
36
+ pango_layout_iter_get_type(void)
37
+ {
38
+ static GType our_type = 0;
39
+
40
+ if (our_type == 0)
41
+ our_type = g_boxed_type_register_static ("PangoLayoutIter",
42
+ (GBoxedCopyFunc)layout_iter_copy,
43
+ (GBoxedFreeFunc)pango_layout_iter_free);
44
+ return our_type;
45
+ }
46
+ #endif
47
+ /**********************************/
48
+
49
+ static VALUE
50
+ layout_iter_next_run(self)
51
+ VALUE self;
52
+ {
53
+ return CBOOL2RVAL(pango_layout_iter_next_run(_SELF(self)));
54
+ }
55
+
56
+ static VALUE
57
+ layout_iter_next_char(self)
58
+ VALUE self;
59
+ {
60
+ return CBOOL2RVAL(pango_layout_iter_next_char(_SELF(self)));
61
+ }
62
+
63
+ static VALUE
64
+ layout_iter_next_cluster(self)
65
+ VALUE self;
66
+ {
67
+ return CBOOL2RVAL(pango_layout_iter_next_cluster(_SELF(self)));
68
+ }
69
+
70
+ static VALUE
71
+ layout_iter_next_line(self)
72
+ VALUE self;
73
+ {
74
+ return CBOOL2RVAL(pango_layout_iter_next_line(_SELF(self)));
75
+ }
76
+
77
+ static VALUE
78
+ layout_iter_at_last_line(self)
79
+ VALUE self;
80
+ {
81
+ return CBOOL2RVAL(pango_layout_iter_at_last_line(_SELF(self)));
82
+ }
83
+
84
+ static VALUE
85
+ layout_iter_get_index(self)
86
+ VALUE self;
87
+ {
88
+ return INT2NUM(pango_layout_iter_get_index(_SELF(self)));
89
+ }
90
+
91
+ static VALUE
92
+ layout_iter_get_baseline(self)
93
+ VALUE self;
94
+ {
95
+ return INT2NUM(pango_layout_iter_get_baseline(_SELF(self)));
96
+ }
97
+
98
+ static VALUE
99
+ layout_iter_get_run(self)
100
+ VALUE self;
101
+ {
102
+ PangoLayoutRun* run = pango_layout_iter_get_run(_SELF(self));
103
+ return BOXED2RVAL(run, PANGO_TYPE_GLYPH_ITEM);
104
+ }
105
+
106
+ static VALUE
107
+ layout_iter_get_line(self)
108
+ VALUE self;
109
+ {
110
+ return BOXED2RVAL(pango_layout_iter_get_line(_SELF(self)), PANGO_TYPE_LAYOUT_LINE);
111
+ }
112
+
113
+ static VALUE
114
+ layout_iter_get_char_extents(self)
115
+ VALUE self;
116
+ {
117
+ PangoRectangle logical_rect;
118
+
119
+ pango_layout_iter_get_char_extents(_SELF(self), &logical_rect);
120
+ return BOXED2RVAL(&logical_rect, PANGO_TYPE_RECTANGLE);
121
+ }
122
+
123
+ static VALUE
124
+ layout_iter_get_cluster_extents(self)
125
+ VALUE self;
126
+ {
127
+ PangoRectangle ink_rect, logical_rect;
128
+
129
+ pango_layout_iter_get_cluster_extents(_SELF(self), &ink_rect, &logical_rect);
130
+
131
+ return rb_assoc_new(BOXED2RVAL(&ink_rect, PANGO_TYPE_RECTANGLE),
132
+ BOXED2RVAL(&logical_rect, PANGO_TYPE_RECTANGLE));
133
+ }
134
+
135
+ static VALUE
136
+ layout_iter_get_run_extents(self)
137
+ VALUE self;
138
+ {
139
+ PangoRectangle ink_rect, logical_rect;
140
+
141
+ pango_layout_iter_get_run_extents(_SELF(self), &ink_rect, &logical_rect);
142
+
143
+ return rb_assoc_new(BOXED2RVAL(&ink_rect, PANGO_TYPE_RECTANGLE),
144
+ BOXED2RVAL(&logical_rect, PANGO_TYPE_RECTANGLE));
145
+ }
146
+
147
+ static VALUE
148
+ layout_iter_get_line_yrange(self)
149
+ VALUE self;
150
+ {
151
+ int y0, y1;
152
+ pango_layout_iter_get_line_yrange(_SELF(self), &y0, &y1);
153
+ return rb_assoc_new(INT2NUM(y0), INT2NUM(y1));
154
+ }
155
+
156
+ static VALUE
157
+ layout_iter_get_line_extents(self)
158
+ VALUE self;
159
+ {
160
+ PangoRectangle ink_rect, logical_rect;
161
+
162
+ pango_layout_iter_get_line_extents(_SELF(self), &ink_rect, &logical_rect);
163
+
164
+ return rb_assoc_new(BOXED2RVAL(&ink_rect, PANGO_TYPE_RECTANGLE),
165
+ BOXED2RVAL(&logical_rect, PANGO_TYPE_RECTANGLE));
166
+ }
167
+ static VALUE
168
+ layout_iter_get_layout_extents(self)
169
+ VALUE self;
170
+ {
171
+ PangoRectangle ink_rect, logical_rect;
172
+
173
+ pango_layout_iter_get_layout_extents(_SELF(self), &ink_rect, &logical_rect);
174
+
175
+ return rb_assoc_new(BOXED2RVAL(&ink_rect, PANGO_TYPE_RECTANGLE),
176
+ BOXED2RVAL(&logical_rect, PANGO_TYPE_RECTANGLE));
177
+ }
178
+
179
+ void
180
+ Init_pango_layout_iter()
181
+ {
182
+ VALUE pIter = G_DEF_CLASS(PANGO_TYPE_LAYOUT_ITER, "LayoutIter", mPango);
183
+
184
+ rbgobj_boxed_not_copy_obj(PANGO_TYPE_LAYOUT_ITER);
185
+
186
+ rb_define_method(pIter, "next_run!", layout_iter_next_run, 0);
187
+ rb_define_method(pIter, "next_char!", layout_iter_next_char, 0);
188
+ rb_define_method(pIter, "next_cluster!", layout_iter_next_cluster, 0);
189
+ rb_define_method(pIter, "next_line!", layout_iter_next_line, 0);
190
+ rb_define_method(pIter, "at_last_line!", layout_iter_at_last_line, 0);
191
+ rb_define_method(pIter, "index", layout_iter_get_index, 0);
192
+ rb_define_method(pIter, "baseline", layout_iter_get_baseline, 0);
193
+ rb_define_method(pIter, "run", layout_iter_get_run, 0);
194
+ rb_define_method(pIter, "line", layout_iter_get_line, 0);
195
+ rb_define_method(pIter, "char_extents", layout_iter_get_char_extents, 0);
196
+ rb_define_method(pIter, "cluster_extents", layout_iter_get_cluster_extents, 0);
197
+ rb_define_method(pIter, "run_extents", layout_iter_get_run_extents, 0);
198
+ rb_define_method(pIter, "line_yrange", layout_iter_get_line_yrange, 0);
199
+ rb_define_method(pIter, "line_extents", layout_iter_get_line_extents, 0);
200
+ rb_define_method(pIter, "layout_extents", layout_iter_get_layout_extents, 0);
201
+
202
+ }
@@ -0,0 +1,256 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbpangolayoutline.c -
5
+
6
+ $Author: ggc $
7
+ $Date: 2007/07/13 16:07:33 $
8
+
9
+ Copyright (C) 2002-2005 Masao Mutoh
10
+ ************************************************/
11
+
12
+ #include "rbpango.h"
13
+
14
+
15
+ #define _SELF(r) ((PangoLayoutLine*)RVAL2BOXED(r, PANGO_TYPE_LAYOUT_LINE))
16
+
17
+ /**********************************/
18
+ #if !PANGO_CHECK_VERSION(1,9,0)
19
+ static PangoLayoutLine*
20
+ layout_line_copy(ref)
21
+ PangoLayoutLine* ref;
22
+ {
23
+ g_return_val_if_fail (ref != NULL, NULL);
24
+ pango_layout_line_ref(ref);
25
+ return ref;
26
+ }
27
+
28
+ GType
29
+ pango_layout_line_get_type(void)
30
+ {
31
+ static GType our_type = 0;
32
+
33
+ if (our_type == 0)
34
+ our_type = g_boxed_type_register_static ("PangoLayoutLine",
35
+ (GBoxedCopyFunc)layout_line_copy,
36
+ (GBoxedFreeFunc)pango_layout_line_unref);
37
+ return our_type;
38
+ }
39
+ #endif
40
+ /**********************************/
41
+
42
+ static VALUE
43
+ layout_line_get_extents(self)
44
+ VALUE self;
45
+ {
46
+ PangoRectangle ink_rect, logical_rect;
47
+
48
+ pango_layout_line_get_extents(_SELF(self), &ink_rect, &logical_rect);
49
+
50
+ return rb_assoc_new(BOXED2RVAL(&ink_rect, PANGO_TYPE_RECTANGLE),
51
+ BOXED2RVAL(&logical_rect, PANGO_TYPE_RECTANGLE));
52
+ }
53
+
54
+ static VALUE
55
+ layout_line_get_pixel_extents(self)
56
+ VALUE self;
57
+ {
58
+ PangoRectangle ink_rect, logical_rect;
59
+
60
+ pango_layout_line_get_pixel_extents(_SELF(self), &ink_rect, &logical_rect);
61
+
62
+ return rb_assoc_new(BOXED2RVAL(&ink_rect, PANGO_TYPE_RECTANGLE),
63
+ BOXED2RVAL(&logical_rect, PANGO_TYPE_RECTANGLE));
64
+ }
65
+
66
+ static VALUE
67
+ layout_line_index_to_x(self, index, trailing)
68
+ VALUE self, index, trailing;
69
+ {
70
+ int x_pos;
71
+ pango_layout_line_index_to_x(_SELF(self), NUM2INT(index),
72
+ RVAL2CBOOL(trailing), &x_pos);
73
+ return INT2NUM(x_pos);
74
+ }
75
+
76
+ static VALUE
77
+ layout_line_x_to_index(self, x_pos)
78
+ VALUE self, x_pos;
79
+ {
80
+ int index, trailing;
81
+
82
+ gboolean ret = pango_layout_line_x_to_index(_SELF(self), NUM2INT(x_pos),
83
+ &index, &trailing);
84
+ return rb_ary_new3(CBOOL2RVAL(ret), INT2NUM(index), INT2NUM(trailing));
85
+ }
86
+
87
+ static VALUE
88
+ layout_line_get_x_ranges(self, start_index, end_index)
89
+ VALUE self, start_index, end_index;
90
+ {
91
+ int* ranges;
92
+ int i, n_ranges;
93
+ VALUE ary;
94
+
95
+ pango_layout_line_get_x_ranges(_SELF(self), NUM2INT(start_index),
96
+ NUM2INT(end_index), &ranges, &n_ranges);
97
+
98
+ ary = rb_ary_new();
99
+ for (i = 0; i < n_ranges; i++) {
100
+ rb_ary_push(ary, INT2NUM(ranges[i]));
101
+ }
102
+
103
+ g_free(ranges);
104
+ return ary;
105
+ }
106
+
107
+ /* Structure members */
108
+ static VALUE
109
+ layout_line_get_layout(self)
110
+ VALUE self;
111
+ {
112
+ return GOBJ2RVAL(_SELF(self)->layout);
113
+ }
114
+
115
+ static VALUE
116
+ layout_line_set_layout(self, val)
117
+ VALUE self, val;
118
+ {
119
+ _SELF(self)->layout = PANGO_LAYOUT(RVAL2GOBJ(val));
120
+ return self;
121
+ }
122
+
123
+ static VALUE
124
+ layout_line_get_start_index(self)
125
+ VALUE self;
126
+ {
127
+ return INT2NUM(_SELF(self)->start_index);
128
+ }
129
+
130
+ static VALUE
131
+ layout_line_set_start_index(self, val)
132
+ VALUE self, val;
133
+ {
134
+ _SELF(self)->start_index = NUM2INT(val);
135
+ return self;
136
+ }
137
+
138
+ static VALUE
139
+ layout_line_get_length(self)
140
+ VALUE self;
141
+ {
142
+ return INT2NUM(_SELF(self)->length);
143
+ }
144
+
145
+ static VALUE
146
+ layout_line_set_length(self, val)
147
+ VALUE self, val;
148
+ {
149
+ _SELF(self)->length = NUM2INT(val);
150
+ return self;
151
+ }
152
+
153
+ #if PANGO_CHECK_VERSION(1,2,0)
154
+ static VALUE
155
+ layout_line_get_runs(self)
156
+ VALUE self;
157
+ {
158
+ GSList* list = _SELF(self)->runs;
159
+ VALUE ary = rb_ary_new();
160
+ while (list) {
161
+ PangoGlyphItem* old_item = (PangoGlyphItem*)list->data;
162
+ PangoGlyphItem new_item;
163
+
164
+ new_item.item = pango_item_copy(old_item->item);
165
+ new_item.glyphs = pango_glyph_string_copy(old_item->glyphs);
166
+
167
+ rb_ary_push(ary, BOXED2RVAL(&new_item, PANGO_TYPE_GLYPH_ITEM));
168
+ list = list->next;
169
+ }
170
+ return ary;
171
+ }
172
+ #endif
173
+
174
+ static VALUE
175
+ layout_line_set_runs(self, ary)
176
+ VALUE self, ary;
177
+ {
178
+ int i, len;
179
+ GSList* list = NULL;
180
+
181
+ len = RARRAY_LEN(ary);
182
+
183
+ for (i = 0; i < len; i++) {
184
+ list = g_slist_append(list, RVAL2BOXED(RARRAY_PTR(ary)[i],
185
+ PANGO_TYPE_GLYPH_ITEM));
186
+ }
187
+
188
+ if (_SELF(self)->runs) {
189
+ g_slist_free(_SELF(self)->runs);
190
+ }
191
+ _SELF(self)->runs = list;
192
+
193
+ return self;
194
+ }
195
+
196
+ #if PANGO_CHECK_VERSION(1,4,0)
197
+ static VALUE
198
+ layout_line_is_paragraph_start(self)
199
+ VALUE self;
200
+ {
201
+ return CBOOL2RVAL(_SELF(self)->is_paragraph_start);
202
+ }
203
+
204
+ static VALUE
205
+ layout_line_set_paragraph_start(self, val)
206
+ VALUE self, val;
207
+ {
208
+ _SELF(self)->is_paragraph_start = RVAL2CBOOL(val);
209
+ return self;
210
+ }
211
+
212
+ static VALUE
213
+ layout_line_get_resolved_dir(self)
214
+ VALUE self;
215
+ {
216
+ return UINT2NUM(_SELF(self)->resolved_dir);
217
+ }
218
+
219
+ static VALUE
220
+ layout_line_set_resolved_dir(self, val)
221
+ VALUE self, val;
222
+ {
223
+ _SELF(self)->resolved_dir = NUM2UINT(val);
224
+ return self;
225
+ }
226
+ #endif
227
+
228
+ void
229
+ Init_pango_layout_line()
230
+ {
231
+ VALUE pLine = G_DEF_CLASS(PANGO_TYPE_LAYOUT_LINE, "LayoutLine", mPango);
232
+
233
+ rb_define_method(pLine, "extents", layout_line_get_extents, 0);
234
+ rb_define_method(pLine, "pixel_extents", layout_line_get_pixel_extents, 0);
235
+ rb_define_method(pLine, "index_to_x", layout_line_index_to_x, 2);
236
+ rb_define_method(pLine, "x_to_index", layout_line_x_to_index, 1);
237
+ rb_define_method(pLine, "get_x_ranges", layout_line_get_x_ranges, 2);
238
+ rb_define_method(pLine, "layout", layout_line_get_layout, 0);
239
+ rb_define_method(pLine, "set_layout", layout_line_set_layout, 1);
240
+ rb_define_method(pLine, "start_index", layout_line_get_start_index, 0);
241
+ rb_define_method(pLine, "set_start_index", layout_line_set_start_index, 1);
242
+ rb_define_method(pLine, "length", layout_line_get_length, 0);
243
+ rb_define_method(pLine, "set_length", layout_line_set_length, 1);
244
+ #if PANGO_CHECK_VERSION(1,2,0)
245
+ rb_define_method(pLine, "runs", layout_line_get_runs, 0);
246
+ #endif
247
+ rb_define_method(pLine, "set_runs", layout_line_set_runs, 1);
248
+
249
+ #if PANGO_CHECK_VERSION(1,4,0)
250
+ rb_define_method(pLine, "paragraph_start?", layout_line_is_paragraph_start, 0);
251
+ rb_define_method(pLine, "set_paragraph_start", layout_line_set_paragraph_start, 1);
252
+ rb_define_method(pLine, "resolved_dir", layout_line_get_resolved_dir, 0);
253
+ rb_define_method(pLine, "set_resolved_dir", layout_line_set_resolved_dir, 1);
254
+ #endif
255
+ G_DEF_SETTERS(pLine);
256
+ }