pango 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,137 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbpangoattriterator.c -
5
+
6
+ $Author: mutoh $
7
+ $Date: 2005/07/24 07:00:32 $
8
+
9
+ Copyright (C) 2002-2005 Masao Mutoh
10
+ ************************************************/
11
+
12
+ #include "rbpango.h"
13
+
14
+ #define _SELF(self) ((PangoAttrIterator*)RVAL2BOXED(self, PANGO_TYPE_ATTR_ITERATOR))
15
+
16
+ /**********************************/
17
+ GType
18
+ pango_attr_iter_get_type(void)
19
+ {
20
+ static GType our_type = 0;
21
+
22
+ if (our_type == 0)
23
+ our_type = g_boxed_type_register_static ("PangoAttrIterator",
24
+ (GBoxedCopyFunc)pango_attr_iterator_copy,
25
+ (GBoxedFreeFunc)pango_attr_iterator_destroy);
26
+ return our_type;
27
+ }
28
+ /**********************************/
29
+
30
+ static VALUE
31
+ attriterator_next(self)
32
+ VALUE self;
33
+ {
34
+ return CBOOL2RVAL(pango_attr_iterator_next(_SELF(self)));
35
+ }
36
+
37
+ static VALUE
38
+ attriterator_range(self)
39
+ VALUE self;
40
+ {
41
+ gint start = 0;
42
+ gint end = 0;
43
+ pango_attr_iterator_range(_SELF(self), &start, &end);
44
+ return rb_ary_new3(2, INT2NUM(start), INT2NUM(end));
45
+ }
46
+
47
+ static VALUE
48
+ attriterator_get(argc, argv, self)
49
+ int argc;
50
+ VALUE* argv;
51
+ VALUE self;
52
+ {
53
+ VALUE type, ret;
54
+ PangoAttribute* attr;
55
+ int i;
56
+
57
+ rb_scan_args(argc, argv, "01", &type);
58
+
59
+ if (NIL_P(type)){
60
+ PangoAttrIterator* iter = _SELF(self);
61
+ ret = rb_ary_new();
62
+ for (i = 0; i < PANGO_ATTR_SCALE + 1; i++){
63
+ attr = pango_attr_iterator_get(iter, i);
64
+ if (attr)
65
+ rb_ary_push(ret, ATTR2RVAL(attr));
66
+ }
67
+ } else {
68
+ attr = pango_attr_iterator_get(_SELF(self), FIX2INT(type));
69
+ ret = attr ? ATTR2RVAL(attr) : Qnil;
70
+ }
71
+ return ret;
72
+ }
73
+
74
+ static VALUE
75
+ attriterator_get_font(self)
76
+ VALUE self;
77
+ {
78
+ PangoFontDescription* desc;
79
+ PangoLanguage* lang;
80
+ GSList* extra_attrs;
81
+ VALUE ary, ret;
82
+
83
+ desc = pango_font_description_new();
84
+
85
+ pango_attr_iterator_get_font(_SELF(self), desc, &lang, &extra_attrs);
86
+
87
+ ary = rb_ary_new();
88
+ while(extra_attrs) {
89
+ rb_ary_push(ary, ATTR2RVAL(extra_attrs->data));
90
+ extra_attrs = extra_attrs->next;
91
+ }
92
+
93
+ ret = rb_ary_new3(3, (PangoFontDescription*)BOXED2RVAL(desc, PANGO_TYPE_FONT_DESCRIPTION),
94
+ (PangoLanguage*)BOXED2RVAL(lang, PANGO_TYPE_LANGUAGE),
95
+ ary);
96
+
97
+ pango_font_description_free(desc);
98
+ return ret;
99
+ }
100
+
101
+ #ifdef HAVE_PANGO_ATTR_ITERATOR_GET_ATTRS
102
+ static VALUE
103
+ attriterator_get_attrs(self)
104
+ VALUE self;
105
+ {
106
+ GSList* list = pango_attr_iterator_get_attrs(_SELF(self));
107
+ GSList* base = list;
108
+ GSList* old = list;
109
+ VALUE ary = rb_ary_new();
110
+
111
+ while (list) {
112
+ rb_ary_push(ary, ATTR2RVAL(list->data));
113
+ list = list->next;
114
+ }
115
+ while (old) {
116
+ pango_attribute_destroy((PangoAttribute*)old);
117
+ old = old->next;
118
+ }
119
+ g_slist_free(base);
120
+
121
+ return ary;
122
+ }
123
+ #endif
124
+
125
+ void
126
+ Init_pango_attriterator()
127
+ {
128
+ VALUE pAttriterator = G_DEF_CLASS(PANGO_TYPE_ATTR_ITERATOR, "AttrIterator", mPango);
129
+
130
+ rb_define_method(pAttriterator, "next!", attriterator_next, 0);
131
+ rb_define_method(pAttriterator, "range", attriterator_range, 0);
132
+ rb_define_method(pAttriterator, "get", attriterator_get, -1);
133
+ rb_define_method(pAttriterator, "font", attriterator_get_font, 0);
134
+ #ifdef HAVE_PANGO_ATTR_ITERATOR_GET_ATTRS
135
+ rb_define_method(pAttriterator, "attrs", attriterator_get_attrs, 0);
136
+ #endif
137
+ }
@@ -0,0 +1,104 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbpangoattrlist.c -
5
+
6
+ $Author: sakai $
7
+ $Date: 2007/07/08 02:53:10 $
8
+
9
+ Copyright (C) 2002-2005 Masao Mutoh
10
+ ************************************************/
11
+
12
+ #include "rbpango.h"
13
+
14
+ static ID id_call;
15
+
16
+ #define _SELF(self) ((PangoAttrList*)RVAL2BOXED(self, PANGO_TYPE_ATTR_LIST))
17
+
18
+ static VALUE
19
+ attrlist_initialize(self)
20
+ VALUE self;
21
+ {
22
+ G_INITIALIZE(self, pango_attr_list_new());
23
+ return Qnil;
24
+ }
25
+
26
+ static VALUE
27
+ attrlist_insert(self, attr)
28
+ VALUE self, attr;
29
+ {
30
+ pango_attr_list_insert(_SELF(self), RVAL2ATTR(attr));
31
+ return self;
32
+ }
33
+
34
+ static VALUE
35
+ attrlist_insert_before(self, attr)
36
+ VALUE self, attr;
37
+ {
38
+ pango_attr_list_insert_before(_SELF(self), RVAL2ATTR(attr));
39
+ return self;
40
+ }
41
+
42
+ static VALUE
43
+ attrlist_change(self, attr)
44
+ VALUE self, attr;
45
+ {
46
+ pango_attr_list_change(_SELF(self), RVAL2ATTR(attr));
47
+ return self;
48
+ }
49
+
50
+ static VALUE
51
+ attrlist_splice(self, other, pos, len)
52
+ VALUE self, other, pos, len;
53
+ {
54
+ pango_attr_list_splice(_SELF(self), _SELF(other), NUM2INT(pos), NUM2INT(len));
55
+ return self;
56
+ }
57
+
58
+ #if PANGO_CHECK_VERSION(1,4,0)
59
+ static gboolean
60
+ filter_func(attr, data)
61
+ PangoAttribute* attr;
62
+ gpointer data;
63
+ {
64
+ return CBOOL2RVAL(rb_funcall((VALUE)data, id_call, 1, ATTR2RVAL(attr)));
65
+ }
66
+
67
+ static VALUE
68
+ attrlist_filter(self)
69
+ VALUE self;
70
+ {
71
+ VALUE func = rb_block_proc();
72
+ G_RELATIVE(self, func);
73
+ return BOXED2RVAL(pango_attr_list_filter(_SELF(self),
74
+ (PangoAttrFilterFunc)filter_func,
75
+ (gpointer)func),
76
+ PANGO_TYPE_ATTR_LIST);
77
+ }
78
+ #endif
79
+
80
+ static VALUE
81
+ attrlist_get_iterator(self)
82
+ VALUE self;
83
+ {
84
+ return BOXED2RVAL(pango_attr_list_get_iterator(_SELF(self)), PANGO_TYPE_ATTR_ITERATOR);
85
+ }
86
+
87
+ void
88
+ Init_pango_attrlist()
89
+ {
90
+ VALUE pAttrlist = G_DEF_CLASS(PANGO_TYPE_ATTR_LIST, "AttrList", mPango);
91
+
92
+ id_call = rb_intern("call");
93
+
94
+ rb_define_method(pAttrlist, "initialize", attrlist_initialize, 0);
95
+ rb_define_method(pAttrlist, "insert", attrlist_insert, 1);
96
+ rb_define_method(pAttrlist, "insert_before", attrlist_insert_before, 1);
97
+ rb_define_method(pAttrlist, "change", attrlist_change, 1);
98
+ rb_define_method(pAttrlist, "splice", attrlist_splice, 3);
99
+ #if PANGO_CHECK_VERSION(1,4,0)
100
+ rb_define_method(pAttrlist, "filter", attrlist_filter, 0);
101
+ #endif
102
+ rb_define_method(pAttrlist, "iterator", attrlist_get_iterator, 0);
103
+
104
+ }
@@ -0,0 +1,229 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbpangocairo.c -
5
+
6
+ $Author: ktou $
7
+ $Date: 2007/08/13 11:10:22 $
8
+
9
+ Copyright (C) 2005 Kouhei Sutou
10
+ Copyright (C) 2006 Ruby-GNOME2 Project Team
11
+ ************************************************/
12
+
13
+ #include "rbpango.h"
14
+
15
+ #if PANGO_CHECK_VERSION(1,10,0) && defined(HAVE_RB_CAIRO_H)
16
+ # define CAIRO_AVAILABLE 1
17
+ #endif
18
+
19
+ #ifdef CAIRO_AVAILABLE
20
+
21
+ #define _SELF(self) (PANGO_CAIRO_FONT_MAP(RVAL2GOBJ(self)))
22
+ #define RVAL2CONTEXT(v) (PANGO_CONTEXT(RVAL2GOBJ(v)))
23
+ #define RVAL2LAYOUT(v) (PANGO_LAYOUT(RVAL2GOBJ(v)))
24
+ #define RVAL2FONT(v) (PANGO_FONT(RVAL2GOBJ(v)))
25
+ #define RVAL2GLYPH(v) ((PangoGlyphString*)(RVAL2BOXED(self, PANGO_TYPE_GLYPH_STRING)))
26
+ #define RVAL2LINE(v) ((PangoLayoutLine*)RVAL2BOXED(v, PANGO_TYPE_LAYOUT_LINE))
27
+
28
+ static VALUE
29
+ font_map_create(klass)
30
+ VALUE klass;
31
+ {
32
+ return GOBJ2RVAL(pango_cairo_font_map_new());
33
+ }
34
+
35
+ static VALUE
36
+ font_map_get_default(klass)
37
+ VALUE klass;
38
+ {
39
+ return GOBJ2RVAL(pango_cairo_font_map_get_default());
40
+ }
41
+
42
+ static VALUE
43
+ font_map_set_resolution(self, dpi)
44
+ VALUE self, dpi;
45
+ {
46
+ pango_cairo_font_map_set_resolution(_SELF(self), NUM2DBL(dpi));
47
+ return self;
48
+ }
49
+
50
+ static VALUE
51
+ font_map_get_resolution(self)
52
+ VALUE self;
53
+ {
54
+ return rb_float_new(pango_cairo_font_map_get_resolution(_SELF(self)));
55
+ }
56
+
57
+ static VALUE
58
+ font_map_create_context(VALUE self)
59
+ {
60
+ return GOBJ2RVAL_UNREF(pango_cairo_font_map_create_context(_SELF(self)));
61
+ }
62
+
63
+ static VALUE
64
+ update_context(self, context)
65
+ VALUE self, context;
66
+ {
67
+ pango_cairo_update_context(RVAL2CRCONTEXT(self), RVAL2CONTEXT(context));
68
+ return self;
69
+ }
70
+
71
+ /* Convenience */
72
+ static VALUE
73
+ create_layout(VALUE self)
74
+ {
75
+ return GOBJ2RVAL_UNREF(pango_cairo_create_layout(RVAL2CRCONTEXT(self)));
76
+ }
77
+
78
+ static VALUE
79
+ update_layout(self, layout)
80
+ VALUE self, layout;
81
+ {
82
+ pango_cairo_update_layout(RVAL2CRCONTEXT(self), RVAL2LAYOUT(layout));
83
+ return self;
84
+ }
85
+
86
+ /* Rendering */
87
+ static VALUE
88
+ show_glyph_string(self, font, glyphs)
89
+ VALUE self, font, glyphs;
90
+ {
91
+ pango_cairo_show_glyph_string(RVAL2CRCONTEXT(self),
92
+ RVAL2FONT(font),
93
+ RVAL2GLYPH(glyphs));
94
+ return self;
95
+ }
96
+
97
+ static VALUE
98
+ show_layout_line(self, line)
99
+ VALUE self, line;
100
+ {
101
+ pango_cairo_show_layout_line(RVAL2CRCONTEXT(self), RVAL2LINE(line));
102
+ return self;
103
+ }
104
+
105
+ static VALUE
106
+ show_layout(self, layout)
107
+ VALUE self, layout;
108
+ {
109
+ pango_cairo_show_layout(RVAL2CRCONTEXT(self), RVAL2LAYOUT(layout));
110
+ return self;
111
+ }
112
+
113
+ #if PANGO_CHECK_VERSION(1,14,0)
114
+ static VALUE
115
+ show_error_underline(self, x, y, width, height)
116
+ VALUE self, x, y, width, height;
117
+ {
118
+ pango_cairo_show_error_underline(RVAL2CRCONTEXT(self),
119
+ NUM2DBL(x), NUM2DBL(y),
120
+ NUM2DBL(width), NUM2DBL(height));
121
+ return self;
122
+ }
123
+ #endif
124
+
125
+ /* Rendering to a path */
126
+ static VALUE
127
+ glyph_string_path(self, font, glyphs)
128
+ VALUE self, font, glyphs;
129
+ {
130
+ pango_cairo_glyph_string_path(RVAL2CRCONTEXT(self),
131
+ RVAL2FONT(font),
132
+ RVAL2GLYPH(glyphs));
133
+ return self;
134
+ }
135
+
136
+ static VALUE
137
+ layout_line_path(self, line)
138
+ VALUE self, line;
139
+ {
140
+ pango_cairo_layout_line_path(RVAL2CRCONTEXT(self), RVAL2LINE(line));
141
+ return self;
142
+ }
143
+
144
+ static VALUE
145
+ layout_path(self, layout)
146
+ VALUE self, layout;
147
+ {
148
+ pango_cairo_layout_path(RVAL2CRCONTEXT(self), RVAL2LAYOUT(layout));
149
+ return self;
150
+ }
151
+
152
+ #if PANGO_CHECK_VERSION(1,14,0)
153
+ static VALUE
154
+ error_underline_path(self, x, y, width, height)
155
+ VALUE self, x, y, width, height;
156
+ {
157
+ pango_cairo_error_underline_path(RVAL2CRCONTEXT(self),
158
+ NUM2DBL(x), NUM2DBL(y),
159
+ NUM2DBL(width), NUM2DBL(height));
160
+ return self;
161
+ }
162
+ #endif
163
+
164
+ #endif
165
+
166
+ static VALUE
167
+ cairo_available_p(VALUE self)
168
+ {
169
+ #if CAIRO_AVAILABLE
170
+ return Qtrue;
171
+ #else
172
+ return Qfalse;
173
+ #endif
174
+ }
175
+
176
+ void
177
+ Init_pango_cairo()
178
+ {
179
+ #ifdef CAIRO_AVAILABLE
180
+ VALUE pFontMap;
181
+
182
+ /* Pango::CairoFontMap */
183
+ pFontMap = G_DEF_CLASS(PANGO_TYPE_CAIRO_FONT_MAP, "CairoFontMap", mPango);
184
+
185
+ rb_define_singleton_method(pFontMap, "create", font_map_create, 0);
186
+ rb_define_singleton_method(pFontMap, "default", font_map_get_default, 0);
187
+
188
+ rb_define_method(pFontMap, "set_resolution", font_map_set_resolution, 1);
189
+ rb_define_method(pFontMap, "resolution", font_map_get_resolution, 0);
190
+ rb_define_method(pFontMap, "create_context", font_map_create_context, 0);
191
+
192
+ G_DEF_SETTERS(pFontMap);
193
+
194
+ /* Cairo::Context */
195
+ rb_define_method(rb_cCairo_Context, "update_pango_context",
196
+ update_context, 1);
197
+ /* Convenience */
198
+ rb_define_method(rb_cCairo_Context, "create_pango_layout",
199
+ create_layout, 0);
200
+ rb_define_method(rb_cCairo_Context, "update_pango_layout",
201
+ update_layout, 1);
202
+ /* Rendering */
203
+ rb_define_method(rb_cCairo_Context, "show_pango_glyph_string",
204
+ show_glyph_string, 2);
205
+ rb_define_method(rb_cCairo_Context, "show_pango_layout_line",
206
+ show_layout_line, 1);
207
+ rb_define_method(rb_cCairo_Context, "show_pango_layout",
208
+ show_layout, 1);
209
+ #if PANGO_CHECK_VERSION(1,14,0)
210
+ rb_define_method(rb_cCairo_Context, "show_pango_error_underline",
211
+ show_error_underline, 4);
212
+ #endif
213
+ /* Rendering to a path */
214
+ rb_define_method(rb_cCairo_Context, "pango_glyph_string_path",
215
+ glyph_string_path, 2);
216
+ rb_define_method(rb_cCairo_Context, "pango_layout_line_path",
217
+ layout_line_path, 1);
218
+ rb_define_method(rb_cCairo_Context, "pango_layout_path",
219
+ layout_path, 1);
220
+
221
+ #if PANGO_CHECK_VERSION(1,14,0)
222
+ rb_define_method(rb_cCairo_Context, "pango_error_underline_path",
223
+ error_underline_path, 4);
224
+ #endif
225
+
226
+ #endif
227
+
228
+ rb_define_module_function(mPango, "cairo_available?", cairo_available_p, 0);
229
+ }