rsvg2 0.90.2

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.
@@ -0,0 +1,2 @@
1
+ EXPORTS
2
+ Init_rsvg2
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'pathname'
4
+ require 'mkmf'
5
+ require 'rbconfig'
6
+ require 'fileutils'
7
+
8
+ package = "rsvg2"
9
+
10
+ base_dir = Pathname(__FILE__).dirname.expand_path
11
+ ext_dir = base_dir + "ext" + package
12
+ mkmf_gnome2_dir = base_dir + 'lib'
13
+
14
+ ruby = File.join(RbConfig::CONFIG['bindir'],
15
+ RbConfig::CONFIG['ruby_install_name'] +
16
+ RbConfig::CONFIG["EXEEXT"])
17
+
18
+ build_dir = Pathname("ext") + package
19
+ FileUtils.mkdir_p(build_dir.to_s) unless build_dir.exist?
20
+ extconf_rb_path = ext_dir + "extconf.rb"
21
+ system(ruby, "-C", build_dir.to_s, extconf_rb_path.to_s, *ARGV) || exit(false)
22
+
23
+ create_makefile(package)
24
+ FileUtils.mv("Makefile", "Makefile.lib")
25
+
26
+ File.open("Makefile", "w") do |makefile|
27
+ makefile.puts(<<-EOM)
28
+ all:
29
+ (cd ext/#{package} && $(MAKE))
30
+ $(MAKE) -f Makefile.lib
31
+
32
+ install:
33
+ (cd ext/#{package} && $(MAKE) install)
34
+ $(MAKE) -f Makefile.lib install
35
+
36
+ site-install:
37
+ (cd ext/#{package} && $(MAKE) site-install)
38
+ $(MAKE) -f Makefile.lib site-install
39
+
40
+ clean:
41
+ (cd ext/#{package} && $(MAKE) clean)
42
+ $(MAKE) -f Makefile.lib clean
43
+
44
+ distclean:
45
+ (cd ext/#{package} && $(MAKE) distclean)
46
+ $(MAKE) -f Makefile.lib distclean
47
+ @rm -f Makefile.lib
48
+ EOM
49
+ end
@@ -0,0 +1,33 @@
1
+ require "glib2"
2
+ require "gdk_pixbuf2"
3
+ begin
4
+ require "cairo"
5
+ rescue LoadError
6
+ end
7
+
8
+ base_dir = Pathname.new(__FILE__).dirname.dirname.expand_path
9
+ vendor_dir = base_dir + "vendor" + "local"
10
+ vendor_bin_dir = vendor_dir + "bin"
11
+ GLib.prepend_environment_path(vendor_bin_dir)
12
+ begin
13
+ major, minor, micro, = RUBY_VERSION.split(/\./)
14
+ require "#{major}.#{minor}/rsvg2.so"
15
+ rescue LoadError
16
+ require "rsvg2.so"
17
+ end
18
+
19
+ module RSVG
20
+ LOG_DOMAIN = "librsvg"
21
+ end
22
+
23
+ if RSVG.cairo_available?
24
+ module Cairo
25
+ class Context
26
+ def render_rsvg_handle(handle, *args, &block)
27
+ handle.render_cairo(self, *args, &block)
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ GLib::Log.set_log_domain(RSVG::LOG_DOMAIN)
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'gtk2'
4
+ require 'rsvg2'
5
+
6
+ unless RSVG.cairo_available?
7
+ puts "this sample needs RSVG with cairo support"
8
+ exit(-1)
9
+ end
10
+
11
+ unless Gdk.cairo_available?
12
+ puts "this sample needs GDK with cairo support"
13
+ exit(-1)
14
+ end
15
+
16
+ if ARGV.size != 1
17
+ puts "usage: #{$0} input.svg"
18
+ exit(-1)
19
+ end
20
+
21
+ input = ARGV.shift
22
+
23
+ handle = RSVG::Handle.new_from_file(input)
24
+ width, height = handle.dimensions.to_a
25
+
26
+ window = Gtk::Window.new
27
+ window.set_default_size(width, height)
28
+ area = Gtk::DrawingArea.new
29
+
30
+ window.signal_connect("destroy") do
31
+ Gtk.main_quit
32
+ end
33
+
34
+ area.signal_connect("expose_event") do |widget, event|
35
+ context = widget.window.create_cairo_context
36
+ window_width, window_height = widget.window.size
37
+ context.scale(window_width.to_f / width, window_height.to_f / height)
38
+ context.render_rsvg_handle(handle)
39
+ end
40
+
41
+ window.add(area)
42
+ window.show_all
43
+
44
+ Gtk.main
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env ruby
2
+ =begin
3
+ svg2.rb - Ruby/RSVG sample script.
4
+
5
+ Copyright (c) 2006 Ruby-GNOME2 Project Team
6
+ This program is licenced under the same licence as Ruby-GNOME2.
7
+
8
+ $Id: svg2.rb,v 1.5 2006/06/17 13:30:25 mutoh Exp $
9
+ =end
10
+
11
+ require 'tempfile'
12
+ require "rsvg2"
13
+
14
+ if ARGV.size < 2
15
+ puts "usage: #{$0} input.svg output [scale_ratio]"
16
+ exit(-1)
17
+ end
18
+
19
+ input, output, ratio = ARGV
20
+ ratio ||= 1.0
21
+ ratio = ratio.to_f
22
+
23
+ output_type = File.extname(output)[1..-1].downcase
24
+ output_type = "jpeg" if /jpg/ =~ output_type
25
+
26
+ def to_pixbuf_with_cairo(input, ratio)
27
+ handle = nil
28
+ Dir.chdir(File.dirname(File.expand_path(input))) do
29
+ handle = RSVG::Handle.new_from_file(input)
30
+ end
31
+ dim = handle.dimensions
32
+ width = dim.width * ratio
33
+ height = dim.height * ratio
34
+ surface = Cairo::ImageSurface.new(Cairo::FORMAT_ARGB32, width, height)
35
+ cr = Cairo::Context.new(surface)
36
+ cr.scale(ratio, ratio)
37
+ cr.render_rsvg_handle(handle)
38
+ temp = Tempfile.new("svg2")
39
+ cr.target.write_to_png(temp.path)
40
+ cr.target.finish
41
+ Gdk::Pixbuf.new(temp.path)
42
+ end
43
+
44
+ def to_pixbuf(input, ratio)
45
+ RSVG.pixbuf_from_file_at_zoom(input, ratio, ratio)
46
+ end
47
+
48
+ if RSVG.cairo_available?
49
+ puts "using cairo..."
50
+ pixbuf = to_pixbuf_with_cairo(input, ratio)
51
+ else
52
+ pixbuf = to_pixbuf(input, ratio)
53
+ end
54
+
55
+ if pixbuf.nil?
56
+ puts "Is it a SVG file?: #{input}"
57
+ exit(-1)
58
+ end
59
+ puts "saving to #{output}(#{pixbuf.width}x#{pixbuf.height})..."
60
+ pixbuf.save(output, output_type)
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rsvg2
3
+ version: !ruby/object:Gem::Version
4
+ hash: 371
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 90
9
+ - 2
10
+ version: 0.90.2
11
+ platform: ruby
12
+ authors:
13
+ - The Ruby-GNOME2 Proejct Team
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-09-26 00:00:00 +09:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: cairo
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 63
30
+ segments:
31
+ - 1
32
+ - 10
33
+ - 0
34
+ version: 1.10.0
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: glib2
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - "="
44
+ - !ruby/object:Gem::Version
45
+ hash: 371
46
+ segments:
47
+ - 0
48
+ - 90
49
+ - 2
50
+ version: 0.90.2
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ description: Ruby/RSVG is a Ruby binding of librsvg-2.x.
54
+ email: ruby-gnome2-devel-en@lists.sourceforge.net
55
+ executables: []
56
+
57
+ extensions:
58
+ - ext/rsvg2/extconf.rb
59
+ extra_rdoc_files: []
60
+
61
+ files:
62
+ - ChangeLog
63
+ - README
64
+ - Rakefile
65
+ - extconf.rb
66
+ - lib/rsvg2.rb
67
+ - ext/rsvg2/Makefile
68
+ - ext/rsvg2/extconf.rb
69
+ - ext/rsvg2/rsvg2.def
70
+ - ext/rsvg2/depend
71
+ - ext/rsvg2/rbrsvg.c
72
+ - sample/svg2.rb
73
+ - sample/svg-viewer.rb
74
+ has_rdoc: true
75
+ homepage: http://ruby-gnome2.sourceforge.jp/
76
+ licenses: []
77
+
78
+ post_install_message:
79
+ rdoc_options: []
80
+
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ hash: 3
89
+ segments:
90
+ - 0
91
+ version: "0"
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ none: false
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ hash: 3
98
+ segments:
99
+ - 0
100
+ version: "0"
101
+ requirements: []
102
+
103
+ rubyforge_project:
104
+ rubygems_version: 1.3.7
105
+ signing_key:
106
+ specification_version: 3
107
+ summary: Ruby/RSVG is a Ruby binding of librsvg-2.x.
108
+ test_files: []
109
+