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,121 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbpangocolor.c -
5
+
6
+ $Author: ggc $
7
+ $Date: 2007/07/13 14:27:11 $
8
+
9
+ Copyright (C) 2002,2003 Masao Mutoh
10
+ ************************************************/
11
+
12
+ #include "rbpango.h"
13
+
14
+ #define _SELF(self) ((PangoColor*)RVAL2BOXED(self, PANGO_TYPE_COLOR))
15
+
16
+ static VALUE
17
+ color_initialize(self, red, green, blue)
18
+ VALUE self, red, green, blue;
19
+ {
20
+ PangoColor c;
21
+ c.red = NUM2INT(red);
22
+ c.green = NUM2INT(green);
23
+ c.blue = NUM2INT(blue);
24
+
25
+ G_INITIALIZE(self, &c);
26
+ return Qnil;
27
+ }
28
+
29
+ static VALUE
30
+ color_parse(self, spec)
31
+ VALUE self, spec;
32
+ {
33
+ return CBOOL2RVAL(pango_color_parse(_SELF(self), RVAL2CSTR(spec)));
34
+ }
35
+
36
+ static VALUE
37
+ color_red(self)
38
+ VALUE self;
39
+ {
40
+ return INT2FIX(_SELF(self)->red);
41
+ }
42
+
43
+ static VALUE
44
+ color_set_red(self, red)
45
+ VALUE self;
46
+ VALUE red;
47
+ {
48
+ _SELF(self)->red = NUM2INT(red);
49
+ return self;
50
+ }
51
+
52
+ static VALUE
53
+ color_green(self)
54
+ VALUE self;
55
+ {
56
+ return INT2FIX(_SELF(self)->green);
57
+ }
58
+
59
+ static VALUE
60
+ color_set_green(self, green)
61
+ VALUE self;
62
+ VALUE green;
63
+ {
64
+ _SELF(self)->green = NUM2INT(green);
65
+ return self;
66
+ }
67
+
68
+ static VALUE
69
+ color_blue(self)
70
+ VALUE self;
71
+ {
72
+ return INT2FIX(_SELF(self)->blue);
73
+ }
74
+
75
+ static VALUE
76
+ color_set_blue(self, blue)
77
+ VALUE self;
78
+ VALUE blue;
79
+ {
80
+ _SELF(self)->blue = NUM2INT(blue);
81
+ return self;
82
+ }
83
+
84
+ static VALUE
85
+ color_to_a(self)
86
+ VALUE self;
87
+ {
88
+ PangoColor *c = _SELF(self);
89
+ return rb_ary_new3(3, INT2FIX(c->red),
90
+ INT2FIX(c->green), INT2FIX(c->blue));
91
+ }
92
+
93
+ static VALUE
94
+ color_equal(self, other)
95
+ VALUE self, other;
96
+ {
97
+ PangoColor* c1 = _SELF(self);
98
+ PangoColor* c2 = _SELF(other);
99
+
100
+ return CBOOL2RVAL((c1->red == c2->red) && (c1->green == c2->green) &&
101
+ (c1->blue == c2->blue));
102
+ }
103
+
104
+ void
105
+ Init_pango_color()
106
+ {
107
+ VALUE pColor = G_DEF_CLASS(PANGO_TYPE_COLOR, "Color", mPango);
108
+
109
+ rb_define_method(pColor, "initialize", color_initialize, 3);
110
+ rb_define_method(pColor, "parse", color_parse, 1);
111
+ rb_define_method(pColor, "red", color_red, 0);
112
+ rb_define_method(pColor, "set_red", color_set_red, 1);
113
+ rb_define_method(pColor, "green", color_green, 0);
114
+ rb_define_method(pColor, "set_green", color_set_green, 1);
115
+ rb_define_method(pColor, "blue", color_blue, 0);
116
+ rb_define_method(pColor, "set_blue", color_set_blue, 1);
117
+ rb_define_method(pColor, "to_a", color_to_a, 0);
118
+ rb_define_method(pColor, "==", color_equal, 1);
119
+
120
+ G_DEF_SETTERS(pColor);
121
+ }
@@ -0,0 +1,341 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbpangocontext.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(self) (PANGO_CONTEXT(RVAL2GOBJ(self)))
15
+ #define RVAL2DESC(v) ((PangoFontDescription*)RVAL2BOXED(v, PANGO_TYPE_FONT_DESCRIPTION))
16
+ #define RVAL2LANG(v) ((PangoLanguage*)RVAL2BOXED(v, PANGO_TYPE_LANGUAGE))
17
+
18
+ static VALUE
19
+ rcontext_itemize(argc, argv, self)
20
+ int argc;
21
+ VALUE *argv;
22
+ VALUE self;
23
+ {
24
+ VALUE arg1, arg2, arg3, arg4, arg5, arg6;
25
+ GList* list;
26
+
27
+ rb_scan_args(argc, argv, "42", &arg1, &arg2, &arg3, &arg4, &arg5, &arg6);
28
+
29
+ if (TYPE(arg1) == T_STRING) {
30
+ list = pango_itemize(_SELF(self),
31
+ RVAL2CSTR(arg1), /* text */
32
+ NUM2INT(arg2), /* start_index */
33
+ NUM2INT(arg3), /* length */
34
+ (PangoAttrList*)RVAL2BOXED(arg4, PANGO_TYPE_ATTR_LIST), /* attrs */
35
+ NIL_P(arg5) ? NULL : (PangoAttrIterator*)RVAL2BOXED(arg5, PANGO_TYPE_ATTR_ITERATOR)); /* cached_iter */
36
+ } else {
37
+ #ifdef HAVE_PANGO_ITEMIZE_WITH_BASE_DIR
38
+ list = pango_itemize_with_base_dir(_SELF(self),
39
+ RVAL2GENUM(arg1, PANGO_TYPE_DIRECTION), /* base_dir */
40
+ RVAL2CSTR(arg2), /* text */
41
+ NUM2INT(arg3), /* start_index */
42
+ NUM2INT(arg4), /* length */
43
+ (PangoAttrList*)RVAL2BOXED(arg5, PANGO_TYPE_ATTR_LIST), /* attrs */
44
+ NIL_P(arg6) ? NULL : (PangoAttrIterator*)RVAL2BOXED(arg6, PANGO_TYPE_ATTR_ITERATOR)); /* cached_iter */
45
+ #else
46
+ rb_warn("Pango::Context#itemize(base_dir, text, start_index, length, attrs, cached_iter) isn't supported on this environment.");
47
+ list = pango_itemize(_SELF(self),
48
+ RVAL2CSTR(arg1), /* text */
49
+ NUM2INT(arg2), /* start_index */
50
+ NUM2INT(arg3), /* length */
51
+ (PangoAttrList*)RVAL2BOXED(arg4, PANGO_TYPE_ATTR_LIST), /* attrs */
52
+ NIL_P(arg5) ? NULL : (PangoAttrIterator*)RVAL2BOXED(arg5, PANGO_TYPE_ATTR_ITERATOR)); /* cached_iter */
53
+ #endif
54
+ }
55
+ return GLIST2ARY2F(list, PANGO_TYPE_ITEM);
56
+ }
57
+
58
+ /* Move to Pango module (rbpangomain.c)
59
+ GList* pango_reorder_items (GList *logical_items);
60
+ */
61
+
62
+ #ifdef PANGO_ENABLE_BACKEND
63
+ static VALUE
64
+ rcontext_initialize(self)
65
+ VALUE self;
66
+ {
67
+ G_INITIALIZE(self, pango_context_new());
68
+ return Qnil;
69
+ }
70
+
71
+ static VALUE
72
+ rcontext_set_font_map(self, font_map)
73
+ VALUE self, font_map;
74
+ {
75
+ pango_context_set_font_map(_SELF(self), PANGO_FONT_MAP(RVAL2GOBJ(font_map)));
76
+ return self;
77
+ }
78
+
79
+ #if PANGO_CHECK_VERSION(1,6,0)
80
+ static VALUE
81
+ rcontext_get_font_map(self)
82
+ VALUE self;
83
+ {
84
+ return GOBJ2RVAL(pango_context_get_font_map(_SELF(self)));
85
+ }
86
+ #endif
87
+ #endif /* PANGO_ENABLE_BACKEND */
88
+
89
+ static VALUE
90
+ rcontext_get_font_description(self)
91
+ VALUE self;
92
+ {
93
+ PangoFontDescription* ret = pango_context_get_font_description(_SELF(self));
94
+ return BOXED2RVAL(ret, PANGO_TYPE_FONT_DESCRIPTION);
95
+ }
96
+
97
+ static VALUE
98
+ rcontext_set_font_description(self, desc)
99
+ VALUE self, desc;
100
+ {
101
+ pango_context_set_font_description(_SELF(self), RVAL2DESC(desc));
102
+ return self;
103
+ }
104
+
105
+ static VALUE
106
+ rcontext_get_language(self)
107
+ VALUE self;
108
+ {
109
+ PangoLanguage* ret = pango_context_get_language(_SELF(self));
110
+ return BOXED2RVAL(ret, PANGO_TYPE_LANGUAGE);
111
+ }
112
+
113
+ static VALUE
114
+ rcontext_set_language(self, lang)
115
+ VALUE self, lang;
116
+ {
117
+ pango_context_set_language(_SELF(self),
118
+ RVAL2LANG(lang));
119
+ return self;
120
+ }
121
+
122
+ static VALUE
123
+ rcontext_get_base_dir(self)
124
+ VALUE self;
125
+ {
126
+ return GENUM2RVAL(pango_context_get_base_dir(_SELF(self)), PANGO_TYPE_DIRECTION);
127
+ }
128
+
129
+ static VALUE
130
+ rcontext_set_base_dir(self, direction)
131
+ VALUE self, direction;
132
+ {
133
+ pango_context_set_base_dir(_SELF(self), RVAL2GENUM(direction, PANGO_TYPE_DIRECTION));
134
+ return self;
135
+ }
136
+
137
+ #if PANGO_CHECK_VERSION(1,16,0)
138
+ static VALUE
139
+ rcontext_get_base_gravity(VALUE self)
140
+ {
141
+ return GENUM2RVAL(pango_context_get_base_gravity(_SELF(self)), PANGO_TYPE_GRAVITY);
142
+ }
143
+
144
+ static VALUE
145
+ rcontext_set_base_gravity(VALUE self, VALUE gravity)
146
+ {
147
+ pango_context_set_base_gravity(_SELF(self), RVAL2GENUM(gravity, PANGO_TYPE_GRAVITY));
148
+ return self;
149
+ }
150
+
151
+ static VALUE
152
+ rcontext_get_gravity_hint(VALUE self)
153
+ {
154
+ return GENUM2RVAL(pango_context_get_gravity_hint(_SELF(self)), PANGO_TYPE_GRAVITY_HINT);
155
+ }
156
+
157
+ static VALUE
158
+ rcontext_set_gravity_hint(VALUE self, VALUE gravity_hint)
159
+ {
160
+ pango_context_set_gravity_hint(_SELF(self), RVAL2GENUM(gravity_hint, PANGO_TYPE_GRAVITY_HINT));
161
+ return self;
162
+ }
163
+ #endif
164
+
165
+ #if PANGO_CHECK_VERSION(1,6,0)
166
+ static VALUE
167
+ rcontext_get_matrix(self)
168
+ VALUE self;
169
+ {
170
+ const PangoMatrix* matrix = pango_context_get_matrix(_SELF(self));
171
+ return BOXED2RVAL((PangoMatrix*)matrix, PANGO_TYPE_MATRIX);
172
+ }
173
+
174
+ static VALUE
175
+ rcontext_set_matrix(self, matrix)
176
+ VALUE self, matrix;
177
+ {
178
+ pango_context_set_matrix(_SELF(self),
179
+ (PangoMatrix*)RVAL2BOXED(matrix, PANGO_TYPE_MATRIX));
180
+ return self;
181
+ }
182
+ #endif
183
+
184
+ static VALUE
185
+ rcontext_load_font(self, desc)
186
+ VALUE self, desc;
187
+ {
188
+ return GOBJ2RVAL(pango_context_load_font(_SELF(self), RVAL2DESC(desc)));
189
+ }
190
+
191
+ static VALUE
192
+ rcontext_load_fontset(self, desc, lang)
193
+ VALUE self, desc, lang;
194
+ {
195
+ return GOBJ2RVAL(pango_context_load_fontset(_SELF(self),
196
+ RVAL2DESC(desc), RVAL2LANG(lang)));
197
+ }
198
+
199
+ static VALUE
200
+ rcontext_get_metrics(argc, argv, self)
201
+ int argc;
202
+ VALUE *argv;
203
+ VALUE self;
204
+ {
205
+ VALUE desc, lang;
206
+
207
+ rb_scan_args(argc, argv, "11", &desc, &lang);
208
+
209
+ return BOXED2RVAL(pango_context_get_metrics(_SELF(self),
210
+ RVAL2DESC(desc),
211
+ NIL_P(lang) ? NULL : RVAL2LANG(lang)),
212
+ PANGO_TYPE_FONT_METRICS);
213
+ }
214
+
215
+ static VALUE
216
+ rcontext_list_families(self)
217
+ VALUE self;
218
+ {
219
+ int n_families;
220
+ PangoFontFamily** families;
221
+ int i;
222
+ VALUE result;
223
+
224
+ pango_context_list_families(_SELF(self),
225
+ &families,
226
+ &n_families);
227
+
228
+ result = rb_ary_new2(n_families);
229
+ for (i = 0; i < n_families; i++)
230
+ rb_ary_store(result, i, GOBJ2RVAL(families[i]));
231
+
232
+ g_free(families);
233
+
234
+ return result;
235
+ }
236
+
237
+ #if PANGO_CHECK_VERSION(1,10,0)
238
+ # if HAVE_RB_CAIRO_H
239
+ static VALUE
240
+ rcontext_set_font_options(self, options)
241
+ VALUE self, options;
242
+ {
243
+ if (NIL_P(options))
244
+ pango_cairo_context_set_font_options(_SELF(self), NULL);
245
+ else
246
+ pango_cairo_context_set_font_options(_SELF(self),
247
+ RVAL2CRFONTOPTIONS(options));
248
+ return self;
249
+ }
250
+
251
+ static VALUE
252
+ rcontext_get_font_options(self)
253
+ VALUE self;
254
+ {
255
+ const cairo_font_options_t *options;
256
+ options = pango_cairo_context_get_font_options(_SELF(self));
257
+ if (options)
258
+ return CRFONTOPTIONS2RVAL(cairo_font_options_copy(options));
259
+ else
260
+ return Qnil;
261
+ }
262
+
263
+ static VALUE
264
+ rcontext_set_resolution(self, dpi)
265
+ VALUE self, dpi;
266
+ {
267
+ pango_cairo_context_set_resolution(_SELF(self), NUM2DBL(dpi));
268
+ return self;
269
+ }
270
+
271
+ static VALUE
272
+ rcontext_get_resolution(self)
273
+ VALUE self;
274
+ {
275
+ return rb_float_new(pango_cairo_context_get_resolution(_SELF(self)));
276
+ }
277
+ # endif
278
+ #endif
279
+
280
+
281
+ static VALUE
282
+ rcontext_list_families_old(self)
283
+ VALUE self;
284
+ {
285
+ rb_warn("Deprecated. Use Pango::Context#families instead.");
286
+ return rcontext_list_families(self);
287
+ }
288
+
289
+ void
290
+ Init_pango_context()
291
+ {
292
+ VALUE pContext = G_DEF_CLASS(PANGO_TYPE_CONTEXT, "Context", mPango);
293
+
294
+ rb_define_method(pContext, "itemize", rcontext_itemize, -1);
295
+
296
+ #ifdef PANGO_ENABLE_BACKEND
297
+ rb_define_method(pContext, "initialize", rcontext_initialize, 0);
298
+ rb_define_method(pContext, "set_font_map", rcontext_set_font_map, 1);
299
+ #if PANGO_CHECK_VERSION(1,6,0)
300
+ rb_define_method(pContext, "font_map", rcontext_get_font_map, 0);
301
+ #endif
302
+ #endif /* PANGO_ENABLE_BACKEND */
303
+ rb_define_method(pContext, "font_description", rcontext_get_font_description, 0);
304
+ rb_define_method(pContext, "set_font_description", rcontext_set_font_description, 1);
305
+ rb_define_method(pContext, "language", rcontext_get_language, 0);
306
+ rb_define_method(pContext, "set_language", rcontext_set_language, 1);
307
+ rb_define_method(pContext, "base_dir", rcontext_get_base_dir, 0);
308
+ rb_define_method(pContext, "set_base_dir", rcontext_set_base_dir, 1);
309
+ #if PANGO_CHECK_VERSION(1,16,0)
310
+ rb_define_method(pContext, "base_gravity", rcontext_get_base_gravity, 0);
311
+ rb_define_method(pContext, "set_base_gravity", rcontext_set_base_gravity, 1);
312
+ rb_define_method(pContext, "gravity_hint", rcontext_get_gravity_hint, 0);
313
+ rb_define_method(pContext, "set_gravity_hint", rcontext_set_gravity_hint, 1);
314
+ #endif
315
+ #if PANGO_CHECK_VERSION(1,6,0)
316
+ rb_define_method(pContext, "matrix", rcontext_get_matrix, 0);
317
+ rb_define_method(pContext, "set_matrix", rcontext_set_matrix, 1);
318
+ #endif
319
+ rb_define_method(pContext, "load_font", rcontext_load_font, 1);
320
+ rb_define_method(pContext, "load_fontset", rcontext_load_fontset, 2);
321
+ rb_define_method(pContext, "get_metrics", rcontext_get_metrics, -1);
322
+ rb_define_method(pContext, "families", rcontext_list_families, 0);
323
+
324
+ #if PANGO_CHECK_VERSION(1,10,0)
325
+ # if HAVE_RB_CAIRO_H
326
+ rb_define_method(pContext, "set_font_options", rcontext_set_font_options, 1);
327
+ rb_define_method(pContext, "font_options", rcontext_get_font_options, 0);
328
+ rb_define_method(pContext, "set_resolution", rcontext_set_resolution, 1);
329
+ rb_define_method(pContext, "resolution", rcontext_get_resolution, 0);
330
+ # endif
331
+ #endif
332
+
333
+ /* This will remove 2 or 3 releases later since 0.14.0. */
334
+ rb_define_method(pContext, "list_families", rcontext_list_families_old, 0);
335
+
336
+ G_DEF_SETTERS(pContext);
337
+
338
+ /* PangoDirection */
339
+ G_DEF_CLASS(PANGO_TYPE_DIRECTION, "Direction", pContext);
340
+ G_DEF_CONSTANTS(pContext, PANGO_TYPE_DIRECTION, "PANGO_");
341
+ }