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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7c75aaa3b2c84becd0e4c4513adcf0e81d9cc9be
4
- data.tar.gz: 298d5d938d320058fbac424e53ff52e9bd2409ce
3
+ metadata.gz: 81dda8d141ed08f5b87af59503e32fb3d25d4f34
4
+ data.tar.gz: f43b49f350c5cb009ddcfd29b8525089c72a3220
5
5
  SHA512:
6
- metadata.gz: 6fdd25d2b63cffa6473b6fdb14ae1c8ac0293a98a6112207ef0d58b961132455b8ec1fd5a0cdeca885be2336e5f6d47d83356c811e34b2a320452e519957c62b
7
- data.tar.gz: '0296e017cfb9465beef60c6474a155581d19785373d29172781f79396529dc184a4a26e4bea662c0e33830a198e2658418f1c3412e3f7650a0d3c6d4161cef4c'
6
+ metadata.gz: 04f1130e8d4283cbe97d4368ef50776115edd5963c76c05b6da4f9ebe0be9d5c9b9660c02feb35b4cc5fd63bea47f92730a9f746799bcd9d85013df2cd6aab7c
7
+ data.tar.gz: b92720c3c3260a78f91cd6ecb1eb6158b7d30c17e1ec132377b7e8fcbb0639e7577101ef9eb8045ff7ece17ba133a610adb2c3836fd9f95f96c7e1d93fc60c41
data/Rakefile CHANGED
@@ -22,10 +22,18 @@ require "gnome2/rake/package-task"
22
22
  package_task = GNOME2::Rake::PackageTask.new do |package|
23
23
  package.summary = "Ruby/Pango is a Ruby binding of pango-1.x."
24
24
  package.description = "Ruby/Pango is a Ruby binding of pango-1.x."
25
- package.dependency.gem.runtime = [["cairo", ">= 1.14.0"], "glib2"]
25
+ package.dependency.gem.runtime = [
26
+ ["cairo", ">= 1.14.0"],
27
+ "cairo-gobject",
28
+ "gobject-introspection",
29
+ ]
26
30
  package.windows.packages = []
27
31
  package.windows.dependencies = []
28
- package.windows.build_dependencies = ["glib2", "gobject-introspection"]
32
+ package.windows.build_dependencies = [
33
+ "glib2",
34
+ "gobject-introspection",
35
+ "cairo-gobject",
36
+ ]
29
37
  package.external_packages = [
30
38
  {
31
39
  :name => "icu",
@@ -55,7 +63,7 @@ package_task = GNOME2::Rake::PackageTask.new do |package|
55
63
  :name => "harfbuzz",
56
64
  :download_site => :freedesktop,
57
65
  :label => "HarfBuzz",
58
- :version => "1.4.1",
66
+ :version => "1.4.6",
59
67
  :compression_method => "bz2",
60
68
  :windows => {
61
69
  :configure_args => [
@@ -65,11 +73,25 @@ package_task = GNOME2::Rake::PackageTask.new do |package|
65
73
  :built_file => "bin/libharfbuzz-0.dll",
66
74
  },
67
75
  },
76
+ {
77
+ :name => "graphene",
78
+ :download_site => :gnome,
79
+ :label => "Graphene",
80
+ :version => "1.6.0",
81
+ :compression_method => "xz",
82
+ :windows => {
83
+ :configure_args => [
84
+ "--enable-introspection",
85
+ "--disable-benchmarks",
86
+ ],
87
+ :built_file => "bin/libgraphene-1.0-0.dll",
88
+ },
89
+ },
68
90
  {
69
91
  :name => "pango",
70
92
  :download_site => :gnome,
71
- :label => "pango",
72
- :version => "1.40.3",
93
+ :label => "Pango",
94
+ :version => "1.40.5",
73
95
  :compression_method => "xz",
74
96
  :windows => {
75
97
  :configure_args => [
data/ext/pango/depend CHANGED
@@ -1,7 +1,7 @@
1
1
  install-so: install-headers
2
2
  install-headers:
3
- $(INSTALL_DATA) $(srcdir)/rbpango.h $(RUBYARCHDIR)
4
- $(INSTALL_DATA) $(srcdir)/rbpangoconversions.h $(RUBYARCHDIR)
3
+ $(INSTALL_DATA) $(srcdir)/rb-pango.h $(RUBYARCHDIR)
4
+ $(INSTALL_DATA) $(srcdir)/rb-pango-conversions.h $(RUBYARCHDIR)
5
5
 
6
6
  install: install-pc
7
7
  install-pc:
data/ext/pango/extconf.rb CHANGED
@@ -1,19 +1,33 @@
1
- =begin
2
- extconf.rb for Ruby/Pango extention library
3
- =end
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Copyright (C) 2017 Ruby-GNOME2 Project Team
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2.1 of the License, or (at your option) any later version.
9
+ #
10
+ # This library is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the Free Software
17
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
4
18
 
5
- require 'pathname'
19
+ require "pathname"
6
20
 
7
21
  base_dir = Pathname(__FILE__).dirname.parent.parent.expand_path
8
22
  top_dir = base_dir.parent
9
23
  top_build_dir = Pathname(".").parent.parent.parent.expand_path
10
24
 
11
- mkmf_gnome2_dir = top_dir + "glib2" + 'lib'
25
+ mkmf_gnome2_dir = top_dir + "glib2" + "lib"
12
26
  version_suffix = ""
13
27
  unless mkmf_gnome2_dir.exist?
14
- if /(-\d+\.\d+\.\d+)(?:\.\d+)?\z/ =~ base_dir.basename.to_s
28
+ if /(-\d+\.\d+\.\d+)\z/ =~ base_dir.basename.to_s
15
29
  version_suffix = $1
16
- mkmf_gnome2_dir = top_dir + "glib2#{version_suffix}" + 'lib'
30
+ mkmf_gnome2_dir = top_dir + "glib2#{version_suffix}" + "lib"
17
31
  end
18
32
  end
19
33
 
@@ -22,20 +36,16 @@ $LOAD_PATH.unshift(mkmf_gnome2_dir.to_s)
22
36
  module_name = "pango"
23
37
  package_id = "pango"
24
38
 
25
- begin
26
- require 'mkmf-gnome2'
27
- rescue LoadError
28
- require 'rubygems'
29
- gem 'glib2'
30
- require 'mkmf-gnome2'
31
- end
32
-
33
- ruby_header = "ruby.h"
34
- have_func("rb_errinfo", ruby_header)
39
+ require "mkmf-gnome2"
35
40
 
36
- ["glib2"].each do |package|
41
+ depended_packages = [
42
+ "glib2",
43
+ ]
44
+ depended_packages.each do |package|
37
45
  directory = "#{package}#{version_suffix}"
38
- build_dir = "#{directory}/tmp/#{RUBY_PLATFORM}/#{package}/#{RUBY_VERSION}"
46
+ build_base_path = "#{directory}/tmp/#{RUBY_PLATFORM}"
47
+ package_library_name = package.gsub(/-/, "_")
48
+ build_dir = "#{build_base_path}/#{package_library_name}/#{RUBY_VERSION}"
39
49
  add_depend_package(package, "#{directory}/ext/#{package}",
40
50
  top_dir.to_s,
41
51
  :top_build_dir => top_build_dir.to_s,
@@ -49,15 +59,15 @@ end
49
59
  setup_windows(module_name, base_dir)
50
60
 
51
61
  unless required_pkg_config_package([package_id, 1, 14, 0],
52
- :altlinux => "libpango-devel",
62
+ :alt_linux => "libpango-devel",
53
63
  :debian => "libpango1.0-dev",
54
64
  :redhat => "pango-devel",
55
- :arch => "pango",
65
+ :arch_linux => "pango",
56
66
  :homebrew => "pango",
57
67
  :macports => "pango")
58
68
  exit(false)
59
69
  end
60
- PKGConfig.have_package('pangocairo')
70
+ PKGConfig.have_package("pangocairo")
61
71
 
62
72
  if PKGConfig.have_package("pangowin32")
63
73
  $defs << " -DHAVE_PANGO_WIN32"
@@ -67,15 +77,9 @@ if PKGConfig.have_package("pangoft2")
67
77
  end
68
78
 
69
79
  pango_header = "pango/pango.h"
70
- have_func("pango_layout_iter_get_type", pango_header)
71
- have_func("pango_render_part_get_type", pango_header)
72
80
  have_func("pango_attr_strikethrough_color_new", pango_header)
73
81
  have_func("pango_attr_underline_color_new", pango_header)
74
- have_func("pango_glyph_item_free", pango_header)
75
- have_func("pango_glyph_item_get_type", pango_header)
76
82
  have_func("pango_attr_iterator_get_attrs", pango_header)
77
- have_func("pango_itemize_with_base_dir", pango_header)
78
- have_func("pango_font_family_is_monospace", pango_header)
79
83
 
80
84
  create_pkg_config_file("Ruby/Pango", package_id)
81
85
  $defs << " -DRUBY_PANGO_COMPILATION"
data/ext/pango/pango.def CHANGED
@@ -1,18 +1,2 @@
1
1
  EXPORTS
2
2
  Init_pango
3
- mPango DATA
4
- attrstring DATA
5
- pattr DATA
6
- pattrbool DATA
7
- pattrcolor DATA
8
- pattrfloat DATA
9
- pattrint DATA
10
- pango_add_attribute
11
- pango_attr_iter_get_type
12
- pango_get_attribute
13
- pango_get_attribute_klass
14
- pango_item_get_type
15
- pango_layout_iter_get_type
16
- pango_layout_line_get_type
17
- pango_make_attribute
18
- pango_rectangle_get_type
@@ -0,0 +1,64 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright (C) 2017 Ruby-GNOME2 Project Team
4
+ *
5
+ * This library is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU Lesser General Public
7
+ * License as published by the Free Software Foundation; either
8
+ * version 2.1 of the License, or (at your option) any later version.
9
+ *
10
+ * This library is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ * Lesser General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Lesser General Public
16
+ * License along with this library; if not, write to the Free Software
17
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
+ * MA 02110-1301 USA
19
+ */
20
+
21
+ #include "rb-pango-private.h"
22
+
23
+ #define RG_TARGET_NAMESPACE cAttrList
24
+
25
+ static VALUE
26
+ rg_insert(VALUE self, VALUE rb_attribute)
27
+ {
28
+ PangoAttribute *attribute;
29
+
30
+ if (NIL_P(rb_attribute))
31
+ return self;
32
+
33
+ attribute = DATA_PTR(rb_attribute);
34
+ pango_attr_list_insert(RVAL2PANGOATTRLIST(self),
35
+ pango_attribute_copy(attribute));
36
+
37
+ return self;
38
+ }
39
+
40
+ static VALUE
41
+ rg_insert_before(VALUE self, VALUE rb_attribute)
42
+ {
43
+ PangoAttribute *attribute;
44
+
45
+ if (NIL_P(rb_attribute))
46
+ return self;
47
+
48
+ attribute = DATA_PTR(rb_attribute);
49
+ pango_attr_list_insert_before(RVAL2PANGOATTRLIST(self),
50
+ pango_attribute_copy(attribute));
51
+
52
+ return self;
53
+ }
54
+
55
+ void
56
+ rbpango_attr_list_init(VALUE mPango)
57
+ {
58
+ VALUE RG_TARGET_NAMESPACE;
59
+
60
+ RG_TARGET_NAMESPACE = G_DEF_CLASS(PANGO_TYPE_ATTR_LIST, "AttrList", mPango);
61
+
62
+ RG_DEF_METHOD(insert, 1);
63
+ RG_DEF_METHOD(insert_before, 1);
64
+ }
@@ -0,0 +1,147 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright (C) 2017 Ruby-GNOME2 Project Team
4
+ *
5
+ * This library is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU Lesser General Public
7
+ * License as published by the Free Software Foundation; either
8
+ * version 2.1 of the License, or (at your option) any later version.
9
+ *
10
+ * This library is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ * Lesser General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Lesser General Public
16
+ * License along with this library; if not, write to the Free Software
17
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
+ * MA 02110-1301 USA
19
+ */
20
+
21
+ #include "rb-pango-private.h"
22
+
23
+ static VALUE
24
+ rbpango_attribute_allocate(VALUE klass)
25
+ {
26
+ return Data_Wrap_Struct(klass, NULL, pango_attribute_destroy, 0);
27
+ }
28
+
29
+ static VALUE
30
+ rbpango_attr_font_desc_initialize(VALUE self, VALUE rb_font_desc)
31
+ {
32
+ PangoFontDescription *font_desc;
33
+
34
+ if (RB_TYPE_P(rb_font_desc, RUBY_T_STRING)) {
35
+ VALUE mPango;
36
+ VALUE cPangoFontDescription;
37
+
38
+ mPango = rb_const_get(rb_cObject, rb_intern("Pango"));
39
+ cPangoFontDescription = rb_const_get(mPango,
40
+ rb_intern("FontDescription"));
41
+ rb_font_desc = rb_funcall(cPangoFontDescription,
42
+ rb_intern("new"), 1, rb_font_desc);
43
+ }
44
+ font_desc = RVAL2PANGOFONTDESCRIPTION(rb_font_desc);
45
+ DATA_PTR(self) = pango_attr_font_desc_new(font_desc);
46
+
47
+ return Qnil;
48
+ }
49
+
50
+ static VALUE
51
+ rbpango_attr_font_features_initialize(VALUE self, VALUE rb_font_features)
52
+ {
53
+ DATA_PTR(self) = pango_attr_font_features_new(RVAL2CSTR(rb_font_features));
54
+
55
+ return Qnil;
56
+ }
57
+
58
+ static VALUE
59
+ rbpango_attr_language_initialize(VALUE self, VALUE rb_language)
60
+ {
61
+ PangoLanguage *language;
62
+
63
+ language = RVAL2PANGOLANGUAGE(rb_language);
64
+ DATA_PTR(self) = pango_attr_language_new(language);
65
+
66
+ return Qnil;
67
+ }
68
+
69
+ static VALUE
70
+ rbpango_attr_shape_initialize(int argc, VALUE *argv, VALUE self)
71
+ {
72
+ VALUE rb_ink_rect;
73
+ VALUE rb_logical_rect;
74
+ VALUE rb_data;
75
+ PangoRectangle *ink_rect;
76
+ PangoRectangle *logical_rect;
77
+
78
+ rb_scan_args(argc, argv, "21", &rb_ink_rect, &rb_logical_rect, &rb_data);
79
+
80
+ ink_rect = RVAL2PANGORECTANGLE(rb_ink_rect);
81
+ logical_rect = RVAL2PANGORECTANGLE(rb_logical_rect);
82
+
83
+ if (NIL_P(rb_data)) {
84
+ DATA_PTR(self) = pango_attr_shape_new(ink_rect, logical_rect);
85
+ } else {
86
+ G_RELATIVE(self, rb_data);
87
+ DATA_PTR(self) = pango_attr_shape_new_with_data(ink_rect,
88
+ logical_rect,
89
+ (gpointer)rb_data,
90
+ NULL,
91
+ NULL);
92
+ }
93
+
94
+ return Qnil;
95
+ }
96
+
97
+ static VALUE
98
+ rbpango_attr_size_initialize(VALUE self, VALUE rb_size)
99
+ {
100
+ gint size;
101
+
102
+ size = NUM2INT(rb_size);
103
+ DATA_PTR(self) = pango_attr_size_new(size);
104
+
105
+ return Qnil;
106
+ }
107
+
108
+ void
109
+ rbpango_attribute_init(VALUE mPango)
110
+ {
111
+ VALUE cAttribute;
112
+
113
+ cAttribute = rb_define_class_under(mPango, "Attribute", rb_cData);
114
+ rb_define_alloc_func(cAttribute, rbpango_attribute_allocate);
115
+
116
+ #define DEFINE_ABSTRACT_ATTRIBUTE(ClassName) \
117
+ do { \
118
+ rb_define_class_under(mPango, \
119
+ #ClassName, \
120
+ cAttribute); \
121
+ } while (FALSE)
122
+
123
+ #define DEFINE_ATTRIBUTE(ClassName, method_name, n_initialize_args) \
124
+ do { \
125
+ VALUE c ## ClassName; \
126
+ c ## ClassName = rb_define_class_under(mPango, \
127
+ #ClassName, \
128
+ cAttribute); \
129
+ rb_define_method(c ## ClassName, "initialize", \
130
+ rbpango_ ## method_name ## _initialize, \
131
+ n_initialize_args); \
132
+ } while (FALSE)
133
+
134
+ DEFINE_ABSTRACT_ATTRIBUTE(AttrBool);
135
+ DEFINE_ABSTRACT_ATTRIBUTE(AttrColor);
136
+ DEFINE_ABSTRACT_ATTRIBUTE(AttrFloat);
137
+ DEFINE_ATTRIBUTE(AttrFontDesc, attr_font_desc, 1);
138
+ DEFINE_ATTRIBUTE(AttrFontFeatures, attr_font_features, 1);
139
+ DEFINE_ABSTRACT_ATTRIBUTE(AttrInt);
140
+ DEFINE_ATTRIBUTE(AttrLanguage, attr_language, 1);
141
+ DEFINE_ATTRIBUTE(AttrShape, attr_shape, -1);
142
+ DEFINE_ATTRIBUTE(AttrSize, attr_size, 1);
143
+ DEFINE_ABSTRACT_ATTRIBUTE(AttrString);
144
+
145
+ #undef DEFINE_ABSTRACT_ATTRIBUTE
146
+ #undef DEFINE_ATTRIBUTE
147
+ }
@@ -0,0 +1,79 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright (C) 2017 Ruby-GNOME2 Project Team
4
+ *
5
+ * This library is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU Lesser General Public
7
+ * License as published by the Free Software Foundation; either
8
+ * version 2.1 of the License, or (at your option) any later version.
9
+ *
10
+ * This library is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ * Lesser General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Lesser General Public
16
+ * License along with this library; if not, write to the Free Software
17
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
+ * MA 02110-1301 USA
19
+ */
20
+
21
+ #include "rb-pango-private.h"
22
+
23
+ #if PANGO_VERSION_CHECK(1, 18, 0)
24
+ # include <pango/pangocairo.h>
25
+ # include <rb_cairo.h>
26
+ #endif
27
+
28
+ #define RG_TARGET_NAMESPACE cContext
29
+
30
+ #if PANGO_VERSION_CHECK(1, 18, 0)
31
+ static void
32
+ shape_renderer_callback(cairo_t *cr,
33
+ PangoAttrShape *attr,
34
+ gboolean do_path,
35
+ gpointer data)
36
+ {
37
+ VALUE rb_cr;
38
+ VALUE rb_mPango;
39
+ VALUE rb_cPangoAttrShape;
40
+ VALUE rb_attr;
41
+ VALUE rb_do_path;
42
+ VALUE rb_callback;
43
+ ID id_call;
44
+
45
+ rb_cr = CRCONTEXT2RVAL(cr);
46
+ rb_mPango = rb_const_get(rb_cObject, rb_intern("Pango"));
47
+ rb_cPangoAttrShape = rb_const_get(rb_mPango, rb_intern("AttrShape"));
48
+ rb_attr = Data_Wrap_Struct(rb_cPangoAttrShape,
49
+ NULL,
50
+ pango_attribute_destroy,
51
+ pango_attribute_copy((PangoAttribute *)attr));
52
+ rb_do_path = CBOOL2RVAL(do_path);
53
+ rb_callback = (VALUE)data;
54
+ CONST_ID(id_call, "call");
55
+ rb_funcall(rb_callback, id_call, 3, rb_cr, rb_attr, rb_do_path);
56
+ }
57
+
58
+ static VALUE
59
+ rg_set_shape_renderer(VALUE self)
60
+ {
61
+ VALUE func = rb_block_proc();
62
+ rb_iv_set(self, "@shape_renderer", func);
63
+ pango_cairo_context_set_shape_renderer(RVAL2PANGOCONTEXT(self),
64
+ shape_renderer_callback,
65
+ (gpointer)func,
66
+ NULL);
67
+ return self;
68
+ }
69
+ #endif
70
+
71
+ void
72
+ rbpango_context_init(VALUE mPango)
73
+ {
74
+ VALUE RG_TARGET_NAMESPACE;
75
+
76
+ RG_TARGET_NAMESPACE = rb_const_get(mPango, rb_intern("Context"));
77
+
78
+ RG_DEF_METHOD(set_shape_renderer, 0);
79
+ }