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,178 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbpangolayoutline.c -
5
+
6
+ $Author: mutoh $
7
+ $Date: 2005/02/13 17:31:33 $
8
+
9
+ Copyright (C) 2002,2003 Masao Mutoh
10
+ ************************************************/
11
+
12
+ #include "rbpango.h"
13
+
14
+ #define _SELF(s) ((PangoRectangle*)RVAL2BOXED(s, PANGO_TYPE_RECTANGLE))
15
+
16
+ /**********************************/
17
+ static PangoRectangle*
18
+ pango_rectangle_copy(ref)
19
+ const PangoRectangle* ref;
20
+ {
21
+ PangoRectangle* new_ref;
22
+ g_return_val_if_fail (ref != NULL, NULL);
23
+ new_ref = g_new(PangoRectangle, 1);
24
+ *new_ref = *ref;
25
+ return new_ref;
26
+ }
27
+
28
+ GType
29
+ pango_rectangle_get_type(void)
30
+ {
31
+ static GType our_type = 0;
32
+
33
+ if (our_type == 0)
34
+ our_type = g_boxed_type_register_static ("PangoRectangle",
35
+ (GBoxedCopyFunc)pango_rectangle_copy,
36
+ (GBoxedFreeFunc)g_free);
37
+ return our_type;
38
+ }
39
+ /**********************************/
40
+
41
+ static VALUE
42
+ pango_rectangle_initialize(self, x, y, width, height)
43
+ VALUE self, x, y, width, height;
44
+ {
45
+ PangoRectangle new;
46
+
47
+ new.x = NUM2INT(x);
48
+ new.y = NUM2INT(y);
49
+ new.width = NUM2INT(width);
50
+ new.height = NUM2INT(height);
51
+
52
+ G_INITIALIZE(self, &new);
53
+ return Qnil;
54
+ }
55
+
56
+
57
+ static VALUE
58
+ pango_rectangle_x(self)
59
+ VALUE self;
60
+ {
61
+ return INT2NUM(_SELF(self)->x);
62
+ }
63
+
64
+ static VALUE
65
+ pango_rectangle_y(self)
66
+ VALUE self;
67
+ {
68
+ return INT2NUM(_SELF(self)->y);
69
+ }
70
+
71
+ static VALUE
72
+ pango_rectangle_w(self)
73
+ VALUE self;
74
+ {
75
+ return INT2NUM(_SELF(self)->width);
76
+ }
77
+
78
+ static VALUE
79
+ pango_rectangle_h(self)
80
+ VALUE self;
81
+ {
82
+ return INT2NUM(_SELF(self)->height);
83
+ }
84
+
85
+ static VALUE
86
+ pango_rectangle_set_x(self, x)
87
+ VALUE self, x;
88
+ {
89
+ _SELF(self)->x = NUM2INT(x);
90
+ return self;
91
+ }
92
+
93
+ static VALUE
94
+ pango_rectangle_set_y(self, y)
95
+ VALUE self, y;
96
+ {
97
+ _SELF(self)->y = NUM2INT(y);
98
+ return self;
99
+ }
100
+ static VALUE
101
+ pango_rectangle_set_w(self, width)
102
+ VALUE self, width;
103
+ {
104
+ _SELF(self)->width = NUM2INT(width);
105
+ return self;
106
+ }
107
+
108
+ static VALUE
109
+ pango_rectangle_set_h(self, height)
110
+ VALUE self, height;
111
+ {
112
+ _SELF(self)->height = NUM2INT(height);
113
+ return self;
114
+ }
115
+ static VALUE
116
+ pango_rectangle_to_a(self)
117
+ VALUE self;
118
+ {
119
+ PangoRectangle* a = _SELF(self);
120
+ return rb_ary_new3(4, INT2FIX(a->x), INT2FIX(a->y),
121
+ INT2FIX(a->width), INT2FIX(a->height));
122
+ }
123
+
124
+ static VALUE
125
+ pango_rectangle_ascent(self)
126
+ VALUE self;
127
+ {
128
+ PangoRectangle* r =_SELF(self);
129
+ return INT2NUM(PANGO_ASCENT(*r));
130
+ }
131
+
132
+ static VALUE
133
+ pango_rectangle_descent(self)
134
+ VALUE self;
135
+ {
136
+ PangoRectangle* r =_SELF(self);
137
+ return INT2NUM(PANGO_DESCENT(*r));
138
+ }
139
+
140
+ static VALUE
141
+ pango_rectangle_lbearing(self)
142
+ VALUE self;
143
+ {
144
+ PangoRectangle* r =_SELF(self);
145
+ return INT2NUM(PANGO_LBEARING(*r));
146
+ }
147
+
148
+ static VALUE
149
+ pango_rectangle_rbearing(self)
150
+ VALUE self;
151
+ {
152
+ PangoRectangle* r =_SELF(self);
153
+ return INT2NUM(PANGO_RBEARING(*r));
154
+ }
155
+
156
+
157
+ void
158
+ Init_pango_rectangle()
159
+ {
160
+ VALUE pRectangle = G_DEF_CLASS(PANGO_TYPE_RECTANGLE, "Rectangle", mPango);
161
+ rb_define_method(pRectangle, "initialize", pango_rectangle_initialize, 4);
162
+ rb_define_method(pRectangle, "x", pango_rectangle_x, 0);
163
+ rb_define_method(pRectangle, "y", pango_rectangle_y, 0);
164
+ rb_define_method(pRectangle, "width", pango_rectangle_w, 0);
165
+ rb_define_method(pRectangle, "height", pango_rectangle_h, 0);
166
+ rb_define_method(pRectangle, "set_x", pango_rectangle_set_x, 1);
167
+ rb_define_method(pRectangle, "set_y", pango_rectangle_set_y, 1);
168
+ rb_define_method(pRectangle, "set_width", pango_rectangle_set_w, 1);
169
+ rb_define_method(pRectangle, "set_height", pango_rectangle_set_h, 1);
170
+ rb_define_method(pRectangle, "to_a", pango_rectangle_to_a, 0);
171
+
172
+ rb_define_method(pRectangle, "ascent", pango_rectangle_ascent, 0);
173
+ rb_define_method(pRectangle, "descent", pango_rectangle_descent, 0);
174
+ rb_define_method(pRectangle, "lbearing", pango_rectangle_lbearing, 0);
175
+ rb_define_method(pRectangle, "rbearing", pango_rectangle_rbearing, 0);
176
+
177
+ G_DEF_SETTERS(pRectangle);
178
+ }
@@ -0,0 +1,204 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbpangorenderer.c -
5
+
6
+ $Author: ggc $
7
+ $Date: 2006/06/22 19:52:54 $
8
+
9
+ Copyright (C) 2005 Masao Mutoh
10
+ ************************************************/
11
+
12
+ #include "rbpango.h"
13
+
14
+ #if PANGO_CHECK_VERSION(1,8,0)
15
+ #define _SELF(self) (PANGO_RENDERER(RVAL2GOBJ(self)))
16
+
17
+ static VALUE
18
+ renderer_draw_layout(self, layout, x, y)
19
+ VALUE self, layout, x, y;
20
+ {
21
+ pango_renderer_draw_layout(_SELF(self),
22
+ PANGO_LAYOUT(RVAL2GOBJ(layout)),
23
+ NUM2INT(x), NUM2INT(y));
24
+ return self;
25
+ }
26
+
27
+ static VALUE
28
+ renderer_draw_layout_line(self, line, x, y)
29
+ VALUE self, line, x, y;
30
+ {
31
+ pango_renderer_draw_layout_line(_SELF(self),
32
+ (PangoLayoutLine*)RVAL2BOXED(line, PANGO_TYPE_LAYOUT_LINE),
33
+ NUM2INT(x), NUM2INT(y));
34
+ return self;
35
+ }
36
+
37
+ static VALUE
38
+ renderer_draw_glyphs(self, font, glyphs, x, y)
39
+ VALUE self, font, glyphs, x, y;
40
+ {
41
+ pango_renderer_draw_glyphs(_SELF(self),
42
+ PANGO_FONT(RVAL2GOBJ(self)),
43
+ (PangoGlyphString*)(RVAL2BOXED(self, PANGO_TYPE_GLYPH_STRING)),
44
+ NUM2INT(x), NUM2INT(y));
45
+ return self;
46
+ }
47
+
48
+ static VALUE
49
+ renderer_draw_rectangle(self, part, x, y, width, height)
50
+ VALUE self, part, x, y, width, height;
51
+ {
52
+ #if HAVE_PANGO_RENDER_PART_GET_TYPE
53
+ pango_renderer_draw_rectangle(_SELF(self), RVAL2GENUM(part, PANGO_TYPE_RENDER_PART),
54
+ NUM2INT(x), NUM2INT(y), NUM2INT(width), NUM2INT(height));
55
+ #else
56
+ pango_renderer_draw_rectangle(_SELF(self), NUM2INT(part),
57
+ NUM2INT(x), NUM2INT(y), NUM2INT(width), NUM2INT(height));
58
+ #endif
59
+ return self;
60
+ }
61
+
62
+ static VALUE
63
+ renderer_draw_error_underline(self, x, y, width, height)
64
+ VALUE self, x, y, width, height;
65
+ {
66
+ pango_renderer_draw_error_underline(_SELF(self),
67
+ NUM2INT(x), NUM2INT(y), NUM2INT(width), NUM2INT(height));
68
+ return self;
69
+ }
70
+
71
+ static VALUE
72
+ renderer_draw_trapezoid(self, part, y1, x11, x21, y2, x12, x22)
73
+ VALUE self, part, y1, x11, x21, y2, x12, x22;
74
+ {
75
+ #if HAVE_PANGO_RENDER_PART_GET_TYPE
76
+ pango_renderer_draw_trapezoid(_SELF(self),
77
+ RVAL2GENUM(part, PANGO_TYPE_RENDER_PART),
78
+ NUM2DBL(y1), NUM2DBL(x11), NUM2DBL(x21),
79
+ NUM2DBL(y2), NUM2DBL(x12), NUM2DBL(x22));
80
+ #else
81
+ pango_renderer_draw_trapezoid(_SELF(self), NUM2INT(part),
82
+ NUM2DBL(y1), NUM2DBL(x11), NUM2DBL(x21),
83
+ NUM2DBL(y2), NUM2DBL(x12), NUM2DBL(x22));
84
+ #endif
85
+ return self;
86
+ }
87
+
88
+ static VALUE
89
+ renderer_draw_glyph(self, font, glyph, x, y)
90
+ VALUE self, font, glyph, x, y;
91
+ {
92
+ pango_renderer_draw_glyph(_SELF(self), PANGO_FONT(RVAL2GOBJ(self)),
93
+ NUM2INT(glyph), NUM2INT(x), NUM2INT(y));
94
+ return self;
95
+ }
96
+
97
+ static VALUE
98
+ renderer_deactivate(self)
99
+ VALUE self;
100
+ {
101
+ pango_renderer_deactivate(_SELF(self));
102
+ return self;
103
+ }
104
+
105
+ static VALUE
106
+ renderer_activate(self)
107
+ VALUE self;
108
+ {
109
+ pango_renderer_activate(_SELF(self));
110
+ if (rb_block_given_p()) {
111
+ rb_ensure(rb_yield, self, renderer_deactivate, self);
112
+ }
113
+ return self;
114
+ }
115
+
116
+ static VALUE
117
+ renderer_part_changed(self, part)
118
+ VALUE self, part;
119
+ {
120
+ #if HAVE_PANGO_RENDER_PART_GET_TYPE
121
+ pango_renderer_part_changed(_SELF(self), RVAL2GENUM(part, PANGO_TYPE_RENDER_PART));
122
+ #else
123
+ pango_renderer_part_changed(_SELF(self), NUM2INT(part));
124
+ #endif
125
+ return self;
126
+ }
127
+
128
+ static VALUE
129
+ renderer_set_color(self, part, color)
130
+ VALUE self, part, color;
131
+ {
132
+ #if HAVE_PANGO_RENDER_PART_GET_TYPE
133
+ pango_renderer_set_color(_SELF(self), RVAL2GENUM(part, PANGO_TYPE_RENDER_PART),
134
+ (PangoColor*)(NIL_P(color) ? NULL : RVAL2BOXED(color, PANGO_TYPE_COLOR)));
135
+ #else
136
+ pango_renderer_set_color(_SELF(self), NUM2INT(part),
137
+ (PangoColor*)(NIL_P(color) ? NULL : RVAL2BOXED(color, PANGO_TYPE_COLOR)));
138
+ #endif
139
+ return self;
140
+ }
141
+
142
+ static VALUE
143
+ renderer_get_color(self, part)
144
+ VALUE self, part;
145
+ {
146
+ #if HAVE_PANGO_RENDER_PART_GET_TYPE
147
+ PangoColor* color = pango_renderer_get_color(_SELF(self),
148
+ RVAL2GENUM(part, PANGO_TYPE_RENDER_PART));
149
+ #else
150
+ PangoColor* color = pango_renderer_get_color(_SELF(self),NUM2INT(part));
151
+ #endif
152
+ return BOXED2RVAL(color, PANGO_TYPE_COLOR);
153
+ }
154
+
155
+ static VALUE
156
+ renderer_set_matrix(self, matrix)
157
+ VALUE self, matrix;
158
+ {
159
+ pango_renderer_set_matrix(_SELF(self),
160
+ (PangoMatrix*)(NIL_P(matrix) ? NULL : RVAL2BOXED(matrix, PANGO_TYPE_MATRIX)));
161
+ return self;
162
+ }
163
+
164
+ static VALUE
165
+ renderer_get_matrix(self)
166
+ VALUE self;
167
+ {
168
+ const PangoMatrix* matrix = pango_renderer_get_matrix(_SELF(self));
169
+ return BOXED2RVAL((PangoMatrix*)matrix, PANGO_TYPE_MATRIX);
170
+ }
171
+
172
+ #endif
173
+
174
+ void
175
+ Init_pangorenderer()
176
+ {
177
+ #if PANGO_CHECK_VERSION(1,8,0)
178
+ VALUE renderer = G_DEF_CLASS(PANGO_TYPE_RENDERER, "Renderer", mPango);
179
+
180
+ rb_define_method(renderer, "draw_layout", renderer_draw_layout, 3);
181
+ rb_define_method(renderer, "draw_layout_line", renderer_draw_layout_line, 3);
182
+ rb_define_method(renderer, "draw_glyphs", renderer_draw_glyphs, 4);
183
+ rb_define_method(renderer, "draw_rectangle", renderer_draw_rectangle, 5);
184
+ rb_define_method(renderer, "draw_error_underline", renderer_draw_error_underline, 4);
185
+ rb_define_method(renderer, "draw_trapezoid", renderer_draw_trapezoid, 7);
186
+ rb_define_method(renderer, "draw_glyph", renderer_draw_glyph, 4);
187
+ rb_define_method(renderer, "activate", renderer_activate, 0);
188
+ rb_define_method(renderer, "deactivate", renderer_deactivate, 0);
189
+ rb_define_method(renderer, "part_changed", renderer_part_changed, 1);
190
+ rb_define_method(renderer, "set_color", renderer_set_color, 2);
191
+ rb_define_method(renderer, "get_color", renderer_get_color, 1);
192
+ rb_define_method(renderer, "set_matrix", renderer_set_matrix, 1);
193
+ rb_define_method(renderer, "matrix", renderer_get_matrix, 0);
194
+
195
+ G_DEF_SETTERS(renderer);
196
+
197
+ /* PangoRenderPart */
198
+ #if HAVE_PANGO_RENDER_PART_GET_TYPE
199
+ G_DEF_CLASS(PANGO_TYPE_RENDER_PART, "Part", renderer);
200
+ G_DEF_CONSTANTS(renderer, PANGO_TYPE_RENDER_PART, "PANGO_RENDER_");
201
+ #endif
202
+
203
+ #endif
204
+ }
@@ -0,0 +1,80 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbpangoscript.c -
5
+
6
+ $Author: ggc $
7
+ $Date: 2006/06/22 19:52:54 $
8
+
9
+ Copyright (C) 2005 Masao Mutoh
10
+ ************************************************/
11
+
12
+ #include "rbpango.h"
13
+
14
+ #if PANGO_CHECK_VERSION(1,4,0)
15
+ #define _SELF(r) (RVAL2GENUM(r, PANGO_TYPE_SCRIPT))
16
+
17
+ static VALUE
18
+ rbpango_s_script_for_unichar(self, ch)
19
+ VALUE self, ch;
20
+ {
21
+ return GENUM2RVAL(pango_script_for_unichar(NUM2UINT(ch)), PANGO_TYPE_SCRIPT);
22
+ }
23
+
24
+ static VALUE
25
+ rbpango_script_get_sample_language(self)
26
+ VALUE self;
27
+ {
28
+ PangoLanguage* lang = pango_script_get_sample_language(_SELF(self));
29
+ return BOXED2RVAL(lang, PANGO_TYPE_LANGUAGE);
30
+ }
31
+
32
+ #if PANGO_CHECK_VERSION(1,16,0)
33
+ static VALUE
34
+ rbpango_script_get_gravity(int argc, VALUE *argv, VALUE self)
35
+ {
36
+ VALUE wide, gravity, gravity_hint;
37
+ int n;
38
+ PangoGravity g;
39
+
40
+ n = rb_scan_args(argc, argv, "21", &gravity, &gravity_hint, &wide);
41
+
42
+ if (n == 2) {
43
+ g = pango_gravity_get_for_script(_SELF(self),
44
+ RVAL2GENUM(gravity, PANGO_TYPE_GRAVITY),
45
+ RVAL2GENUM(gravity_hint, PANGO_TYPE_GRAVITY_HINT));
46
+ } else {
47
+ # if PANGO_CHECK_VERSION(1,26,0)
48
+ g = pango_gravity_get_for_script_and_width(_SELF(self),
49
+ RVAL2CBOOL(wide),
50
+ RVAL2GENUM(gravity, PANGO_TYPE_GRAVITY),
51
+ RVAL2GENUM(gravity_hint, PANGO_TYPE_GRAVITY_HINT));
52
+ # else
53
+ rb_raise(rb_eArgError,
54
+ "the 3rd 'wide' argument requires Pango >= 1.26");
55
+ # endif
56
+ }
57
+ return GENUM2RVAL(g, PANGO_TYPE_GRAVITY);
58
+ }
59
+ #endif
60
+
61
+ /* Move to Pango::Language
62
+ gboolean pango_language_includes_script (PangoLanguage *language,
63
+ PangoScript script);
64
+ */
65
+ #endif
66
+
67
+ void
68
+ Init_pango_script()
69
+ {
70
+ #if PANGO_CHECK_VERSION(1,4,0)
71
+ VALUE script = G_DEF_CLASS(PANGO_TYPE_SCRIPT, "Script", mPango);
72
+
73
+ rb_define_singleton_method(script, "for_unichar", rbpango_s_script_for_unichar, 1);
74
+ rb_define_method(script, "sample_language", rbpango_script_get_sample_language, 0);
75
+ #endif
76
+ #if PANGO_CHECK_VERSION(1,16,0)
77
+ rb_define_method(script, "get_gravity", rbpango_script_get_gravity, -1);
78
+ #endif
79
+ }
80
+