gd2-ffij 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ *.kpf
2
+ *.komodoproject
3
+ *~
4
+ .DS_Store
5
+ *tmp*
6
+ pkg/
7
+ doc/
8
+ *.orig
9
+ *.patch
10
+ *.gem
11
+ *.rbc
12
+ .bundle
13
+ .config
14
+ .yardoc
15
+ Gemfile.lock
data/COPYRIGHT CHANGED
@@ -1,6 +1,7 @@
1
1
 
2
2
  Ruby/GD2 - Ruby binding for gd 2.x graphics library
3
- Copyright (C) 2005-2006 Robert Leslie, 2010 J Smith <dark.panda@gmail.com>
3
+ Copyright (C) 2005-2006 Robert Leslie
4
+ Copyright (C) 2010-2012 J Smith <dark.panda@gmail.com>
4
5
 
5
6
  This program is free software; you can redistribute it and/or modify
6
7
  it under the terms of the GNU General Public License as published by
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -1,22 +1,14 @@
1
1
 
2
- Ruby/GD2 - Ruby binding for Thomas Boutell's gd 2.x graphics library
3
- Copyright (C) 2005-2006 Robert Leslie <rob@mars.org>
2
+ = gd2-ffij - Ruby FFI Bindings for Thomas Boutell's gd 2.x Graphics Library
4
3
 
5
- FFI modifications copyright (C) 2010-2012 J Smith <dark.panda@gmail.com>
6
-
7
- Robert's Notes:
8
-
9
- I wrote this Ruby library because I wasn't satisfied with the existing
10
- Ruby/GD extension library. Among other things, it had no support for
11
- creating images from PNG or JPEG data already in memory.
4
+ Original dl-based code copyright (C) 2005-2006 Robert Leslie <rob@mars.org>
12
5
 
13
- Ruby/GD2 is 100% Ruby and uses dl to link with the gd shared library. Most
14
- of the gd API is supported in some way, however the interface is quite
15
- different so that we can do things The Ruby Way as much as possible.
6
+ FFI modifications copyright (C) 2010-2012 J Smith <dark.panda@gmail.com>
16
7
 
17
- Most of the documentation for this library is now in RDoc form.
8
+ The gd2-ffij project page can be found at
9
+ http://github.com/dark-panda/gd2-ffij .
18
10
 
19
- J's Notes:
11
+ == Why FFI
20
12
 
21
13
  DL just doesn't want to work correctly on my x86_64 linux boxes and on
22
14
  OSX, so here's a refactoring using FFI.
@@ -25,10 +17,31 @@ These modifications were partly inspired by Patrick Stenmark's
25
17
  work, which can be found at http://github.com/spatrik/gd2-ffi/,
26
18
  although the goal of these modifications are a complete GD2 Ruby
27
19
  library using FFI. I've also included the beginning of a test suite,
28
- although coverage isn't quite complete yet..
20
+ although coverage isn't quite complete yet.
29
21
 
30
22
  This GD2 library should "just work" as a replacement for Robert's
31
23
  original GD2 library, although without a complete test suite and
32
24
  the time and resources to do complete testing, it is difficult to
33
25
  know for sure. Reports on successful test runs are welcomed.
34
26
 
27
+ == Robert's Original Notes
28
+
29
+ "I wrote this Ruby library because I wasn't satisfied with the existing
30
+ Ruby/GD extension library. Among other things, it had no support for
31
+ creating images from PNG or JPEG data already in memory.
32
+
33
+ Ruby/GD2 is 100% Ruby and uses dl to link with the gd shared library. Most
34
+ of the gd API is supported in some way, however the interface is quite
35
+ different so that we can do things The Ruby Way as much as possible.
36
+
37
+ Most of the documentation for this library is now in RDoc form."
38
+
39
+ == Contributing
40
+
41
+ Patches, bug reports, pull requests, and all other good stuff can be performed
42
+ via the project GitHub page at http://github.com/dark-panda/gd2-ffij .
43
+
44
+ == License
45
+
46
+ See the COPYRIGHT file for details, but the gist of it is that this gem is
47
+ covered under the terms of the GPL version 2 or above.
data/Rakefile CHANGED
@@ -1,9 +1,13 @@
1
1
  # -*- ruby -*-
2
2
 
3
3
  require 'rubygems'
4
+
5
+ gem 'rdoc', '~> 3.12'
6
+
4
7
  require 'rubygems/package_task'
5
8
  require 'rake/testtask'
6
9
  require 'rdoc/task'
10
+ require 'bundler/gem_tasks'
7
11
 
8
12
  if RUBY_VERSION >= '1.9'
9
13
  begin
@@ -15,35 +19,19 @@ end
15
19
 
16
20
  $:.push 'lib'
17
21
 
18
- version = File.read('VERSION') rescue ''
19
-
20
- begin
21
- require 'jeweler'
22
- Jeweler::Tasks.new do |gem|
23
- gem.name = "gd2-ffij"
24
- gem.summary = "gd2-ffij is a refactoring of the Ruby/GD2 library implemented with FFI"
25
- gem.description = gem.summary
26
- gem.email = "dark.panda@gmail.com"
27
- gem.homepage = "http://github.com/dark-panda/gd2-ffij"
28
- gem.authors = [ "J Smith" ]
29
- gem.add_dependency "ffi", "~> 1.0.0"
30
- end
31
- Jeweler::GemcutterTasks.new
32
- rescue LoadError
33
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
34
- end
22
+ version = GD2::VERSION
35
23
 
36
24
  desc 'Test GD2 interface'
37
25
  Rake::TestTask.new(:test) do |t|
38
26
  t.test_files = FileList['test/**/*_tests.rb']
39
27
  t.verbose = !!ENV['VERBOSE_TESTS']
28
+ t.warning = !!ENV['WARNINGS']
40
29
  end
41
30
 
42
31
  desc 'Build docs'
43
32
  Rake::RDocTask.new do |t|
44
- require 'rdoc'
45
33
  t.title = "gd2-ffij #{version}"
46
- t.main = 'README'
34
+ t.main = 'README.rdoc'
47
35
  t.rdoc_dir = 'doc'
48
- t.rdoc_files.include('README', 'COPYING', 'COPYRIGHT', 'lib/**/*.rb')
36
+ t.rdoc_files.include('README.rdoc', 'COPYING', 'COPYRIGHT', 'lib/**/*.rb')
49
37
  end
data/gd2-ffij.gemspec CHANGED
@@ -1,92 +1,27 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
1
  # -*- encoding: utf-8 -*-
5
2
 
3
+ require File.expand_path('../lib/gd2/version', __FILE__)
4
+
6
5
  Gem::Specification.new do |s|
7
6
  s.name = "gd2-ffij"
8
- s.version = "0.0.4"
7
+ s.version = GD2::VERSION
9
8
 
10
9
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
10
  s.authors = ["J Smith"]
12
- s.date = "2012-01-03"
13
11
  s.description = "gd2-ffij is a refactoring of the Ruby/GD2 library implemented with FFI"
12
+ s.summary = s.description
14
13
  s.email = "dark.panda@gmail.com"
15
14
  s.extra_rdoc_files = [
16
- "README"
17
- ]
18
- s.files = [
19
- "COPYING",
20
- "COPYRIGHT",
21
- "README",
22
- "Rakefile",
23
- "VERSION",
24
- "gd2-ffij.gemspec",
25
- "lib/gd2-ffij.rb",
26
- "lib/gd2/canvas.rb",
27
- "lib/gd2/color.rb",
28
- "lib/gd2/ffi_struct.rb",
29
- "lib/gd2/font.rb",
30
- "lib/gd2/image.rb",
31
- "lib/gd2/palette.rb",
32
- "test/canvas_tests.rb",
33
- "test/image_tests.rb",
34
- "test/images/test.bmp",
35
- "test/images/test.gd",
36
- "test/images/test.gd2",
37
- "test/images/test.gif",
38
- "test/images/test.jpg",
39
- "test/images/test.png",
40
- "test/images/test.wbmp",
41
- "test/images/test.xbm",
42
- "test/images/test.xcf",
43
- "test/images/test.xpm",
44
- "test/images/test_arc.gd2",
45
- "test/images/test_canvas_filled_polygon.gd2",
46
- "test/images/test_canvas_filled_rectangle.gd2",
47
- "test/images/test_canvas_line.gd2",
48
- "test/images/test_canvas_move_to_and_line_to.gd2",
49
- "test/images/test_canvas_polygon.gd2",
50
- "test/images/test_canvas_rectangle.gd2",
51
- "test/images/test_circle.gd2",
52
- "test/images/test_color.gd2",
53
- "test/images/test_color.png",
54
- "test/images/test_color.xcf",
55
- "test/images/test_color_indexed.gd2",
56
- "test/images/test_color_sharpened.gd2",
57
- "test/images/test_cropped.gd2",
58
- "test/images/test_ellipse.gd2",
59
- "test/images/test_fill.gd2",
60
- "test/images/test_fill_to.gd2",
61
- "test/images/test_filled_circle.gd2",
62
- "test/images/test_filled_ellipse.gd2",
63
- "test/images/test_filled_wedge.gd2",
64
- "test/images/test_polar_transform.gd2",
65
- "test/images/test_resampled.gd2",
66
- "test/images/test_resized.gd2",
67
- "test/images/test_rotated_180.gd2",
68
- "test/images/test_text.gd2",
69
- "test/images/test_text_circle.gd2",
70
- "test/images/test_wedge.gd2",
71
- "test/test_helper.rb",
72
- "vendor/fonts/ttf/DejaVuSans.ttf",
73
- "vendor/fonts/ttf/LICENSE"
15
+ "README.rdoc"
74
16
  ]
17
+ s.files = `git ls-files`.split($\)
18
+ s.executables = s.files.grep(%r{^bin/}).map { |f| File.basename(f) }
19
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
75
20
  s.homepage = "http://github.com/dark-panda/gd2-ffij"
76
21
  s.require_paths = ["lib"]
77
- s.rubygems_version = "1.8.10"
78
- s.summary = "gd2-ffij is a refactoring of the Ruby/GD2 library implemented with FFI"
79
-
80
- if s.respond_to? :specification_version then
81
- s.specification_version = 3
82
22
 
83
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
84
- s.add_runtime_dependency(%q<ffi>, ["~> 1.0.0"])
85
- else
86
- s.add_dependency(%q<ffi>, ["~> 1.0.0"])
87
- end
88
- else
89
- s.add_dependency(%q<ffi>, ["~> 1.0.0"])
90
- end
23
+ s.add_dependency("ffi", ["~> 1.0.0"])
24
+ s.add_dependency("rdoc")
25
+ s.add_dependency("rake", ["~> 0.9"])
91
26
  end
92
27
 
data/lib/gd2-ffij.rb CHANGED
@@ -22,21 +22,20 @@
22
22
 
23
23
  require 'ffi'
24
24
  require 'rbconfig'
25
+ require 'gd2/version'
25
26
 
26
27
  module GD2
27
- VERSION = File.read(File.join(File.dirname(__FILE__), %w{ .. VERSION })).strip
28
-
29
28
  module GD2FFI
30
29
  def self.gd_library_name
31
- return @gd_library_name if @gd_library_name
30
+ return @gd_library_name if defined?(@gd_library_name)
32
31
 
33
32
  @gd_library_name = if RbConfig::CONFIG['host_os'] == 'cygwin'
34
33
  'cyggd-2.dll'
35
34
  else
36
35
  paths = if ENV['GD2_LIBRARY_PATH']
37
- ENV['GD2_LIBRARY_PATH']
36
+ [ ENV['GD2_LIBRARY_PATH'] ]
38
37
  else
39
- [ '/usr/local/{lib64,lib}', '/opt/local/{lib64,lib}', '/usr/{lib64,lib}' ]
38
+ [ '/usr/local/{lib64,lib}', '/opt/local/{lib64,lib}', '/usr/{lib64,lib}', '/usr/lib/x86_64-linux-gnu' ]
40
39
  end
41
40
 
42
41
  lib = if [
data/lib/gd2/canvas.rb CHANGED
@@ -58,7 +58,7 @@ module GD2
58
58
  end
59
59
 
60
60
  def draw(image, mode)
61
- GD2FFI.send(:gdImageLine, image.image_ptr,
61
+ ::GD2::GD2FFI.send(:gdImageLine, image.image_ptr,
62
62
  @p1.x.to_i, @p1.y.to_i, @p2.x.to_i, @p2.y.to_i, mode.to_i)
63
63
  nil
64
64
  end
@@ -70,7 +70,7 @@ module GD2
70
70
  end
71
71
 
72
72
  def draw(image, mode)
73
- GD2FFI.send(draw_sym, image.image_ptr, @p1.x.to_i, @p1.y.to_i, @p2.x.to_i, @p2.y.to_i, mode.to_i)
73
+ ::GD2::GD2FFI.send(draw_sym, image.image_ptr, @p1.x.to_i, @p1.y.to_i, @p2.x.to_i, @p2.y.to_i, mode.to_i)
74
74
  nil
75
75
  end
76
76
 
@@ -91,7 +91,7 @@ module GD2
91
91
  end
92
92
 
93
93
  def draw(image, mode)
94
- GD2FFI.send(draw_sym, image.image_ptr, @points.map { |point|
94
+ ::GD2::GD2FFI.send(draw_sym, image.image_ptr, @points.map { |point|
95
95
  point.coordinates.pack('i_i_')
96
96
  }.join(''), @points.length, mode.to_i)
97
97
  nil
@@ -122,7 +122,7 @@ module GD2
122
122
  end
123
123
 
124
124
  def draw(image, mode)
125
- GD2FFI.send(:gdImageArc, image.image_ptr, @center.x.to_i, @center.y.to_i,
125
+ ::GD2::GD2FFI.send(:gdImageArc, image.image_ptr, @center.x.to_i, @center.y.to_i,
126
126
  @width.to_i, @height.to_i,
127
127
  @range.begin.to_degrees.round.to_i, @range.end.to_degrees.round.to_i, mode.to_i)
128
128
  nil
@@ -144,7 +144,7 @@ module GD2
144
144
  end
145
145
 
146
146
  def draw(image, mode)
147
- GD2FFI.send(:gdImageFilledArc, image.image_ptr, @center.x.to_i, @center.y.to_i,
147
+ ::GD2::GD2FFI.send(:gdImageFilledArc, image.image_ptr, @center.x.to_i, @center.y.to_i,
148
148
  @width.to_i, @height.to_i,
149
149
  @range.begin.to_degrees.round.to_i, @range.end.to_degrees.round.to_i,
150
150
  mode.to_i, style.to_i)
@@ -168,7 +168,7 @@ module GD2
168
168
  end
169
169
 
170
170
  def draw(image, mode)
171
- GD2FFI.send(:gdImageArc, image.image_ptr, @center.x.to_i, @center.y.to_i,
171
+ ::GD2::GD2FFI.send(:gdImageArc, image.image_ptr, @center.x.to_i, @center.y.to_i,
172
172
  @width.to_i, @height.to_i, 0, 360, mode.to_i)
173
173
  nil
174
174
  end
@@ -176,7 +176,7 @@ module GD2
176
176
 
177
177
  class FilledEllipse < Ellipse
178
178
  def draw(image, mode)
179
- GD2FFI.send(:gdImageFilledEllipse, image.image_ptr, @center.x.to_i, @center.y.to_i,
179
+ ::GD2::GD2FFI.send(:gdImageFilledEllipse, image.image_ptr, @center.x.to_i, @center.y.to_i,
180
180
  @width.to_i, @height.to_i, mode.to_i)
181
181
  end
182
182
  end
@@ -240,12 +240,12 @@ module GD2
240
240
  end
241
241
 
242
242
  def thickness=(thickness)
243
- GD2FFI.send(:gdImageSetThickness, @image.image_ptr, @thickness = thickness.to_i)
243
+ ::GD2::GD2FFI.send(:gdImageSetThickness, @image.image_ptr, @thickness = thickness.to_i)
244
244
  end
245
245
 
246
246
  def style=(ary)
247
247
  if @style = ary
248
- GD2FFI.send(:gdImageSetStyle, @image.image_ptr,
248
+ ::GD2::GD2FFI.send(:gdImageSetStyle, @image.image_ptr,
249
249
  ary.map { |c|
250
250
  !c ? TRANSPARENT : true == c ? -1 : @image.color2pixel(c)
251
251
  }, ary.length)
@@ -254,13 +254,13 @@ module GD2
254
254
 
255
255
  def brush=(image)
256
256
  if @brush = image
257
- GD2FFI.send(:gdImageSetBrush, @image.image_ptr, image.image_ptr)
257
+ ::GD2::GD2FFI.send(:gdImageSetBrush, @image.image_ptr, image.image_ptr)
258
258
  end
259
259
  end
260
260
 
261
261
  def tile=(image)
262
262
  if @tile = image
263
- GD2FFI.send(:gdImageSetTile, @image.image_ptr, image.image_ptr)
263
+ ::GD2::GD2FFI.send(:gdImageSetTile, @image.image_ptr, image.image_ptr)
264
264
  end
265
265
  end
266
266
 
@@ -339,13 +339,13 @@ module GD2
339
339
  end
340
340
 
341
341
  def fill
342
- GD2FFI.send(:gdImageFill, @image.image_ptr, @point.x.to_i, @point.y.to_i, fill_pixel.to_i)
342
+ ::GD2::GD2FFI.send(:gdImageFill, @image.image_ptr, @point.x.to_i, @point.y.to_i, fill_pixel.to_i)
343
343
  self
344
344
  end
345
345
 
346
346
  def fill_to(border)
347
347
  # An apparent bug in gd prevents us from using fill_pixel
348
- GD2FFI.send(:gdImageFillToBorder, @image.image_ptr, @point.x.to_i, @point.y.to_i,
348
+ ::GD2::GD2FFI.send(:gdImageFillToBorder, @image.image_ptr, @point.x.to_i, @point.y.to_i,
349
349
  @image.color2pixel(border), pixel.to_i)
350
350
  self
351
351
  end
@@ -412,10 +412,10 @@ module GD2
412
412
  BRUSHED
413
413
  elsif anti_aliasing?
414
414
  if @dont_blend
415
- GD2FFI.send(:gdImageSetAntiAliasedDontBlend, @image.image_ptr,
415
+ ::GD2::GD2FFI.send(:gdImageSetAntiAliasedDontBlend, @image.image_ptr,
416
416
  pixel.to_i, @dont_blend.to_i)
417
417
  else
418
- GD2FFI.send(:gdImageSetAntiAliased, @image.image_ptr, pixel.to_i)
418
+ ::GD2::GD2FFI.send(:gdImageSetAntiAliased, @image.image_ptr, pixel.to_i)
419
419
  end
420
420
  ANTI_ALIASED
421
421
  else
@@ -424,7 +424,7 @@ module GD2
424
424
  end
425
425
 
426
426
  def fill_pixel
427
- @tile ? TILED : pixel
427
+ defined?(@tile) ? TILED : pixel
428
428
  end
429
429
  end
430
430
  end
data/lib/gd2/color.rb CHANGED
@@ -215,7 +215,7 @@ module GD2
215
215
  # Alpha blend this color with the given color. If this color is associated
216
216
  # with a palette entry, this also modifies the palette.
217
217
  def alpha_blend!(other)
218
- self.rgba = GD2FFI.send(:gdAlphaBlend, rgba.to_i, other.rgba.to_i)
218
+ self.rgba = ::GD2::GD2FFI.send(:gdAlphaBlend, rgba.to_i, other.rgba.to_i)
219
219
  self
220
220
  end
221
221
  alias << alpha_blend!
@@ -70,7 +70,7 @@ module GD2::FFIStruct
70
70
  )
71
71
 
72
72
  def self.release(ptr)
73
- GD2FFI.gdImageDestroy(ptr)
73
+ ::GD2::GD2FFI.gdImageDestroy(ptr)
74
74
  end
75
75
  end
76
76
  end
data/lib/gd2/font.rb CHANGED
@@ -50,14 +50,14 @@ module GD2
50
50
  private_class_method :new
51
51
 
52
52
  def self.font_ptr #:nodoc:
53
- GD2FFI.send(font_sym)
53
+ ::GD2::GD2FFI.send(font_sym)
54
54
  end
55
55
 
56
56
  def self.draw(image_ptr, x, y, angle, string, fg) #:nodoc:
57
57
  raise ArgumentError, "Angle #{angle} not supported for #{self}" unless
58
58
  angle == 0.degrees || angle == 90.degrees
59
59
 
60
- GD2FFI.send(angle > 0 ? :gdImageStringUp : :gdImageString, image_ptr,
60
+ ::GD2::GD2FFI.send(angle > 0 ? :gdImageStringUp : :gdImageString, image_ptr,
61
61
  font_ptr, x.to_i, y.to_i, string, fg.to_i)
62
62
  nil
63
63
  end
@@ -110,21 +110,16 @@ module GD2
110
110
  FTEX_FONTCONFIG = 64
111
111
  FTEX_RETURNFONTPATHNAME = 128
112
112
 
113
- @@fontcount = 0
114
- @@fontconfig = false
113
+ def self.register(font) #:nodoc:
114
+ Thread.current[:fontcount] ||= 0
115
+ Thread.current[:fontcount] += 1
115
116
 
116
- def self.register(font) #:nodoc:
117
- Thread.exclusive do
118
- count = @@fontcount
119
- @@fontcount += 1
120
-
121
- if count.zero?
122
- raise FreeTypeError, 'FreeType library failed to initialize' unless
123
- GD2FFI.send(:gdFontCacheSetup).zero?
124
- end
125
-
126
- ObjectSpace.define_finalizer(font, font_finalizer)
117
+ if Thread.current[:fontcount].zero?
118
+ raise FreeTypeError, 'FreeType library failed to initialize' unless
119
+ ::GD2::GD2FFI.send(:gdFontCacheSetup).zero?
127
120
  end
121
+
122
+ ObjectSpace.define_finalizer(font, font_finalizer)
128
123
  end
129
124
 
130
125
  def self.font_finalizer
@@ -132,16 +127,23 @@ module GD2
132
127
  end
133
128
 
134
129
  def self.unregister
135
- Thread.exclusive do
136
- @@fontcount -= 1
137
- GD2FFI.send(:gdFontCacheShutdown) if @@fontcount.zero?
130
+ if Thread.current[:fontcount]
131
+ Thread.current[:fontcount] -= 1
132
+ else
133
+ Thread.current[:fontcount] = 0
138
134
  end
135
+
136
+ ::GD2::GD2FFI.send(:gdFontCacheShutdown) if Thread.current[:fontcount].zero?
139
137
  end
140
138
 
141
139
  private_class_method :font_finalizer, :unregister
142
140
 
143
- def self.fontconfig #:nodoc:
144
- @@fontconfig
141
+ def self.fontconfig #:nodoc:
142
+ if Thread.current[:fontconfig].nil?
143
+ Thread.current[:fontconfig] = false
144
+ end
145
+
146
+ Thread.current[:fontconfig]
145
147
  end
146
148
 
147
149
  # Return a boolean indicating whether fontconfig support has been enabled.
@@ -154,9 +156,9 @@ module GD2
154
156
  # library must have been built with fontconfig support. Raises an error if
155
157
  # fontconfig support is unavailable.
156
158
  def self.fontconfig=(want)
157
- avail = !GD2FFI.send(:gdFTUseFontConfig, want ? 1 : 0).zero?
159
+ avail = !::GD2::GD2FFI.send(:gdFTUseFontConfig, want ? 1 : 0).zero?
158
160
  raise FontconfigError, 'Fontconfig not available' if want && !avail
159
- @@fontconfig = want
161
+ Thread.current[:fontconfig] = !!want
160
162
  end
161
163
 
162
164
  class << self
@@ -228,12 +230,12 @@ module GD2
228
230
 
229
231
  strex = strex(false, true)
230
232
  args = [ nil, nil, 0, @fontname, @ptsize, 0.0, 0, 0, '', strex ]
231
- r = GD2FFI.send(:gdImageStringFTEx, *args)
233
+ r = ::GD2::GD2FFI.send(:gdImageStringFTEx, *args)
232
234
 
233
235
  raise FreeTypeError.new(r.read_string) unless r.null?
234
236
  @fontpath = strex[:fontpath].read_string
235
237
  ensure
236
- GD2FFI.send(:gdFree, strex[:fontpath])
238
+ ::GD2::GD2FFI.send(:gdFree, strex[:fontpath])
237
239
  end
238
240
 
239
241
  def inspect #:nodoc:
@@ -251,7 +253,7 @@ module GD2
251
253
  strex = strex(true)
252
254
  args = [ image_ptr, brect, fg, @fontname, @ptsize, angle.to_f, x.to_i, y.to_i, string.gsub('&', '&amp;'), strex ]
253
255
 
254
- r = GD2FFI.send(:gdImageStringFTEx, *args)
256
+ r = ::GD2::GD2FFI.send(:gdImageStringFTEx, *args)
255
257
  raise FreeTypeError.new(r.read_string) unless r.null?
256
258
  brect = brect.read_array_of_int(8)
257
259
 
@@ -259,7 +261,7 @@ module GD2
259
261
  begin
260
262
  xshow = xshow.read_string.split(' ').map { |e| e.to_f }
261
263
  ensure
262
- GD2FFI.send(:gdFree, strex[:xshow])
264
+ ::GD2::GD2FFI.send(:gdFree, strex[:xshow])
263
265
  end
264
266
  else
265
267
  xshow = []
@@ -285,7 +287,7 @@ module GD2
285
287
  image_ptr, cx, cy, radius, text_radius, fill_portion,
286
288
  top, bottom, fgcolor
287
289
  ) #:nodoc:
288
- r = GD2FFI.send(
290
+ r = ::GD2::GD2FFI.send(
289
291
  :gdImageStringFTCircle, image_ptr, cx.to_i, cy.to_i,
290
292
  radius.to_f, text_radius.to_f, fill_portion.to_f, @fontname, @ptsize,
291
293
  top || '', bottom || '', fgcolor.to_i