pango 3.1.1 → 3.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +27 -5
  3. data/ext/pango/depend +2 -2
  4. data/ext/pango/extconf.rb +32 -28
  5. data/ext/pango/pango.def +0 -16
  6. data/ext/pango/rb-pango-attr-list.c +64 -0
  7. data/ext/pango/rb-pango-attribute.c +147 -0
  8. data/ext/pango/rb-pango-context.c +79 -0
  9. data/ext/pango/{rbpangoconversions.h → rb-pango-conversions.h} +4 -6
  10. data/ext/pango/rb-pango-private.h +27 -0
  11. data/ext/pango/rb-pango.c +32 -0
  12. data/ext/pango/rb-pango.h +29 -0
  13. data/extconf.rb +25 -9
  14. data/lib/pango.rb +24 -68
  15. data/lib/pango/cairo-loader.rb +63 -0
  16. data/lib/pango/color.rb +31 -0
  17. data/lib/pango/deprecated.rb +37 -0
  18. data/lib/pango/font-description.rb +29 -0
  19. data/lib/pango/language.rb +29 -0
  20. data/lib/pango/layout.rb +41 -0
  21. data/lib/pango/loader.rb +87 -0
  22. data/lib/pango/markup.rb +31 -0
  23. data/lib/pango/matrix.rb +64 -0
  24. data/lib/pango/rectangle.rb +28 -0
  25. data/lib/pango/version.rb +30 -0
  26. data/test/pango-test-utils.rb +7 -7
  27. data/test/run-test.rb +34 -8
  28. data/test/test-attr-list.rb +28 -0
  29. data/test/test-color.rb +1 -3
  30. data/test/test-context.rb +4 -4
  31. data/test/test-enum.rb +37 -0
  32. data/test/test-font-description.rb +31 -0
  33. data/test/test-language.rb +2 -1
  34. data/test/test-layout.rb +12 -0
  35. data/test/test-markup.rb +30 -0
  36. data/test/test-matrix.rb +131 -5
  37. data/test/test-rectangle.rb +16 -3
  38. metadata +42 -56
  39. data/README +0 -32
  40. data/ext/pango/rbpango.c +0 -356
  41. data/ext/pango/rbpango.h +0 -95
  42. data/ext/pango/rbpangoanalysis.c +0 -218
  43. data/ext/pango/rbpangoattribute.c +0 -506
  44. data/ext/pango/rbpangoattriterator.c +0 -141
  45. data/ext/pango/rbpangoattrlist.c +0 -101
  46. data/ext/pango/rbpangocairo.c +0 -122
  47. data/ext/pango/rbpangocairocontext.c +0 -131
  48. data/ext/pango/rbpangocolor.c +0 -120
  49. data/ext/pango/rbpangocontext.c +0 -344
  50. data/ext/pango/rbpangocoverage.c +0 -106
  51. data/ext/pango/rbpangoengine.c +0 -73
  52. data/ext/pango/rbpangofont.c +0 -110
  53. data/ext/pango/rbpangofontdescription.c +0 -282
  54. data/ext/pango/rbpangofontface.c +0 -73
  55. data/ext/pango/rbpangofontfamily.c +0 -79
  56. data/ext/pango/rbpangofontmap.c +0 -102
  57. data/ext/pango/rbpangofontmetrics.c +0 -85
  58. data/ext/pango/rbpangofontset.c +0 -69
  59. data/ext/pango/rbpangofontsetsimple.c +0 -60
  60. data/ext/pango/rbpangoglyphinfo.c +0 -123
  61. data/ext/pango/rbpangoglyphitem.c +0 -125
  62. data/ext/pango/rbpangoglyphstring.c +0 -151
  63. data/ext/pango/rbpangogravity.c +0 -54
  64. data/ext/pango/rbpangoitem.c +0 -95
  65. data/ext/pango/rbpangolanguage.c +0 -94
  66. data/ext/pango/rbpangolayout.c +0 -583
  67. data/ext/pango/rbpangolayoutiter.c +0 -189
  68. data/ext/pango/rbpangolayoutline.c +0 -243
  69. data/ext/pango/rbpangologattr.c +0 -109
  70. data/ext/pango/rbpangomatrix.c +0 -143
  71. data/ext/pango/rbpangoprivate.h +0 -49
  72. data/ext/pango/rbpangorectangle.c +0 -170
  73. data/ext/pango/rbpangorenderer.c +0 -193
  74. data/ext/pango/rbpangoscript.c +0 -84
  75. data/ext/pango/rbpangoscriptiter.c +0 -92
  76. data/ext/pango/rbpangotabarray.c +0 -128
  77. data/sample/attribute.rb +0 -82
  78. data/sample/break.rb +0 -28
  79. data/sample/gdk_layout.rb +0 -27
  80. data/sample/glyphstring.rb +0 -61
  81. data/sample/item.rb +0 -37
  82. data/sample/label.rb +0 -23
  83. data/sample/layout.rb +0 -102
  84. data/sample/pango_cairo.rb +0 -66
  85. data/sample/parse.rb +0 -33
  86. data/sample/sample.txt +0 -10
  87. data/sample/script.rb +0 -23
@@ -1,95 +0,0 @@
1
- /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
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"
23
-
24
- #define RG_TARGET_NAMESPACE cItem
25
- #define _SELF(self) (RVAL2PANGOITEM(self))
26
-
27
- #define ATTR_INT(name)\
28
- static VALUE \
29
- item_int_ ## name (VALUE self)\
30
- {\
31
- return INT2NUM(_SELF(self)->name);\
32
- }\
33
- static VALUE \
34
- item_int_set_ ## name (VALUE self, VALUE val)\
35
- {\
36
- _SELF(self)->name = NUM2INT(val); \
37
- return self;\
38
- }
39
-
40
- #define DEF_INT_ACCESSOR(name) \
41
- rbg_define_method(RG_TARGET_NAMESPACE, G_STRINGIFY(name), item_int_ ## name, 0);\
42
- rbg_define_method(RG_TARGET_NAMESPACE, G_STRINGIFY(set_ ## name), item_int_set_ ## name, 1);
43
-
44
- static VALUE
45
- rg_initialize(VALUE self)
46
- {
47
- G_INITIALIZE(self, pango_item_new());
48
- return Qnil;
49
- }
50
-
51
- static VALUE
52
- rg_split(VALUE self, VALUE split_index, VALUE split_offset)
53
- {
54
- return PANGOITEM2RVAL(pango_item_split(_SELF(self),
55
- NUM2INT(split_index),
56
- NUM2INT(split_offset)));
57
- }
58
- /* Move to Pango module (rbpangomain.c)
59
- GList* pango_reorder_items (GList *logical_items);
60
- */
61
-
62
- ATTR_INT(offset);
63
- ATTR_INT(length);
64
- ATTR_INT(num_chars);
65
-
66
- static VALUE
67
- rg_analysis(VALUE self)
68
- {
69
- PangoAnalysis ana = _SELF(self)->analysis;
70
- return PANGOANALYSIS2RVAL(&ana);
71
- }
72
-
73
- static VALUE
74
- rg_set_analysis(VALUE self, VALUE val)
75
- {
76
- PangoAnalysis* ana = RVAL2PANGOANALYSIS(val);
77
- _SELF(self)->analysis = *ana;
78
- return self;
79
- }
80
-
81
- void
82
- Init_pango_item(VALUE mPango)
83
- {
84
- VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(PANGO_TYPE_ITEM, "Item", mPango);
85
-
86
- RG_DEF_METHOD(initialize, 0);
87
- RG_DEF_METHOD(split, 2);
88
-
89
- DEF_INT_ACCESSOR(offset);
90
- DEF_INT_ACCESSOR(length);
91
- DEF_INT_ACCESSOR(num_chars);
92
-
93
- RG_DEF_METHOD(analysis, 0);
94
- RG_DEF_METHOD(set_analysis, 1);
95
- }
@@ -1,94 +0,0 @@
1
- /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
- /*
3
- * Copyright (C) 2011 Ruby-GNOME2 Project Team
4
- * Copyright (C) 2009 Ruby-GNOME2 Project Team
5
- * Copyright (C) 2002,2003 Masao Mutoh <mutoh@highway.ne.jp>
6
- *
7
- * This library is free software; you can redistribute it and/or
8
- * modify it under the terms of the GNU Lesser General Public
9
- * License as published by the Free Software Foundation; either
10
- * version 2.1 of the License, or (at your option) any later version.
11
- *
12
- * This library is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
- * Lesser General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU Lesser General Public
18
- * License along with this library; if not, write to the Free Software
19
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
- * MA 02110-1301 USA
21
- */
22
-
23
- #include "rbpangoprivate.h"
24
-
25
- #define RG_TARGET_NAMESPACE cLanguage
26
- #define _SELF(self) (RVAL2PANGOLANGUAGE(self))
27
-
28
- static VALUE
29
- rg_s_default(G_GNUC_UNUSED VALUE self)
30
- {
31
- return PANGOLANGUAGE2RVAL(pango_language_get_default());
32
- }
33
-
34
- static VALUE
35
- rg_initialize(VALUE self, VALUE language)
36
- {
37
- G_INITIALIZE(self, pango_language_from_string(RVAL2CSTR(language)));
38
- return Qnil;
39
- }
40
-
41
- static VALUE
42
- rg_s_to_string(G_GNUC_UNUSED VALUE self, VALUE language)
43
- {
44
- return CSTR2RVAL(pango_language_to_string(RVAL2CSTR(language)));
45
- }
46
-
47
- static VALUE
48
- rg_matches(int argc, VALUE *argv, VALUE self)
49
- {
50
- VALUE range_list;
51
-
52
- rb_scan_args(argc, argv, "01", &range_list);
53
-
54
- return CBOOL2RVAL(pango_language_matches(_SELF(self),
55
- RVAL2CSTR_ACCEPT_NIL(range_list)));
56
- }
57
-
58
- static VALUE
59
- rg_to_str(VALUE self)
60
- {
61
- return CSTR2RVAL(pango_language_to_string(_SELF(self)));
62
- }
63
-
64
- /* Moved from Pango::Script */
65
- static VALUE
66
- rg_includes_script(VALUE self, VALUE script)
67
- {
68
- return CBOOL2RVAL(pango_language_includes_script(_SELF(self),
69
- RVAL2PANGOSCRIPT(script)));
70
- }
71
-
72
- static VALUE
73
- rg_sample_string(VALUE self)
74
- {
75
- return CSTR2RVAL(pango_language_get_sample_string(_SELF(self)));
76
- }
77
-
78
- void
79
- Init_pango_language(VALUE mPango)
80
- {
81
- VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(PANGO_TYPE_LANGUAGE, "Language", mPango);
82
-
83
- RG_DEF_SMETHOD(default, 0);
84
-
85
- RG_DEF_METHOD(initialize, 1);
86
- RG_DEF_SMETHOD(to_string, 1);
87
- RG_DEF_METHOD(matches, -1);
88
- RG_DEF_METHOD(to_str, 0);
89
- RG_DEF_ALIAS("to_s", "to_str");
90
-
91
- RG_DEF_METHOD(includes_script, 1);
92
-
93
- RG_DEF_METHOD(sample_string, 0);
94
- }
@@ -1,583 +0,0 @@
1
- /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
- /*
3
- * Copyright (C) 2011-2013 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"
23
-
24
- #define RG_TARGET_NAMESPACE cLayout
25
- #define _SELF(self) (RVAL2PANGOLAYOUT(self))
26
-
27
- static VALUE
28
- rg_initialize(VALUE self, VALUE context)
29
- {
30
- G_INITIALIZE(self, pango_layout_new(RVAL2PANGOCONTEXT(context)));
31
- return Qnil;
32
- }
33
-
34
- static VALUE
35
- rg_copy(VALUE self)
36
- {
37
- return GOBJ2RVAL_UNREF(pango_layout_copy(_SELF(self)));
38
- }
39
-
40
- static VALUE
41
- rg_context(VALUE self)
42
- {
43
- return GOBJ2RVAL(pango_layout_get_context(_SELF(self)));
44
- }
45
-
46
- static VALUE
47
- rg_context_changed(VALUE self)
48
- {
49
- pango_layout_context_changed(_SELF(self));
50
- return Qnil;
51
- }
52
-
53
- static VALUE
54
- rg_set_text(VALUE self, VALUE text)
55
- {
56
- StringValue(text);
57
-
58
- pango_layout_set_text(_SELF(self), RSTRING_PTR(text), RSTRING_LEN(text));
59
-
60
- return self;
61
- }
62
-
63
- static VALUE
64
- rg_text(VALUE self)
65
- {
66
- return CSTR2RVAL(pango_layout_get_text(_SELF(self)));
67
- }
68
-
69
- static VALUE
70
- rg_set_markup(int argc, VALUE *argv, VALUE self)
71
- {
72
- VALUE markup, accel_marker;
73
- gunichar accel_char = 0;
74
-
75
- rb_scan_args(argc, argv, "11", &markup, &accel_marker);
76
-
77
- StringValue(markup);
78
-
79
- if (NIL_P(accel_marker)){
80
- pango_layout_set_markup(_SELF(self),
81
- RSTRING_PTR(markup),
82
- RSTRING_LEN(markup));
83
- } else {
84
- pango_layout_set_markup_with_accel(_SELF(self),
85
- RSTRING_PTR(markup),
86
- RSTRING_LEN(markup),
87
- NUM2CHR(accel_marker), &accel_char);
88
- }
89
- return CHR2FIX(accel_char);
90
- }
91
-
92
- static VALUE
93
- rg_operator_layout_set_markup_eq(VALUE self, VALUE markup)
94
- {
95
- StringValue(markup);
96
-
97
- pango_layout_set_markup(_SELF(self), RSTRING_PTR(markup), RSTRING_LEN(markup));
98
-
99
- return markup;
100
- }
101
-
102
- static VALUE
103
- rg_set_attributes(VALUE self, VALUE attrs)
104
- {
105
- pango_layout_set_attributes(_SELF(self),
106
- RVAL2PANGOATTRLIST(attrs));
107
- return self;
108
- }
109
-
110
- static VALUE
111
- rg_attributes(VALUE self)
112
- {
113
- return PANGOATTRLIST2RVAL(pango_layout_get_attributes(_SELF(self)));
114
- }
115
-
116
- static VALUE
117
- rg_set_font_description(VALUE self, VALUE rb_desc)
118
- {
119
- PangoFontDescription *desc;
120
- gboolean desc_created = FALSE;
121
-
122
- if (RVAL2CBOOL(rb_obj_is_kind_of(rb_desc, rb_cString))) {
123
- desc = pango_font_description_from_string(RVAL2CSTR(rb_desc));
124
- desc_created = TRUE;
125
- } else {
126
- desc = RVAL2PANGOFONTDESCRIPTION(rb_desc);
127
- }
128
-
129
- pango_layout_set_font_description(_SELF(self), desc);
130
-
131
- if (desc_created)
132
- pango_font_description_free(desc);
133
-
134
- return self;
135
- }
136
-
137
- static VALUE
138
- rg_font_description(VALUE self)
139
- {
140
- const PangoFontDescription* desc = pango_layout_get_font_description(_SELF(self));
141
- return PANGOFONTDESCRIPTION2RVAL((gpointer)desc);
142
- }
143
-
144
- static VALUE
145
- rg_set_width(VALUE self, VALUE width)
146
- {
147
- pango_layout_set_width(_SELF(self), NUM2INT(width));
148
- return self;
149
- }
150
-
151
- static VALUE
152
- rg_width(VALUE self)
153
- {
154
- return INT2NUM(pango_layout_get_width(_SELF(self)));
155
- }
156
-
157
- #if PANGO_VERSION_CHECK(1, 20, 0)
158
- static VALUE
159
- rg_set_height(VALUE self, VALUE width)
160
- {
161
- pango_layout_set_height(_SELF(self), NUM2INT(width));
162
- return self;
163
- }
164
-
165
- static VALUE
166
- rg_height(VALUE self)
167
- {
168
- return INT2NUM(pango_layout_get_height(_SELF(self)));
169
- }
170
- #endif
171
-
172
- static VALUE
173
- rg_set_wrap(VALUE self, VALUE wrap)
174
- {
175
- pango_layout_set_wrap(_SELF(self), RVAL2PANGOWRAPMODE(wrap));
176
- return self;
177
- }
178
-
179
- static VALUE
180
- rg_wrap(VALUE self)
181
- {
182
- return PANGOWRAPMODE2RVAL(pango_layout_get_wrap(_SELF(self)));
183
- }
184
-
185
- static VALUE
186
- rg_set_ellipsize(VALUE self, VALUE ellipsize)
187
- {
188
- pango_layout_set_ellipsize(_SELF(self), RVAL2PANGOELLIPSIZEMODE(ellipsize));
189
- return self;
190
- }
191
-
192
- static VALUE
193
- rg_ellipsize(VALUE self)
194
- {
195
- return PANGOELLIPSIZEMODE2RVAL(pango_layout_get_ellipsize(_SELF(self)));
196
- }
197
-
198
- #if PANGO_VERSION_CHECK(1, 16, 0)
199
- static VALUE
200
- rg_ellipsized_p(VALUE self)
201
- {
202
- return CBOOL2RVAL(pango_layout_is_ellipsized(_SELF(self)));
203
- }
204
- #endif
205
-
206
- static VALUE
207
- rg_set_indent(VALUE self, VALUE indent)
208
- {
209
- pango_layout_set_indent(_SELF(self), NUM2INT(indent));
210
- return self;
211
- }
212
-
213
- static VALUE
214
- rg_indent(VALUE self)
215
- {
216
- return INT2NUM(pango_layout_get_indent(_SELF(self)));
217
- }
218
-
219
- static VALUE
220
- rg_spacing(VALUE self)
221
- {
222
- return INT2NUM(pango_layout_get_spacing(_SELF(self)));
223
- }
224
-
225
- static VALUE
226
- rg_set_spacing(VALUE self, VALUE spacing)
227
- {
228
- pango_layout_set_spacing(_SELF(self), NUM2INT(spacing));
229
- return self;
230
- }
231
-
232
- static VALUE
233
- rg_set_justify(VALUE self, VALUE justify)
234
- {
235
- pango_layout_set_justify(_SELF(self), RVAL2CBOOL(justify));
236
- return self;
237
- }
238
- static VALUE
239
- rg_justify_p(VALUE self)
240
- {
241
- return CBOOL2RVAL(pango_layout_get_justify(_SELF(self)));
242
- }
243
-
244
- static VALUE
245
- rg_set_auto_dir(VALUE self, VALUE auto_dir)
246
- {
247
- pango_layout_set_auto_dir(_SELF(self), RVAL2CBOOL(auto_dir));
248
- return self;
249
- }
250
- static VALUE
251
- rg_auto_dir_p(VALUE self)
252
- {
253
- return CBOOL2RVAL(pango_layout_get_auto_dir(_SELF(self)));
254
- }
255
-
256
- static VALUE
257
- rg_set_alignment(VALUE self, VALUE align)
258
- {
259
- pango_layout_set_alignment(_SELF(self), RVAL2PANGOALIGNMENT(align));
260
- return self;
261
- }
262
-
263
- static VALUE
264
- rg_alignment(VALUE self)
265
- {
266
- return PANGOALIGNMENT2RVAL(pango_layout_get_alignment(_SELF(self)));
267
- }
268
-
269
- static VALUE
270
- rg_set_tabs(VALUE self, VALUE tabs)
271
- {
272
- pango_layout_set_tabs(_SELF(self),
273
- RVAL2PANGOTABARRAY(tabs));
274
- return self;
275
- }
276
-
277
- static VALUE
278
- rg_tabs(VALUE self)
279
- {
280
- VALUE ret = Qnil;
281
- PangoTabArray* tabs = pango_layout_get_tabs(_SELF(self));
282
-
283
- if (tabs) {
284
- ret = PANGOTABARRAY2RVAL(tabs);
285
- pango_tab_array_free(tabs);
286
- }
287
- return ret;
288
- }
289
-
290
- static VALUE
291
- rg_set_single_paragraph_mode(VALUE self, VALUE setting)
292
- {
293
- pango_layout_set_single_paragraph_mode(_SELF(self), RVAL2CBOOL(setting));
294
- return self;
295
- }
296
-
297
- static VALUE
298
- rg_single_paragraph_mode_p(VALUE self)
299
- {
300
- return CBOOL2RVAL(pango_layout_get_single_paragraph_mode(_SELF(self)));
301
- }
302
-
303
- static VALUE
304
- rg_log_attrs(VALUE self)
305
- {
306
- PangoLogAttr* attrs;
307
- gint i, n_attrs;
308
- VALUE ary;
309
-
310
- pango_layout_get_log_attrs(_SELF(self), &attrs, &n_attrs);
311
-
312
- ary = rb_ary_new();
313
-
314
- for (i = 0; i < n_attrs; i++) {
315
- rb_ary_assoc(ary, PANGOLOGATTR2RVAL(&attrs[i]));
316
- }
317
- g_free(attrs);
318
-
319
- return ary;
320
- }
321
-
322
- static VALUE
323
- rg_xy_to_index(VALUE self, VALUE x, VALUE y)
324
- {
325
- int index, trailing;
326
- gboolean ret = pango_layout_xy_to_index(_SELF(self),
327
- NUM2INT(x), NUM2INT(y),
328
- &index, &trailing);
329
-
330
- return rb_ary_new3(3, CBOOL2RVAL(ret), INT2NUM(index), INT2NUM(trailing));
331
- }
332
-
333
- static VALUE
334
- rg_index_to_pos(VALUE self, VALUE index)
335
- {
336
- PangoRectangle pos;
337
- pango_layout_index_to_pos(_SELF(self), NUM2INT(index), &pos);
338
- return PANGORECTANGLE2RVAL(&pos);
339
- }
340
-
341
- static VALUE
342
- rg_get_cursor_pos(VALUE self, VALUE index)
343
- {
344
- PangoRectangle strong_pos, weak_pos;
345
- pango_layout_get_cursor_pos(_SELF(self), NUM2INT(index), &strong_pos, &weak_pos);
346
- return rb_ary_new3(2, PANGORECTANGLE2RVAL(&strong_pos),
347
- PANGORECTANGLE2RVAL(&weak_pos));
348
- }
349
-
350
- static VALUE
351
- rg_move_cursor_visually(VALUE self, VALUE strong, VALUE old_index, VALUE old_trailing, VALUE direction)
352
- {
353
- int new_index, new_trailing;
354
- pango_layout_move_cursor_visually(_SELF(self), RVAL2CBOOL(strong),
355
- NUM2INT(old_index), NUM2INT(old_trailing),
356
- NUM2INT(direction),
357
- &new_index, &new_trailing);
358
- return rb_ary_new3(2, INT2NUM(new_index), INT2NUM(new_trailing));
359
- }
360
-
361
- static VALUE
362
- rg_get_extents(int argc, VALUE *argv, VALUE self)
363
- {
364
- VALUE ink_rect, logical_rect;
365
- PangoRectangle rink, rlog;
366
-
367
- rb_scan_args(argc, argv, "02", &ink_rect, &logical_rect);
368
-
369
- if (NIL_P(ink_rect)){
370
- rink.x = 0;
371
- rink.y = 0;
372
- rink.width = 0;
373
- rink.height = 0;
374
- } else {
375
- PangoRectangle* rect = RVAL2PANGORECTANGLE(ink_rect);
376
- rink.x = rect->x;
377
- rink.y = rect->y;
378
- rink.width = rect->width;
379
- rink.height = rect->height;
380
- }
381
- if (NIL_P(logical_rect)){
382
- rlog.x = 0;
383
- rlog.y = 0;
384
- rlog.width = 0;
385
- rlog.height = 0;
386
- } else {
387
- PangoRectangle* rect = RVAL2PANGORECTANGLE(logical_rect);
388
- rlog.x = rect->x;
389
- rlog.y = rect->y;
390
- rlog.width = rect->width;
391
- rlog.height = rect->height;
392
- }
393
-
394
- pango_layout_get_extents(_SELF(self), &rink, &rlog);
395
-
396
- return rb_assoc_new(PANGORECTANGLE2RVAL(&rink),
397
- PANGORECTANGLE2RVAL(&rlog));
398
- }
399
-
400
- static VALUE
401
- rg_extents(VALUE self)
402
- {
403
- PangoRectangle rink = {0, 0, 0, 0};
404
- PangoRectangle rlog = {0, 0, 0, 0};
405
-
406
- pango_layout_get_extents(_SELF(self), &rink, &rlog);
407
- return rb_assoc_new(PANGORECTANGLE2RVAL(&rink),
408
- PANGORECTANGLE2RVAL(&rlog));
409
- }
410
-
411
- static VALUE
412
- rg_get_pixel_extents(int argc, VALUE *argv, VALUE self)
413
- {
414
- VALUE ink_rect, logical_rect;
415
- PangoRectangle rink, rlog;
416
-
417
- rb_scan_args(argc, argv, "02", &ink_rect, &logical_rect);
418
-
419
- if (NIL_P(ink_rect)){
420
- rink.x = 0;
421
- rink.y = 0;
422
- rink.width = 0;
423
- rink.height = 0;
424
- } else {
425
- PangoRectangle* rect = RVAL2PANGORECTANGLE(ink_rect);
426
- rink.x = rect->x;
427
- rink.y = rect->y;
428
- rink.width = rect->width;
429
- rink.height = rect->height;
430
- }
431
- if (NIL_P(logical_rect)){
432
- rlog.x = 0;
433
- rlog.y = 0;
434
- rlog.width = 0;
435
- rlog.height = 0;
436
- } else {
437
- PangoRectangle* rect = RVAL2PANGORECTANGLE(logical_rect);
438
- rlog.x = rect->x;
439
- rlog.y = rect->y;
440
- rlog.width = rect->width;
441
- rlog.height = rect->height;
442
- }
443
-
444
- pango_layout_get_pixel_extents(_SELF(self), &rink, &rlog);
445
-
446
- return rb_assoc_new(PANGORECTANGLE2RVAL(&rink),
447
- PANGORECTANGLE2RVAL(&rlog));
448
- }
449
-
450
- static VALUE
451
- rg_pixel_extents(VALUE self)
452
- {
453
- PangoRectangle rink = {0, 0, 0, 0};
454
- PangoRectangle rlog = {0, 0, 0, 0};
455
-
456
- pango_layout_get_pixel_extents(_SELF(self), &rink, &rlog);
457
- return rb_assoc_new(PANGORECTANGLE2RVAL(&rink),
458
- PANGORECTANGLE2RVAL(&rlog));
459
- }
460
-
461
- static VALUE
462
- rg_size(VALUE self)
463
- {
464
- int width, height;
465
- pango_layout_get_size(_SELF(self), &width, &height);
466
- return rb_ary_new3(2, INT2NUM(width), INT2NUM(height));
467
- }
468
-
469
- static VALUE
470
- rg_pixel_size(VALUE self)
471
- {
472
- int width, height;
473
- pango_layout_get_pixel_size(_SELF(self), &width, &height);
474
- return rb_ary_new3(2, INT2NUM(width), INT2NUM(height));
475
- }
476
-
477
- static VALUE
478
- rg_line_count(VALUE self)
479
- {
480
- return INT2NUM(pango_layout_get_line_count(_SELF(self)));
481
- }
482
-
483
- static VALUE
484
- rg_get_line(VALUE self, VALUE line)
485
- {
486
- return PANGOLAYOUTLINE2RVAL(pango_layout_get_line(_SELF(self), NUM2INT(line)));
487
- }
488
-
489
- static VALUE
490
- rg_lines(VALUE self)
491
- {
492
- return GSLIST2ARY2(pango_layout_get_lines(_SELF(self)), PANGO_TYPE_LAYOUT_LINE);
493
- }
494
-
495
- static VALUE
496
- rg_iter(VALUE self)
497
- {
498
- return PANGOLAYOUTITER2RVAL(pango_layout_get_iter(_SELF(self)));
499
- }
500
-
501
- #if PANGO_VERSION_CHECK(1, 22, 0)
502
- static VALUE
503
- rg_baseline(VALUE self)
504
- {
505
- return INT2NUM(pango_layout_get_baseline(_SELF(self)));
506
- }
507
- #endif
508
-
509
- void
510
- Init_pango_layout(VALUE mPango)
511
- {
512
- VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(PANGO_TYPE_LAYOUT, "Layout", mPango);
513
-
514
- RG_DEF_METHOD(initialize, 1);
515
- RG_DEF_METHOD(copy, 0);
516
- RG_DEF_METHOD(context, 0);
517
- RG_DEF_METHOD(context_changed, 0);
518
- RG_DEF_METHOD(set_text, 1);
519
- RG_DEF_METHOD(text, 0);
520
- RG_DEF_METHOD(set_markup, -1);
521
- RG_DEF_METHOD_OPERATOR("markup=", layout_set_markup_eq, 1);
522
- RG_DEF_METHOD(set_attributes, 1);
523
- RG_DEF_METHOD(attributes, 0);
524
- RG_DEF_METHOD(set_font_description, 1);
525
- RG_DEF_METHOD(font_description, 0);
526
- RG_DEF_METHOD(set_width, 1);
527
- RG_DEF_METHOD(width, 0);
528
- #if PANGO_VERSION_CHECK(1, 20, 0)
529
- RG_DEF_METHOD(set_height, 1);
530
- RG_DEF_METHOD(height, 0);
531
- #endif
532
- RG_DEF_METHOD(set_wrap, 1);
533
- RG_DEF_METHOD(wrap, 0);
534
- RG_DEF_METHOD(set_ellipsize, 1);
535
- RG_DEF_METHOD(ellipsize, 0);
536
- #if PANGO_VERSION_CHECK(1, 16, 0)
537
- RG_DEF_METHOD_P(ellipsized, 0);
538
- #endif
539
- RG_DEF_METHOD(set_indent, 1);
540
- RG_DEF_METHOD(indent, 0);
541
- RG_DEF_METHOD(spacing, 0);
542
- RG_DEF_METHOD(set_spacing, 1);
543
- RG_DEF_METHOD(set_justify, 1);
544
- RG_DEF_METHOD_P(justify, 0);
545
- RG_DEF_METHOD(set_auto_dir, 1);
546
- RG_DEF_METHOD_P(auto_dir, 0);
547
- RG_DEF_METHOD(set_alignment, 1);
548
- RG_DEF_METHOD(alignment, 0);
549
- RG_DEF_METHOD(set_tabs, 1);
550
- RG_DEF_METHOD(tabs, 0);
551
- RG_DEF_METHOD(set_single_paragraph_mode, 1);
552
- RG_DEF_METHOD_P(single_paragraph_mode, 0);
553
- RG_DEF_METHOD(log_attrs, 0);
554
- RG_DEF_METHOD(xy_to_index, 2);
555
- RG_DEF_METHOD(index_to_pos, 1);
556
- RG_DEF_METHOD(get_cursor_pos, 1);
557
- RG_DEF_METHOD(move_cursor_visually, 4);
558
- RG_DEF_METHOD(get_extents, -1);
559
- RG_DEF_METHOD(extents, 0);
560
- RG_DEF_METHOD(get_pixel_extents, -1);
561
- RG_DEF_METHOD(pixel_extents, 0);
562
- RG_DEF_METHOD(size, 0);
563
- RG_DEF_METHOD(pixel_size, 0);
564
- RG_DEF_METHOD(line_count, 0);
565
- RG_DEF_METHOD(get_line, 1);
566
- RG_DEF_METHOD(lines, 0);
567
- RG_DEF_METHOD(iter, 0);
568
- #if PANGO_VERSION_CHECK(1, 22, 0)
569
- RG_DEF_METHOD(baseline, 0);
570
- #endif
571
-
572
- /* PangoWrapMode */
573
- G_DEF_CLASS(PANGO_TYPE_WRAP_MODE, "WrapMode", RG_TARGET_NAMESPACE);
574
- G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, PANGO_TYPE_WRAP_MODE, "PANGO_");
575
-
576
- /* PangoAlignment */
577
- G_DEF_CLASS(PANGO_TYPE_ALIGNMENT, "Alignment", RG_TARGET_NAMESPACE);
578
- G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, PANGO_TYPE_ALIGNMENT, "PANGO_");
579
-
580
- /* PangoEllipsizeMode */
581
- G_DEF_CLASS(PANGO_TYPE_ELLIPSIZE_MODE, "EllipsizeMode", RG_TARGET_NAMESPACE);
582
- G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, PANGO_TYPE_ELLIPSIZE_MODE, "PANGO_");
583
- }