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,71 @@
1
+ extern void Init_pango_analysis();
2
+ extern void Init_pango_attribute();
3
+ extern void Init_pango_attriterator();
4
+ extern void Init_pango_attrlist();
5
+ extern void Init_pango_cairo();
6
+ extern void Init_pango_color();
7
+ extern void Init_pango_context();
8
+ extern void Init_pango_coverage();
9
+ extern void Init_pango_engine();
10
+ extern void Init_pango_font();
11
+ extern void Init_pango_font_description();
12
+ extern void Init_pango_font_face();
13
+ extern void Init_pango_font_family();
14
+ extern void Init_pango_font_map();
15
+ extern void Init_pango_font_metrics();
16
+ extern void Init_pango_fontset();
17
+ extern void Init_pango_fontset_simple();
18
+ extern void Init_pango_glyph_info();
19
+ extern void Init_pango_glyph_item();
20
+ extern void Init_pango_glyph_string();
21
+ extern void Init_pango_gravity();
22
+ extern void Init_pango_item();
23
+ extern void Init_pango_language();
24
+ extern void Init_pango_layout();
25
+ extern void Init_pango_layout_iter();
26
+ extern void Init_pango_layout_line();
27
+ extern void Init_pango_logattr();
28
+ extern void Init_pango_main();
29
+ extern void Init_pango_matrix();
30
+ extern void Init_pango_rectangle();
31
+ extern void Init_pangorenderer();
32
+ extern void Init_pango_script();
33
+ extern void Init_pango_script_iter();
34
+ extern void Init_pango_array();
35
+ void Init_pango_inits()
36
+ {
37
+ Init_pango_analysis();
38
+ Init_pango_attribute();
39
+ Init_pango_attriterator();
40
+ Init_pango_attrlist();
41
+ Init_pango_cairo();
42
+ Init_pango_color();
43
+ Init_pango_context();
44
+ Init_pango_coverage();
45
+ Init_pango_engine();
46
+ Init_pango_font();
47
+ Init_pango_font_description();
48
+ Init_pango_font_face();
49
+ Init_pango_font_family();
50
+ Init_pango_font_map();
51
+ Init_pango_font_metrics();
52
+ Init_pango_fontset();
53
+ Init_pango_fontset_simple();
54
+ Init_pango_glyph_info();
55
+ Init_pango_glyph_item();
56
+ Init_pango_glyph_string();
57
+ Init_pango_gravity();
58
+ Init_pango_item();
59
+ Init_pango_language();
60
+ Init_pango_layout();
61
+ Init_pango_layout_iter();
62
+ Init_pango_layout_line();
63
+ Init_pango_logattr();
64
+ Init_pango_main();
65
+ Init_pango_matrix();
66
+ Init_pango_rectangle();
67
+ Init_pangorenderer();
68
+ Init_pango_script();
69
+ Init_pango_script_iter();
70
+ Init_pango_array();
71
+ }
data/src/rbpangoitem.c ADDED
@@ -0,0 +1,110 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbpangoitem.c -
5
+
6
+ $Author: mutoh $
7
+ $Date: 2005/09/17 18:30:05 $
8
+
9
+ Copyright (C) 2002-2005 Masao Mutoh
10
+ ************************************************/
11
+
12
+ #include "rbpango.h"
13
+
14
+ #define _SELF(self) ((PangoItem*)RVAL2BOXED(self, PANGO_TYPE_ITEM))
15
+
16
+ #define ATTR_INT(name)\
17
+ static VALUE \
18
+ item_int_ ## name (self)\
19
+ VALUE self;\
20
+ {\
21
+ return INT2NUM(_SELF(self)->name);\
22
+ }\
23
+ static VALUE \
24
+ item_int_set_ ## name (self, val)\
25
+ VALUE self, val;\
26
+ {\
27
+ _SELF(self)->name = NUM2INT(val); \
28
+ return self;\
29
+ }
30
+
31
+ #define DEF_INT_ACCESSOR(name) \
32
+ rb_define_method(pItem, G_STRINGIFY(name), item_int_ ## name, 0);\
33
+ rb_define_method(pItem, G_STRINGIFY(set_ ## name), item_int_set_ ## name, 1);
34
+
35
+ /**********************************/
36
+ #if ! PANGO_CHECK_VERSION(1,9,0)
37
+ GType
38
+ pango_item_get_type(void)
39
+ {
40
+ static GType our_type = 0;
41
+
42
+ if (our_type == 0)
43
+ our_type = g_boxed_type_register_static ("PangoItem",
44
+ (GBoxedCopyFunc)pango_item_copy,
45
+ (GBoxedFreeFunc)pango_item_free);
46
+ return our_type;
47
+ }
48
+ #endif
49
+ /**********************************/
50
+
51
+ static VALUE
52
+ item_initialize(self)
53
+ VALUE self;
54
+ {
55
+ G_INITIALIZE(self, pango_item_new());
56
+ return Qnil;
57
+ }
58
+
59
+ static VALUE
60
+ item_split(self, split_index, split_offset)
61
+ VALUE self, split_index, split_offset;
62
+ {
63
+ return BOXED2RVAL(pango_item_split(_SELF(self),
64
+ NUM2INT(split_index),
65
+ NUM2INT(split_offset)),
66
+ PANGO_TYPE_ITEM);
67
+ }
68
+ /* Move to Pango module (rbpangomain.c)
69
+ GList* pango_reorder_items (GList *logical_items);
70
+ */
71
+
72
+ ATTR_INT(offset);
73
+ ATTR_INT(length);
74
+ ATTR_INT(num_chars);
75
+
76
+
77
+ static VALUE
78
+ item_get_analysis(self)
79
+ VALUE self;
80
+ {
81
+ PangoAnalysis ana = _SELF(self)->analysis;
82
+ return BOXED2RVAL(&ana, PANGO_TYPE_ANALYSIS);
83
+ }
84
+
85
+ static VALUE
86
+ item_set_analysis(self, val)
87
+ VALUE self, val;
88
+ {
89
+ PangoAnalysis* ana = (PangoAnalysis*)RVAL2BOXED(val, PANGO_TYPE_ANALYSIS);
90
+ _SELF(self)->analysis = *ana;
91
+ return self;
92
+ }
93
+
94
+ void
95
+ Init_pango_item()
96
+ {
97
+ VALUE pItem = G_DEF_CLASS(PANGO_TYPE_ITEM, "Item", mPango);
98
+
99
+ rb_define_method(pItem, "initialize", item_initialize, 0);
100
+ rb_define_method(pItem, "split", item_split, 2);
101
+
102
+ DEF_INT_ACCESSOR(offset);
103
+ DEF_INT_ACCESSOR(length);
104
+ DEF_INT_ACCESSOR(num_chars);
105
+
106
+ rb_define_method(pItem, "analysis", item_get_analysis, 0);
107
+ rb_define_method(pItem, "set_analysis", item_set_analysis, 1);
108
+
109
+ G_DEF_SETTERS(pItem);
110
+ }
@@ -0,0 +1,88 @@
1
+ /* -*- c-file-style: "ruby" -*- */
2
+ /************************************************
3
+
4
+ rbpangolanguage.c -
5
+
6
+ $Author: mutoh $
7
+ $Date: 2005/09/17 17:09:13 $
8
+
9
+ Copyright (C) 2009 Ruby-GNOME2 Project Team
10
+ Copyright (C) 2002,2003 Masao Mutoh <mutoh@highway.ne.jp>
11
+ ************************************************/
12
+
13
+ #include "rbpango.h"
14
+
15
+ #define _SELF(self) ((PangoLanguage*)RVAL2BOXED(self, PANGO_TYPE_LANGUAGE))
16
+ #define LANG2RVAL(lang) (BOXED2RVAL(lang, PANGO_TYPE_LANGUAGE))
17
+
18
+ static VALUE
19
+ language_s_default(VALUE self)
20
+ {
21
+ return LANG2RVAL(pango_language_get_default());
22
+ }
23
+
24
+ static VALUE
25
+ language_initialize(self, language)
26
+ VALUE self, language;
27
+ {
28
+ G_INITIALIZE(self, pango_language_from_string(RVAL2CSTR(language)));
29
+ return Qnil;
30
+ }
31
+
32
+ static VALUE
33
+ language_s_to_string(self, language)
34
+ VALUE self, language;
35
+ {
36
+ return CSTR2RVAL(pango_language_to_string(RVAL2CSTR(language)));
37
+ }
38
+
39
+ static VALUE
40
+ language_matches(argc, argv, self)
41
+ int argc;
42
+ VALUE *argv;
43
+ VALUE self;
44
+ {
45
+ VALUE range_list;
46
+
47
+ rb_scan_args(argc, argv, "01", &range_list);
48
+
49
+ return CBOOL2RVAL(pango_language_matches(_SELF(self),
50
+ NIL_P(range_list) ? NULL : RVAL2CSTR(range_list)));
51
+ }
52
+
53
+ static VALUE
54
+ language_to_str(self)
55
+ VALUE self;
56
+ {
57
+ return CSTR2RVAL(pango_language_to_string(_SELF(self)));
58
+ }
59
+
60
+ #if PANGO_CHECK_VERSION(1,4,0)
61
+ /* Moved from Pango::Script */
62
+ static VALUE
63
+ language_includes_script(self, script)
64
+ VALUE self, script;
65
+ {
66
+ return CBOOL2RVAL(pango_language_includes_script(_SELF(self),
67
+ RVAL2GENUM(script, PANGO_TYPE_SCRIPT)));
68
+ }
69
+ #endif
70
+
71
+ void
72
+ Init_pango_language()
73
+ {
74
+ VALUE pLanguage = G_DEF_CLASS(PANGO_TYPE_LANGUAGE, "Language", mPango);
75
+
76
+ rb_define_singleton_method(pLanguage, "default", language_s_default, 0);
77
+
78
+ rb_define_method(pLanguage, "initialize", language_initialize, 1);
79
+ rb_define_singleton_method(pLanguage, "to_string", language_s_to_string, 1);
80
+ rb_define_method(pLanguage, "matches", language_matches, -1);
81
+ rb_define_method(pLanguage, "to_str", language_to_str, 0);
82
+ rb_define_alias(pLanguage, "to_s", "to_str");
83
+
84
+ #if PANGO_CHECK_VERSION(1,4,0)
85
+ rb_define_method(pLanguage, "includes_script", language_includes_script, 1);
86
+ #endif
87
+
88
+ }
@@ -0,0 +1,593 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbpangolayout.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
+ #define _SELF(self) (PANGO_LAYOUT(RVAL2GOBJ(self)))
15
+ #define RVAL2CONTEXT(v) (PANGO_CONTEXT(RVAL2GOBJ(v)))
16
+
17
+ static VALUE
18
+ layout_initialize(self, context)
19
+ VALUE self, context;
20
+ {
21
+ G_INITIALIZE(self, pango_layout_new(RVAL2CONTEXT(context)));
22
+ return Qnil;
23
+ }
24
+
25
+ static VALUE
26
+ layout_copy(VALUE self)
27
+ {
28
+ return GOBJ2RVAL_UNREF(pango_layout_copy(_SELF(self)));
29
+ }
30
+
31
+ static VALUE
32
+ layout_get_context(self)
33
+ VALUE self;
34
+ {
35
+ return GOBJ2RVAL(pango_layout_get_context(_SELF(self)));
36
+ }
37
+
38
+ static VALUE
39
+ layout_context_changed(self)
40
+ VALUE self;
41
+ {
42
+ pango_layout_context_changed(_SELF(self));
43
+ return Qnil;
44
+ }
45
+
46
+ static VALUE
47
+ layout_set_text(self, text)
48
+ VALUE self, text;
49
+ {
50
+ pango_layout_set_text(_SELF(self), RVAL2CSTR(text), RSTRING_LEN(text));
51
+ return self;
52
+ }
53
+
54
+ static VALUE
55
+ layout_get_text(self)
56
+ VALUE self;
57
+ {
58
+ return CSTR2RVAL(pango_layout_get_text(_SELF(self)));
59
+ }
60
+
61
+ static VALUE
62
+ layout_set_markup(argc, argv, self)
63
+ int argc;
64
+ VALUE *argv;
65
+ VALUE self;
66
+ {
67
+ VALUE markup, accel_marker;
68
+ gunichar accel_char = 0;
69
+
70
+ rb_scan_args(argc, argv, "11", &markup, &accel_marker);
71
+
72
+ if (NIL_P(accel_marker)){
73
+ pango_layout_set_markup(_SELF(self),
74
+ RVAL2CSTR(markup),
75
+ RSTRING_LEN(markup));
76
+ } else {
77
+ pango_layout_set_markup_with_accel(_SELF(self),
78
+ RVAL2CSTR(markup),
79
+ RSTRING_LEN(markup),
80
+ NUM2CHR(accel_marker), &accel_char);
81
+ }
82
+ return CHR2FIX(accel_char);
83
+ }
84
+
85
+ static VALUE
86
+ layout_set_markup_eq(self, markup)
87
+ VALUE self, markup;
88
+ {
89
+ pango_layout_set_markup(_SELF(self), RVAL2CSTR(markup), RSTRING_LEN(markup));
90
+ return markup;
91
+ }
92
+
93
+ static VALUE
94
+ layout_set_attributes(self, attrs)
95
+ VALUE self, attrs;
96
+ {
97
+ pango_layout_set_attributes(_SELF(self),
98
+ (PangoAttrList*)(RVAL2BOXED(attrs, PANGO_TYPE_ATTR_LIST)));
99
+ return self;
100
+ }
101
+
102
+ static VALUE
103
+ layout_get_attributes(self)
104
+ VALUE self;
105
+ {
106
+ return BOXED2RVAL(pango_layout_get_attributes(_SELF(self)), PANGO_TYPE_ATTR_LIST);
107
+ }
108
+
109
+ static VALUE
110
+ layout_set_font_description(VALUE self, VALUE rb_desc)
111
+ {
112
+ PangoFontDescription *desc;
113
+ gboolean desc_created = FALSE;
114
+
115
+ if (RVAL2CBOOL(rb_obj_is_kind_of(rb_desc, rb_cString))) {
116
+ desc = pango_font_description_from_string(RVAL2CSTR(rb_desc));
117
+ desc_created = TRUE;
118
+ } else {
119
+ desc = RVAL2BOXED(rb_desc, PANGO_TYPE_FONT_DESCRIPTION);
120
+ }
121
+
122
+ pango_layout_set_font_description(_SELF(self), desc);
123
+
124
+ if (desc_created)
125
+ pango_font_description_free(desc);
126
+
127
+ return self;
128
+ }
129
+
130
+ #ifdef HAVE_PANGO_LAYOUT_GET_FONT_DESCRIPTION
131
+ static VALUE
132
+ layout_get_font_description(self)
133
+ VALUE self;
134
+ {
135
+ const PangoFontDescription* desc = pango_layout_get_font_description(_SELF(self));
136
+ return BOXED2RVAL((gpointer)desc, PANGO_TYPE_FONT_DESCRIPTION);
137
+ }
138
+ #endif
139
+
140
+ static VALUE
141
+ layout_set_width(self, width)
142
+ VALUE self, width;
143
+ {
144
+ pango_layout_set_width(_SELF(self), NUM2INT(width));
145
+ return self;
146
+ }
147
+
148
+ static VALUE
149
+ layout_get_width(self)
150
+ VALUE self;
151
+ {
152
+ return INT2NUM(pango_layout_get_width(_SELF(self)));
153
+ }
154
+
155
+ static VALUE
156
+ layout_set_wrap(self, wrap)
157
+ VALUE self, wrap;
158
+ {
159
+ pango_layout_set_wrap(_SELF(self), RVAL2GENUM(wrap, PANGO_TYPE_WRAP_MODE));
160
+ return self;
161
+ }
162
+
163
+ static VALUE
164
+ layout_get_wrap(self)
165
+ VALUE self;
166
+ {
167
+ return GENUM2RVAL(pango_layout_get_wrap(_SELF(self)), PANGO_TYPE_WRAP_MODE);
168
+ }
169
+
170
+ #ifdef HAVE_PANGO_LAYOUT_SET_ELLIPSIZE
171
+ static VALUE
172
+ layout_set_ellipsize(self, ellipsize)
173
+ VALUE self, ellipsize;
174
+ {
175
+ pango_layout_set_ellipsize(_SELF(self), RVAL2GENUM(ellipsize,
176
+ PANGO_TYPE_ELLIPSIZE_MODE));
177
+ return self;
178
+ }
179
+ static VALUE
180
+ layout_get_ellipsize(self)
181
+ VALUE self;
182
+ {
183
+ return GENUM2RVAL(pango_layout_get_ellipsize(_SELF(self)), PANGO_TYPE_ELLIPSIZE_MODE);
184
+ }
185
+ #endif
186
+
187
+ static VALUE
188
+ layout_set_indent(self, indent)
189
+ VALUE self, indent;
190
+ {
191
+ pango_layout_set_indent(_SELF(self), NUM2INT(indent));
192
+ return self;
193
+ }
194
+
195
+ static VALUE
196
+ layout_get_indent(self)
197
+ VALUE self;
198
+ {
199
+ return INT2NUM(pango_layout_get_indent(_SELF(self)));
200
+ }
201
+
202
+ static VALUE
203
+ layout_get_spacing(self)
204
+ VALUE self;
205
+ {
206
+ return INT2NUM(pango_layout_get_spacing(_SELF(self)));
207
+ }
208
+
209
+ static VALUE
210
+ layout_set_spacing(self, spacing)
211
+ VALUE self, spacing;
212
+ {
213
+ pango_layout_set_spacing(_SELF(self), NUM2INT(spacing));
214
+ return self;
215
+ }
216
+
217
+ static VALUE
218
+ layout_set_justify(self, justify)
219
+ VALUE self, justify;
220
+ {
221
+ pango_layout_set_justify(_SELF(self), RVAL2CBOOL(justify));
222
+ return self;
223
+ }
224
+ static VALUE
225
+ layout_get_justify(self)
226
+ VALUE self;
227
+ {
228
+ return CBOOL2RVAL(pango_layout_get_justify(_SELF(self)));
229
+ }
230
+
231
+ #if PANGO_CHECK_VERSION(1,4,0)
232
+ static VALUE
233
+ layout_set_auto_dir(self, auto_dir)
234
+ VALUE self, auto_dir;
235
+ {
236
+ pango_layout_set_auto_dir(_SELF(self), RVAL2CBOOL(auto_dir));
237
+ return self;
238
+ }
239
+ static VALUE
240
+ layout_get_auto_dir(self)
241
+ VALUE self;
242
+ {
243
+ return CBOOL2RVAL(pango_layout_get_auto_dir(_SELF(self)));
244
+ }
245
+ #endif
246
+
247
+ static VALUE
248
+ layout_set_alignment(self, align)
249
+ VALUE self, align;
250
+ {
251
+ pango_layout_set_alignment(_SELF(self), RVAL2GENUM(align, PANGO_TYPE_ALIGNMENT));
252
+ return self;
253
+ }
254
+
255
+ static VALUE
256
+ layout_get_alignment(self)
257
+ VALUE self;
258
+ {
259
+ return GENUM2RVAL(pango_layout_get_alignment(_SELF(self)), PANGO_TYPE_ALIGNMENT);
260
+ }
261
+
262
+ static VALUE
263
+ layout_set_tabs(self, tabs)
264
+ VALUE self,tabs;
265
+ {
266
+ pango_layout_set_tabs(_SELF(self),
267
+ (PangoTabArray*)RVAL2BOXED(self, PANGO_TYPE_TAB_ARRAY));
268
+ return self;
269
+ }
270
+
271
+ static VALUE
272
+ layout_get_tabs(self)
273
+ VALUE self;
274
+ {
275
+ VALUE ret = Qnil;
276
+ PangoTabArray* tabs = pango_layout_get_tabs(_SELF(self));
277
+
278
+ if (tabs) {
279
+ ret = BOXED2RVAL(tabs, PANGO_TYPE_TAB_ARRAY);
280
+ pango_tab_array_free(tabs);
281
+ }
282
+ return ret;
283
+ }
284
+
285
+ static VALUE
286
+ layout_set_single_paragraph_mode(self, setting)
287
+ VALUE self, setting;
288
+ {
289
+ pango_layout_set_single_paragraph_mode(_SELF(self), RVAL2CBOOL(setting));
290
+ return self;
291
+ }
292
+
293
+ static VALUE
294
+ layout_get_single_paragraph_mode(self)
295
+ VALUE self;
296
+ {
297
+ return CBOOL2RVAL(pango_layout_get_single_paragraph_mode(_SELF(self)));
298
+ }
299
+
300
+ static VALUE
301
+ layout_get_log_attrs(self)
302
+ VALUE self;
303
+ {
304
+ PangoLogAttr* attrs;
305
+ gint i, n_attrs;
306
+ VALUE ary;
307
+
308
+ pango_layout_get_log_attrs(_SELF(self), &attrs, &n_attrs);
309
+
310
+ ary = rb_ary_new();
311
+
312
+ for (i = 0; i < n_attrs; i++) {
313
+ rb_ary_assoc(ary, BOXED2RVAL(&attrs[i], PANGO_TYPE_LOG_ATTR));
314
+ }
315
+ g_free(attrs);
316
+
317
+ return ary;
318
+ }
319
+
320
+ static VALUE
321
+ layout_xy_to_index(self, x, y)
322
+ VALUE self, x, y;
323
+ {
324
+ int index, trailing;
325
+ gboolean ret = pango_layout_xy_to_index(_SELF(self),
326
+ NUM2INT(x), NUM2INT(y),
327
+ &index, &trailing);
328
+
329
+ return rb_ary_new3(3, CBOOL2RVAL(ret), INT2NUM(index), INT2NUM(trailing));
330
+ }
331
+
332
+ static VALUE
333
+ layout_index_to_pos(self, index)
334
+ VALUE self, index;
335
+ {
336
+ PangoRectangle pos;
337
+ pango_layout_index_to_pos(_SELF(self), NUM2INT(index), &pos);
338
+ return BOXED2RVAL(&pos, PANGO_TYPE_RECTANGLE);
339
+ }
340
+
341
+ static VALUE
342
+ layout_get_cursor_pos(self, index)
343
+ VALUE self, index;
344
+ {
345
+ PangoRectangle strong_pos, weak_pos;
346
+ pango_layout_get_cursor_pos(_SELF(self), NUM2INT(index), &strong_pos, &weak_pos);
347
+ return rb_ary_new3(2, BOXED2RVAL(&strong_pos, PANGO_TYPE_RECTANGLE),
348
+ BOXED2RVAL(&weak_pos, PANGO_TYPE_RECTANGLE));
349
+ }
350
+
351
+ static VALUE
352
+ layout_move_cursor_visually(self, strong, old_index, old_trailing, direction)
353
+ VALUE self, strong, old_index, old_trailing, direction;
354
+ {
355
+ int new_index, new_trailing;
356
+ pango_layout_move_cursor_visually(_SELF(self), RVAL2CBOOL(strong),
357
+ NUM2INT(old_index), NUM2INT(old_trailing),
358
+ NUM2INT(direction),
359
+ &new_index, &new_trailing);
360
+ return rb_ary_new3(2, INT2NUM(new_index), INT2NUM(new_trailing));
361
+ }
362
+
363
+ static VALUE
364
+ layout_get_extents(argc, argv, self)
365
+ int argc;
366
+ VALUE* argv;
367
+ VALUE self;
368
+ {
369
+ VALUE ink_rect, logical_rect;
370
+ PangoRectangle rink, rlog;
371
+
372
+ rb_scan_args(argc, argv, "02", &ink_rect, &logical_rect);
373
+
374
+ if (NIL_P(ink_rect)){
375
+ rink.x = 0;
376
+ rink.y = 0;
377
+ rink.width = 0;
378
+ rink.height = 0;
379
+ } else {
380
+ PangoRectangle* rect = (PangoRectangle*)RVAL2BOXED(ink_rect, PANGO_TYPE_RECTANGLE);
381
+ rink.x = rect->x;
382
+ rink.y = rect->y;
383
+ rink.width = rect->width;
384
+ rink.height = rect->height;
385
+ }
386
+ if (NIL_P(logical_rect)){
387
+ rlog.x = 0;
388
+ rlog.y = 0;
389
+ rlog.width = 0;
390
+ rlog.height = 0;
391
+ } else {
392
+ PangoRectangle* rect = (PangoRectangle*)RVAL2BOXED(logical_rect, PANGO_TYPE_RECTANGLE);
393
+ rlog.x = rect->x;
394
+ rlog.y = rect->y;
395
+ rlog.width = rect->width;
396
+ rlog.height = rect->height;
397
+ }
398
+
399
+ pango_layout_get_extents(_SELF(self), &rink, &rlog);
400
+
401
+ return rb_assoc_new(BOXED2RVAL(&rink, PANGO_TYPE_RECTANGLE),
402
+ BOXED2RVAL(&rlog, PANGO_TYPE_RECTANGLE));
403
+ }
404
+
405
+ static VALUE
406
+ layout_extents(self)
407
+ VALUE self;
408
+ {
409
+ PangoRectangle rink = {0, 0, 0, 0};
410
+ PangoRectangle rlog = {0, 0, 0, 0};
411
+
412
+ pango_layout_get_extents(_SELF(self), &rink, &rlog);
413
+ return rb_assoc_new(BOXED2RVAL(&rink, PANGO_TYPE_RECTANGLE),
414
+ BOXED2RVAL(&rlog, PANGO_TYPE_RECTANGLE));
415
+ }
416
+
417
+ static VALUE
418
+ layout_get_pixel_extents(argc, argv, self)
419
+ int argc;
420
+ VALUE* argv;
421
+ VALUE self;
422
+ {
423
+ VALUE ink_rect, logical_rect;
424
+ PangoRectangle rink, rlog;
425
+
426
+ rb_scan_args(argc, argv, "02", &ink_rect, &logical_rect);
427
+
428
+ if (NIL_P(ink_rect)){
429
+ rink.x = 0;
430
+ rink.y = 0;
431
+ rink.width = 0;
432
+ rink.height = 0;
433
+ } else {
434
+ PangoRectangle* rect = (PangoRectangle*)RVAL2BOXED(ink_rect, PANGO_TYPE_RECTANGLE);
435
+ rink.x = rect->x;
436
+ rink.y = rect->y;
437
+ rink.width = rect->width;
438
+ rink.height = rect->height;
439
+ }
440
+ if (NIL_P(logical_rect)){
441
+ rlog.x = 0;
442
+ rlog.y = 0;
443
+ rlog.width = 0;
444
+ rlog.height = 0;
445
+ } else {
446
+ PangoRectangle* rect = (PangoRectangle*)RVAL2BOXED(logical_rect, PANGO_TYPE_RECTANGLE);
447
+ rlog.x = rect->x;
448
+ rlog.y = rect->y;
449
+ rlog.width = rect->width;
450
+ rlog.height = rect->height;
451
+ }
452
+
453
+ pango_layout_get_pixel_extents(_SELF(self), &rink, &rlog);
454
+
455
+ return rb_assoc_new(BOXED2RVAL(&rink, PANGO_TYPE_RECTANGLE),
456
+ BOXED2RVAL(&rlog, PANGO_TYPE_RECTANGLE));
457
+ }
458
+
459
+ static VALUE
460
+ layout_pixel_extents(self)
461
+ VALUE self;
462
+ {
463
+ PangoRectangle rink = {0, 0, 0, 0};
464
+ PangoRectangle rlog = {0, 0, 0, 0};
465
+
466
+ pango_layout_get_pixel_extents(_SELF(self), &rink, &rlog);
467
+ return rb_assoc_new(BOXED2RVAL(&rink, PANGO_TYPE_RECTANGLE),
468
+ BOXED2RVAL(&rlog, PANGO_TYPE_RECTANGLE));
469
+ }
470
+
471
+ static VALUE
472
+ layout_get_size(self)
473
+ VALUE self;
474
+ {
475
+ int width, height;
476
+ pango_layout_get_size(_SELF(self), &width, &height);
477
+ return rb_ary_new3(2, INT2NUM(width), INT2NUM(height));
478
+ }
479
+
480
+ static VALUE
481
+ layout_get_pixel_size(self)
482
+ VALUE self;
483
+ {
484
+ int width, height;
485
+ pango_layout_get_pixel_size(_SELF(self), &width, &height);
486
+ return rb_ary_new3(2, INT2NUM(width), INT2NUM(height));
487
+ }
488
+
489
+ static VALUE
490
+ layout_get_line_count(self)
491
+ VALUE self;
492
+ {
493
+ return INT2NUM(pango_layout_get_line_count(_SELF(self)));
494
+ }
495
+
496
+ static VALUE
497
+ layout_get_line(self, line)
498
+ VALUE self, line;
499
+ {
500
+ return BOXED2RVAL(pango_layout_get_line(_SELF(self), NUM2INT(line)), PANGO_TYPE_LAYOUT_LINE);
501
+ }
502
+
503
+ static VALUE
504
+ layout_get_lines(self)
505
+ VALUE self;
506
+ {
507
+ return GSLIST2ARY2(pango_layout_get_lines(_SELF(self)), PANGO_TYPE_LAYOUT_LINE);
508
+ }
509
+
510
+
511
+ static VALUE
512
+ layout_get_iter(self)
513
+ VALUE self;
514
+ {
515
+ return BOXED2RVAL(pango_layout_get_iter(_SELF(self)),
516
+ PANGO_TYPE_LAYOUT_ITER);
517
+ }
518
+
519
+ void
520
+ Init_pango_layout()
521
+ {
522
+ VALUE pLayout = G_DEF_CLASS(PANGO_TYPE_LAYOUT, "Layout", mPango);
523
+
524
+ rb_define_method(pLayout, "initialize", layout_initialize, 1);
525
+ rb_define_method(pLayout, "copy", layout_copy, 0);
526
+ rb_define_method(pLayout, "context", layout_get_context, 0);
527
+ rb_define_method(pLayout, "context_changed", layout_context_changed, 0);
528
+ rb_define_method(pLayout, "set_text", layout_set_text, 1);
529
+ rb_define_method(pLayout, "text", layout_get_text, 0);
530
+ rb_define_method(pLayout, "set_markup", layout_set_markup, -1);
531
+ rb_define_method(pLayout, "markup=", layout_set_markup_eq, 1);
532
+ rb_define_method(pLayout, "set_attributes", layout_set_attributes, 1);
533
+ rb_define_method(pLayout, "attributes", layout_get_attributes, 0);
534
+ rb_define_method(pLayout, "set_font_description", layout_set_font_description, 1);
535
+ #ifdef HAVE_PANGO_LAYOUT_GET_FONT_DESCRIPTION
536
+ rb_define_method(pLayout, "font_description", layout_get_font_description, 0);
537
+ #endif
538
+ rb_define_method(pLayout, "set_width", layout_set_width, 1);
539
+ rb_define_method(pLayout, "width", layout_get_width, 0);
540
+ rb_define_method(pLayout, "set_wrap", layout_set_wrap, 1);
541
+ rb_define_method(pLayout, "wrap", layout_get_wrap, 0);
542
+ #ifdef HAVE_PANGO_LAYOUT_SET_ELLIPSIZE
543
+ rb_define_method(pLayout, "set_ellipsize", layout_set_ellipsize, 1);
544
+ rb_define_method(pLayout, "ellipsize", layout_get_ellipsize, 0);
545
+ #endif
546
+ rb_define_method(pLayout, "set_indent", layout_set_indent, 1);
547
+ rb_define_method(pLayout, "indent", layout_get_indent, 0);
548
+ rb_define_method(pLayout, "spacing", layout_get_spacing, 0);
549
+ rb_define_method(pLayout, "set_spacing", layout_set_spacing, 1);
550
+ rb_define_method(pLayout, "set_justify", layout_set_justify, 1);
551
+ rb_define_method(pLayout, "justify?", layout_get_justify, 0);
552
+ #if PANGO_CHECK_VERSION(1,4,0)
553
+ rb_define_method(pLayout, "set_auto_dir", layout_set_auto_dir, 1);
554
+ rb_define_method(pLayout, "auto_dir?", layout_get_auto_dir, 0);
555
+ #endif
556
+ rb_define_method(pLayout, "set_alignment", layout_set_alignment, 1);
557
+ rb_define_method(pLayout, "alignment", layout_get_alignment, 0);
558
+ rb_define_method(pLayout, "set_tabs", layout_set_tabs, 1);
559
+ rb_define_method(pLayout, "tabs", layout_get_tabs, 0);
560
+ rb_define_method(pLayout, "set_single_paragraph_mode", layout_set_single_paragraph_mode, 1);
561
+ rb_define_method(pLayout, "single_paragraph_mode?", layout_get_single_paragraph_mode, 0);
562
+ rb_define_method(pLayout, "log_attrs", layout_get_log_attrs, 0);
563
+ rb_define_method(pLayout, "xy_to_index", layout_xy_to_index, 2);
564
+ rb_define_method(pLayout, "index_to_pos", layout_index_to_pos, 1);
565
+ rb_define_method(pLayout, "get_cursor_pos", layout_get_cursor_pos, 1);
566
+ rb_define_method(pLayout, "move_cursor_visually", layout_move_cursor_visually, 4);
567
+ rb_define_method(pLayout, "get_extents", layout_get_extents, -1);
568
+ rb_define_method(pLayout, "extents", layout_extents, 0);
569
+ rb_define_method(pLayout, "get_pixel_extents", layout_get_pixel_extents, -1);
570
+ rb_define_method(pLayout, "pixel_extents", layout_pixel_extents, 0);
571
+ rb_define_method(pLayout, "size", layout_get_size, 0);
572
+ rb_define_method(pLayout, "pixel_size", layout_get_pixel_size, 0);
573
+ rb_define_method(pLayout, "line_count", layout_get_line_count, 0);
574
+ rb_define_method(pLayout, "get_line", layout_get_line, 1);
575
+ rb_define_method(pLayout, "lines", layout_get_lines, 0);
576
+ rb_define_method(pLayout, "iter", layout_get_iter, 0);
577
+
578
+ G_DEF_SETTERS(pLayout);
579
+
580
+ /* PangoWrapMode */
581
+ G_DEF_CLASS(PANGO_TYPE_WRAP_MODE, "WrapMode", pLayout);
582
+ G_DEF_CONSTANTS(pLayout, PANGO_TYPE_WRAP_MODE, "PANGO_");
583
+
584
+ /* PangoAlignment */
585
+ G_DEF_CLASS(PANGO_TYPE_ALIGNMENT, "Alignment", pLayout);
586
+ G_DEF_CONSTANTS(pLayout, PANGO_TYPE_ALIGNMENT, "PANGO_");
587
+
588
+ #ifdef HAVE_PANGO_LAYOUT_SET_ELLIPSIZE
589
+ /* PangoEllipsizeMode */
590
+ G_DEF_CLASS(PANGO_TYPE_ELLIPSIZE_MODE, "EllipsizeMode", pLayout);
591
+ G_DEF_CONSTANTS(pLayout, PANGO_TYPE_ELLIPSIZE_MODE, "PANGO_");
592
+ #endif
593
+ }