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,91 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbpangoscriptiter.c -
5
+
6
+ $Author: sakai $
7
+ $Date: 2007/07/08 02:53:10 $
8
+
9
+ Copyright (C) 2005 Masao Mutoh
10
+ ************************************************/
11
+
12
+ #include "rbpango.h"
13
+
14
+ #if PANGO_CHECK_VERSION(1,4,0)
15
+
16
+ /**********************************/
17
+ static PangoScriptIter*
18
+ rbpango_script_iter_copy(ref)
19
+ PangoScriptIter* ref;
20
+ {
21
+ /*
22
+ PangoScriptIter* new_ref = pango_script_iter_new("", 0);
23
+ g_return_val_if_fail (ref != NULL, NULL);
24
+ new_ref = g_new(PangoScriptIter, 1);
25
+ *new_ref = *ref;
26
+ return new_ref;
27
+ */
28
+ return ref;
29
+ }
30
+
31
+ GType
32
+ pango_script_iter_get_type(void)
33
+ {
34
+ static GType our_type = 0;
35
+
36
+ if (our_type == 0)
37
+ our_type = g_boxed_type_register_static ("PangoScriptIter",
38
+ (GBoxedCopyFunc)rbpango_script_iter_copy,
39
+ (GBoxedFreeFunc)pango_script_iter_free);
40
+ return our_type;
41
+ }
42
+ /**********************************/
43
+
44
+ #define _SELF(r) ((PangoScriptIter*)RVAL2BOXED(r, PANGO_TYPE_SCRIPT_ITER))
45
+
46
+ static VALUE
47
+ rbpango_scriptiter_initialize(self, text)
48
+ VALUE self, text;
49
+ {
50
+ PangoScriptIter* iter;
51
+
52
+ StringValue(text);
53
+ iter = pango_script_iter_new(RVAL2CSTR(text), RSTRING_LEN(text));
54
+ G_INITIALIZE(self, iter);
55
+ return Qnil;
56
+ }
57
+
58
+ static VALUE
59
+ rbpango_scriptiter_get_range(self)
60
+ VALUE self;
61
+ {
62
+ G_CONST_RETURN char* start;
63
+ G_CONST_RETURN char* end;
64
+ PangoScript script;
65
+
66
+ pango_script_iter_get_range(_SELF(self), &start, &end, &script);
67
+
68
+ return rb_ary_new3(3, CSTR2RVAL(start), CSTR2RVAL(end),
69
+ GENUM2RVAL(script, PANGO_TYPE_SCRIPT));
70
+ }
71
+
72
+ static VALUE
73
+ rbpango_scriptiter_next(self)
74
+ VALUE self;
75
+ {
76
+ return CBOOL2RVAL(pango_script_iter_next(_SELF(self)));
77
+ }
78
+ #endif
79
+
80
+ void
81
+ Init_pango_script_iter()
82
+ {
83
+ #if PANGO_CHECK_VERSION(1,4,0)
84
+ VALUE scriter = G_DEF_CLASS(PANGO_TYPE_SCRIPT_ITER, "ScriptIter", mPango);
85
+
86
+ rb_define_method(scriter, "initialize", rbpango_scriptiter_initialize, 1);
87
+ rb_define_method(scriter, "range", rbpango_scriptiter_get_range, 0);
88
+ rb_define_method(scriter, "next!", rbpango_scriptiter_next, 0);
89
+ #endif
90
+ }
91
+
@@ -0,0 +1,128 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbpangoarray.c -
5
+
6
+ $Author: ggc $
7
+ $Date: 2007/07/13 16:07:33 $
8
+
9
+ Copyright (C) 2002,2003 Masao Mutoh
10
+ ************************************************/
11
+
12
+ #include "rbpango.h"
13
+
14
+ #define _SELF(self) ((PangoTabArray*)RVAL2BOXED(self, PANGO_TYPE_TAB_ARRAY))
15
+
16
+ static VALUE
17
+ rtab_initialize(argc, argv, self)
18
+ int argc;
19
+ VALUE *argv;
20
+ VALUE self;
21
+ {
22
+ VALUE size, positions_in_pixels, attr_ary;
23
+ PangoTabArray *array;
24
+ int i;
25
+
26
+ rb_scan_args(argc, argv, "2*", &size, &positions_in_pixels, &attr_ary);
27
+
28
+ array = pango_tab_array_new(NUM2INT(size),
29
+ RVAL2CBOOL(positions_in_pixels));
30
+ G_INITIALIZE(self, array);
31
+
32
+ if (! NIL_P(attr_ary)){
33
+ for (i = 0; i < RARRAY_LEN(attr_ary); i++) {
34
+ pango_tab_array_set_tab(array, i,
35
+ RVAL2GENUM(RARRAY_PTR(RARRAY_PTR(attr_ary)[i])[0], PANGO_TYPE_TAB_ALIGN),
36
+ FIX2INT(RARRAY_PTR(RARRAY_PTR(attr_ary)[i])[1]));
37
+ }
38
+ }
39
+
40
+ return Qnil;
41
+ }
42
+ /* This is implemented in rtab_initialize.
43
+ PangoTabArray* pango_tab_array_new_with_positions
44
+ (gint size,
45
+ gboolean positions_in_pixels,
46
+ PangoTabAlign first_alignment,
47
+ gint first_position,
48
+ ...);
49
+ */
50
+ static VALUE
51
+ rtab_get_size(self)
52
+ VALUE self;
53
+ {
54
+ return INT2NUM(pango_tab_array_get_size(_SELF(self)));
55
+ }
56
+
57
+ static VALUE
58
+ rtab_resize(self, size)
59
+ VALUE self, size;
60
+ {
61
+ pango_tab_array_resize(_SELF(self), NUM2INT(size));
62
+ return self;
63
+ }
64
+
65
+ static VALUE
66
+ rtab_set_tab(self, tab_index, align, location)
67
+ VALUE self, tab_index, align, location;
68
+ {
69
+ pango_tab_array_set_tab(_SELF(self), NUM2INT(tab_index), RVAL2GENUM(align, PANGO_TYPE_TAB_ALIGN),
70
+ NUM2INT(location));
71
+ return self;
72
+ }
73
+
74
+ static VALUE
75
+ rtab_get_tab(self, tab_index)
76
+ VALUE self, tab_index;
77
+ {
78
+ PangoTabAlign align;
79
+ gint location;
80
+ pango_tab_array_get_tab(_SELF(self), NUM2INT(tab_index),
81
+ &align, &location);
82
+ return rb_ary_new3(2, GENUM2RVAL(align, PANGO_TYPE_TAB_ALIGN), INT2NUM(location));
83
+ }
84
+
85
+ static VALUE
86
+ rtab_get_tabs(self)
87
+ VALUE self;
88
+ {
89
+ PangoTabAlign* aligns;
90
+ gint* locations;
91
+ VALUE ary = rb_ary_new();
92
+ PangoTabArray* tab_array = _SELF(self);
93
+ gint i;
94
+
95
+ pango_tab_array_get_tabs(tab_array, &aligns, &locations);
96
+
97
+ for (i = 0; i < pango_tab_array_get_size(tab_array); i++){
98
+ rb_ary_push(ary, rb_ary_new3(2, GENUM2RVAL(aligns[i], PANGO_TYPE_TAB_ALIGN),
99
+ INT2NUM(locations[i])));
100
+ }
101
+ return ary;
102
+ }
103
+
104
+ static VALUE
105
+ rtab_get_positions_in_pixels(self)
106
+ VALUE self;
107
+ {
108
+ return CBOOL2RVAL(pango_tab_array_get_positions_in_pixels(_SELF(self)));
109
+ }
110
+
111
+ void
112
+ Init_pango_array()
113
+ {
114
+ VALUE pTabArray = G_DEF_CLASS(PANGO_TYPE_TAB_ARRAY, "TabArray", mPango);
115
+ rb_define_method(pTabArray, "initialize", rtab_initialize, -1);
116
+ rb_define_method(pTabArray, "size", rtab_get_size, 0);
117
+ rb_define_method(pTabArray, "resize", rtab_resize, 1);
118
+ rb_define_method(pTabArray, "set_tab", rtab_set_tab, 3);
119
+ rb_define_method(pTabArray, "get_tab", rtab_get_tab, 1);
120
+ rb_define_method(pTabArray, "tabs", rtab_get_tabs, 0);
121
+ rb_define_method(pTabArray, "positions_in_pixels?", rtab_get_positions_in_pixels, 0);
122
+
123
+ G_DEF_SETTERS(pTabArray);
124
+
125
+ /* PangoTabAlign */
126
+ G_DEF_CLASS(PANGO_TYPE_TAB_ALIGN, "TabAlign", pTabArray);
127
+ G_DEF_CONSTANTS(pTabArray, PANGO_TYPE_TAB_ALIGN, "PANGO_");
128
+ }
@@ -0,0 +1,24 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbpangoversion.h -
5
+
6
+ This file was generated by mkmf-gnome2.rb.
7
+
8
+ ************************************************/
9
+
10
+ #ifndef __RBPANGO_VERSION_H__
11
+ #define __RBPANGO_VERSION_H__
12
+
13
+ #define PANGO_MAJOR_VERSION (1)
14
+ #define PANGO_MINOR_VERSION (24)
15
+ #define PANGO_MICRO_VERSION (5)
16
+
17
+ #define PANGO_CHECK_VERSION(major,minor,micro) \
18
+ (PANGO_MAJOR_VERSION > (major) || \
19
+ (PANGO_MAJOR_VERSION == (major) && PANGO_MINOR_VERSION > (minor)) || \
20
+ (PANGO_MAJOR_VERSION == (major) && PANGO_MINOR_VERSION == (minor) && \
21
+ PANGO_MICRO_VERSION >= (micro)))
22
+
23
+
24
+ #endif /* __RBPANGO_VERSION_H__ */
@@ -0,0 +1,9 @@
1
+ module PangoTestUtils
2
+ private
3
+ def only_pango_version(major, minor, micro=nil)
4
+ micro ||= 0
5
+ unless Pango.check_version?(major, minor, micro)
6
+ omit("Require Pango >= #{major}.#{minor}.#{micro}")
7
+ end
8
+ end
9
+ end
data/test/run-test.rb ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $VERBOSE = true
4
+
5
+ ruby_gnome2_base = File.join(File.dirname(__FILE__), "..", "..")
6
+ ruby_gnome2_base = File.expand_path(ruby_gnome2_base)
7
+
8
+ glib_base = File.join(ruby_gnome2_base, "glib")
9
+ pango_base = File.join(ruby_gnome2_base, "pango")
10
+
11
+ $LOAD_PATH.unshift(glib_base)
12
+ require 'test/glib-test-init'
13
+
14
+ [glib_base, pango_base].each do |target|
15
+ if system("which make > /dev/null")
16
+ `make -C #{target.dump} > /dev/null` or exit(1)
17
+ end
18
+ $LOAD_PATH.unshift(File.join(target, "src"))
19
+ $LOAD_PATH.unshift(File.join(target, "src", "lib"))
20
+ end
21
+
22
+ $LOAD_PATH.unshift(File.join(pango_base, "test"))
23
+ require 'pango-test-utils'
24
+
25
+ require 'pango'
26
+
27
+ exit Test::Unit::AutoRunner.run(true)
@@ -0,0 +1,19 @@
1
+ class TestAttribute < Test::Unit::TestCase
2
+ include PangoTestUtils
3
+
4
+ def setup
5
+ @attribute = Pango::AttrLanguage.new(Pango::Language.default)
6
+ end
7
+
8
+ def test_start_index
9
+ assert_equal(0, @attribute.start_index)
10
+ @attribute.start_index = 5
11
+ assert_equal(5, @attribute.start_index)
12
+ end
13
+
14
+ def test_end_index
15
+ assert_equal(GLib::MAXUINT, @attribute.end_index)
16
+ @attribute.end_index = 5
17
+ assert_equal(5, @attribute.end_index)
18
+ end
19
+ end
@@ -0,0 +1,7 @@
1
+ class TestLanguage < Test::Unit::TestCase
2
+ include PangoTestUtils
3
+
4
+ def test_default
5
+ assert_match(/\A[a-z]{2}-[a-z]{2}\z/, Pango::Language.default.to_s)
6
+ end
7
+ end
@@ -0,0 +1,20 @@
1
+ class TestLayout < Test::Unit::TestCase
2
+ include PangoTestUtils
3
+
4
+ def setup
5
+ @context = Pango::Context.new
6
+ @layout = Pango::Layout.new(@context)
7
+ end
8
+
9
+ def test_set_font_description
10
+ assert_nil(@layout.font_description)
11
+
12
+ @layout.font_description = "sans 14"
13
+ assert_equal("sans 14", @layout.font_description.to_s)
14
+
15
+ description = Pango::FontDescription.new("monospace")
16
+ description.size = 10 * Pango::SCALE
17
+ @layout.font_description = description
18
+ assert_equal("monospace 10", @layout.font_description.to_s)
19
+ end
20
+ end
metadata ADDED
@@ -0,0 +1,158 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pango
3
+ version: !ruby/object:Gem::Version
4
+ hash: 79
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 20
9
+ - 0
10
+ version: 0.20.0
11
+ platform: ruby
12
+ authors:
13
+ - ruby-gnome2/AUTHORS
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-07-11 00:00:00 -04:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: glib2
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: cairo
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ type: :runtime
48
+ version_requirements: *id002
49
+ description: Ruby/Pango is a Ruby binding of pango-1.x.
50
+ email: todd.fisher@gmail.com
51
+ executables: []
52
+
53
+ extensions:
54
+ - extconf.rb
55
+ extra_rdoc_files:
56
+ - README
57
+ files:
58
+ - ChangeLog
59
+ - README
60
+ - Rakefile
61
+ - extconf.rb
62
+ - src/lib/pango.rb
63
+ - src/makeinits.rb
64
+ - src/rbpango.c
65
+ - src/rbpangoanalysis.c
66
+ - src/rbpangoattribute.c
67
+ - src/rbpangoattriterator.c
68
+ - src/rbpangoattrlist.c
69
+ - src/rbpangocairo.c
70
+ - src/rbpangocolor.c
71
+ - src/rbpangocontext.c
72
+ - src/rbpangocoverage.c
73
+ - src/rbpangoengine.c
74
+ - src/rbpangofont.c
75
+ - src/rbpangofontdescription.c
76
+ - src/rbpangofontface.c
77
+ - src/rbpangofontfamily.c
78
+ - src/rbpangofontmap.c
79
+ - src/rbpangofontmetrics.c
80
+ - src/rbpangofontset.c
81
+ - src/rbpangofontsetsimple.c
82
+ - src/rbpangoglyphinfo.c
83
+ - src/rbpangoglyphitem.c
84
+ - src/rbpangoglyphstring.c
85
+ - src/rbpangogravity.c
86
+ - src/rbpangoinits.c
87
+ - src/rbpangoitem.c
88
+ - src/rbpangolanguage.c
89
+ - src/rbpangolayout.c
90
+ - src/rbpangolayoutiter.c
91
+ - src/rbpangolayoutline.c
92
+ - src/rbpangologattr.c
93
+ - src/rbpangomain.c
94
+ - src/rbpangomatrix.c
95
+ - src/rbpangorectangle.c
96
+ - src/rbpangorenderer.c
97
+ - src/rbpangoscript.c
98
+ - src/rbpangoscriptiter.c
99
+ - src/rbpangotabarray.c
100
+ - src/rbpango.h
101
+ - src/rbpangoversion.h
102
+ - sample/attribute.rb
103
+ - sample/break.rb
104
+ - sample/gdk_layout.rb
105
+ - sample/glyphstring.rb
106
+ - sample/item.rb
107
+ - sample/label.rb
108
+ - sample/layout.rb
109
+ - sample/pango_cairo.rb
110
+ - sample/parse.rb
111
+ - sample/sample.txt
112
+ - sample/script.rb
113
+ - test/pango-test-utils.rb
114
+ - test/run-test.rb
115
+ - test/test-attribute.rb
116
+ - test/test-language.rb
117
+ - test/test_layout.rb
118
+ has_rdoc: true
119
+ homepage: http://ruby-gnome2.sourceforge.jp/
120
+ licenses: []
121
+
122
+ post_install_message:
123
+ rdoc_options:
124
+ - --main
125
+ - README
126
+ require_paths:
127
+ - src
128
+ required_ruby_version: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ hash: 3
134
+ segments:
135
+ - 0
136
+ version: "0"
137
+ required_rubygems_version: !ruby/object:Gem::Requirement
138
+ none: false
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ hash: 3
143
+ segments:
144
+ - 0
145
+ version: "0"
146
+ requirements: []
147
+
148
+ rubyforge_project: pango
149
+ rubygems_version: 1.3.7
150
+ signing_key:
151
+ specification_version: 3
152
+ summary: Ruby pango bindings
153
+ test_files:
154
+ - test/pango-test-utils.rb
155
+ - test/run-test.rb
156
+ - test/test-attribute.rb
157
+ - test/test-language.rb
158
+ - test/test_layout.rb