cairo 1.12.9 → 1.14.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of cairo might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 25726839fd4ba1f1c0a40c58b90d1de641eb863d
4
- data.tar.gz: b6d811ef022e42990edebe58512740a21e9b1c3f
3
+ metadata.gz: 056d2172361d080d8adf08df91c556a493f46d99
4
+ data.tar.gz: af5ca3d7124cea7a8a288af32083247cfd06a188
5
5
  SHA512:
6
- metadata.gz: 62656ab455331c397f0c98ba0fdceaff7729a08c20276a31190ca711fc6647c7e4f5887e6b81aec742f64e325a4909775cee17d978bd02fd8ab843c7494b5abb
7
- data.tar.gz: 1501d2986b228891b410082e6f9c8446552cab09a48970fea6992615109b47da4e269099b877a1ac68e6a58e52a3a74b579e80a3f575ad55a96f3d390d87b147
6
+ metadata.gz: 0f0ceb6cd0bc3d2c7466070049bb7a659746ac3eafa616185e1aa74e2b892ae845465c45d4529604789541fbb49114c9b55a206a2e81c5041c1ff0c9bdf2c64d
7
+ data.tar.gz: db0d7ed817a5e7530130e60bf5b9d94f859ba8f272dbb4448f2a7b3d4197d34715635f90db17a589fe8334a3d8735cf078753d9b7f55f0b0a0cff3bba6ab91d3
data/NEWS CHANGED
@@ -1,3 +1,29 @@
1
+ Release 1.14.0 (2014-11-24) Kouhei Sutou <kou@cozmixng.org>
2
+ ===========================================================
3
+
4
+ Improvements
5
+ ------------
6
+
7
+ * Supported integration with ffi gem.
8
+ [GitHub#20][Patch by Patrick Hanevold]
9
+ * Supported cairo 1.14.0.
10
+ [GitHub#24][GitHub#25][GitHub#28][GitHub#30][Patch by Hiroshi Hatake]
11
+ * Added libstdc++-6.dll into gem for Windows.
12
+
13
+ Fixes
14
+ -----
15
+
16
+ * Fixed an build error on Cygwin.
17
+ [GitHub#19][Reported by Patrick Hanevold][Patch by Masafumi Yokoyama]
18
+ [ruby-gnome2-devel-en][Reported by Detlef Reichl]
19
+
20
+ Thanks
21
+ ------
22
+
23
+ * Patrick Hanevold
24
+ * Masafumi Yokoyama
25
+ * Hiroshi Hatake
26
+
1
27
  Release 1.12.9 (2014-04-05) Kouhei Sutou <kou@cozmixng.org>
2
28
  ===========================================================
3
29
 
@@ -12,7 +12,7 @@ http://cairographics.org/
12
12
 
13
13
  == Dependencies
14
14
 
15
- * ruby >= 1.9.3 (2.0.0 also supported!)
15
+ * ruby >= 1.9.3 (2.2 also supported!)
16
16
  * cairo >= 1.2.0 (1.12.0 also supported!)
17
17
 
18
18
  == Install
@@ -38,11 +38,11 @@ Compiling:
38
38
  % make # to compile
39
39
 
40
40
  # make install # to install the cairo extension.
41
- # The samples in the samples folder should be able
42
- # to run before installation except text-on-path.rb
43
- # and text2.rb. They uses Ruby/Pango with rcairo
44
- # support. So you need to install rcairo and build
45
- # Ruby/Pango with it before you run them.
41
+ # The samples in the samples folder should be able
42
+ # to run before installation except text-on-path.rb
43
+ # and text2.rb. They uses Ruby/Pango with rcairo
44
+ # support. So you need to install rcairo and build
45
+ # Ruby/Pango with it before you run them.
46
46
 
47
47
  Options to extconf.rb:
48
48
 
@@ -67,7 +67,7 @@ cairo-X.Y.Z-x86-mingw32.gem includes cairo related binaries.
67
67
  == Documents
68
68
 
69
69
  * Reference manual:
70
- http://cairo.rubyforge.org/doc/
70
+ http://rcairo.github.io/doc/
71
71
  * Repository of the reference manual:
72
72
  http://github.com/rcairo/doc
73
73
  * An article for rcairo on Rubyst Magazine a.k.a. RubiMa (in Japanese):
data/Rakefile CHANGED
@@ -1,21 +1,21 @@
1
1
  # -*- coding: utf-8; mode: ruby -*-
2
2
 
3
- require 'English'
4
-
5
- require 'find'
6
- require 'fileutils'
7
- require 'open-uri'
8
- require 'rubygems'
9
- require 'rubygems/package_task'
10
- require 'yard'
11
- require 'bundler/gem_helper'
12
- require 'rake/extensiontask'
13
- require 'packnga'
3
+ require "English"
4
+
5
+ require "find"
6
+ require "fileutils"
7
+ require "open-uri"
8
+ require "rubygems"
9
+ require "rubygems/package_task"
10
+ require "yard"
11
+ require "bundler/gem_helper"
12
+ require "rake/extensiontask"
13
+ require "packnga"
14
14
 
15
15
  base_dir = File.join(File.dirname(__FILE__))
16
16
 
17
- cairo_ext_dir = File.join(base_dir, 'ext', 'cairo')
18
- cairo_lib_dir = File.join(base_dir, 'lib')
17
+ cairo_ext_dir = File.join(base_dir, "ext", "cairo")
18
+ cairo_lib_dir = File.join(base_dir, "lib")
19
19
  $LOAD_PATH.unshift(cairo_ext_dir)
20
20
  $LOAD_PATH.unshift(cairo_lib_dir)
21
21
  ENV["RUBYLIB"] = "#{cairo_lib_dir}:#{cairo_ext_dir}:#{ENV['RUBYLIB']}"
@@ -29,6 +29,8 @@ Gem::PackageTask.new(spec) do |pkg|
29
29
  end
30
30
 
31
31
  Packnga::DocumentTask.new(spec) do |task|
32
+ task.original_language = "en"
33
+ task.translate_languages = ["ja"]
32
34
  end
33
35
 
34
36
  Packnga::ReleaseTask.new(spec) do |task|
@@ -198,9 +200,21 @@ class WindowsTask
198
200
  directory binary_path.to_s
199
201
  desc "Bundle GCC related DLLs"
200
202
  task :bundle => binary_path do
201
- dll_names = ["libgcc_s_sjlj-1.dll", "libwinpthread-1.dll"]
203
+ dll_names = [
204
+ "libstdc++-6.dll",
205
+ "libwinpthread-1.dll",
206
+ "libgcc_s_sjlj-1.dll",
207
+ "libgcc_s_seh-1.dll",
208
+ ]
202
209
  dll_names.each do |dll_name|
203
- cp(absolete_gcc_dll_path(dll_name), binary_path)
210
+ destination_path = binary_path + dll_name
211
+ dll_path = absolete_gcc_dll_path(dll_name)
212
+ unless File.exist?(dll_path)
213
+ puts("#{dll_name} doesn't exist.")
214
+ next
215
+ end
216
+ cp(dll_path, destination_path)
217
+ chmod(0755, destination_path)
204
218
  end
205
219
  end
206
220
  end
@@ -235,6 +249,7 @@ class WindowsTask
235
249
  end
236
250
 
237
251
  def download(package, archive_path)
252
+ rake_output_message "Downloading... #{package.archive_url}"
238
253
  open(package.archive_url) do |downloaded_archive|
239
254
  begin
240
255
  archive_path.open("wb") do |archive_file|
@@ -435,8 +450,8 @@ windows_task = WindowsTask.new(spec) do |task|
435
450
  },
436
451
  {
437
452
  :name => "libpng",
438
- :version => "1.6.10",
439
- :download_base_url => "http://sourceforge.net/projects/libpng/files/libpng16/1.6.10",
453
+ :version => "1.6.14",
454
+ :download_base_url => "http://sourceforge.net/projects/libpng/files/libpng16/1.6.14",
440
455
  :windows => {
441
456
  :built_file => "bin/libpng16-16.dll",
442
457
  },
@@ -452,7 +467,7 @@ windows_task = WindowsTask.new(spec) do |task|
452
467
  },
453
468
  {
454
469
  :name => "libxml2",
455
- :version => "2.9.1",
470
+ :version => "2.9.2",
456
471
  :download_base_url => "ftp://xmlsoft.org/libxml2",
457
472
  :compression_method => "gz",
458
473
  :windows => {
@@ -460,6 +475,10 @@ windows_task = WindowsTask.new(spec) do |task|
460
475
  :configure_args => [
461
476
  "--without-python",
462
477
  ],
478
+ :patches => [
479
+ "remove-empty-z_dir-ldflags.diff",
480
+ ],
481
+ :need_autoreconf => true,
463
482
  },
464
483
  },
465
484
  {
@@ -481,7 +500,7 @@ windows_task = WindowsTask.new(spec) do |task|
481
500
  },
482
501
  {
483
502
  :name => "pixman",
484
- :version => "0.32.4",
503
+ :version => "0.32.6",
485
504
  :download_site => :cairo,
486
505
  :compression_method => "gz",
487
506
  :windows => {
@@ -490,13 +509,17 @@ windows_task = WindowsTask.new(spec) do |task|
490
509
  },
491
510
  {
492
511
  :name => "cairo",
493
- :version => "1.12.16",
512
+ :version => "1.14.0",
494
513
  :download_site => :cairo,
495
514
  :windows => {
496
515
  :built_file => "bin/libcairo-2.dll",
497
516
  :configure_args => [
498
517
  "--enable-gobject",
499
518
  ],
519
+ :patches => [
520
+ "cairo-1.14-missing-exeext-float-m4.diff"
521
+ ],
522
+ :need_autoreconf => true,
500
523
  },
501
524
  },
502
525
  ]
@@ -581,3 +604,17 @@ langs.each do |lang,|
581
604
  rm Dir[File.join(lang_doc_dir, "*.{rd,rdc,rbl}")]
582
605
  end
583
606
  end
607
+
608
+ file "Makefile" => ["extconf.rb", "ext/cairo/extconf.rb"] do
609
+ ruby("extconf.rb")
610
+ end
611
+
612
+ desc "Configure"
613
+ task :configure => "Makefile"
614
+
615
+ desc "Run test"
616
+ task :test => :configure do
617
+ ruby("test/run-test.rb")
618
+ end
619
+
620
+ task :default => :test
@@ -29,13 +29,13 @@ major, minor, micro = 1, 2, 0
29
29
  base_dir = Pathname(__FILE__).dirname.parent.parent
30
30
  checking_for(checking_message("Win32 OS")) do
31
31
  case RUBY_PLATFORM
32
- when /cygwin|mingw|mswin32/
32
+ when /mingw|mswin32/
33
33
  $defs << "-DRUBY_CAIRO_PLATFORM_WIN32"
34
34
  import_library_name = "libruby-#{module_name}.a"
35
35
  $DLDFLAGS << " -Wl,--out-implib=#{import_library_name}"
36
36
  $cleanfiles << import_library_name
37
- if with_config('vendor-override', true)
38
- binary_base_dir = base_dir + "vendor" + "local"
37
+ binary_base_dir = base_dir + "vendor" + "local"
38
+ if with_config('vendor-override', binary_base_dir.exist?)
39
39
  $CFLAGS += " -I#{binary_base_dir}/include"
40
40
  pkg_config_dir = binary_base_dir + "lib" + "pkgconfig"
41
41
  PKGConfig.add_path(pkg_config_dir.to_s)
@@ -5,7 +5,7 @@
5
5
  * $Author: kou $
6
6
  * $Date: 2008-09-19 12:56:27 $
7
7
  *
8
- * Copyright 2006-2008 Kouhei Sutou <kou@cozmixng.org>
8
+ * Copyright 2006-2014 Kouhei Sutou <kou@cozmixng.org>
9
9
  * Copyright 2005 Øyvind Kolås <pippin@freedesktop.org>
10
10
  * Copyright 2004-2005 MenTaLguY <mental@rydia.com>
11
11
  *
@@ -72,8 +72,8 @@ RB_CAIRO_BEGIN_DECLS
72
72
  #endif
73
73
 
74
74
  #define RB_CAIRO_VERSION_MAJOR 1
75
- #define RB_CAIRO_VERSION_MINOR 12
76
- #define RB_CAIRO_VERSION_MICRO 9
75
+ #define RB_CAIRO_VERSION_MINOR 14
76
+ #define RB_CAIRO_VERSION_MICRO 0
77
77
 
78
78
  RB_CAIRO_VAR VALUE rb_mCairo;
79
79
  RB_CAIRO_VAR VALUE rb_cCairo_Context;
@@ -651,6 +651,14 @@ Init_cairo_constants (void)
651
651
  rb_define_const (rb_mCairo_MimeType, "UNIQUE_ID",
652
652
  rb_str_new2 (CAIRO_MIME_TYPE_UNIQUE_ID));
653
653
  #endif
654
+ #if CAIRO_CHECK_VERSION(1, 14, 0)
655
+ rb_define_const (rb_mCairo_MimeType, "JBIG2",
656
+ rb_str_new2 (CAIRO_MIME_TYPE_JBIG2));
657
+ rb_define_const (rb_mCairo_MimeType, "JBIG2_GLOBAL",
658
+ rb_str_new2 (CAIRO_MIME_TYPE_JBIG2_GLOBAL));
659
+ rb_define_const (rb_mCairo_MimeType, "JBIG2_GLOBAL_ID",
660
+ rb_str_new2 (CAIRO_MIME_TYPE_JBIG2_GLOBAL_ID));
661
+ #endif
654
662
 
655
663
  #if CAIRO_CHECK_VERSION(1, 10, 0)
656
664
  rb_mCairo_RegionOverlap = rb_define_module_under (rb_mCairo, "RegionOverlap");
@@ -5,7 +5,7 @@
5
5
  * $Author: kou $
6
6
  * $Date: 2008-09-26 13:52:08 $
7
7
  *
8
- * Copyright 2005-2010 Kouhei Sutou <kou@cozmixng.org>
8
+ * Copyright 2005-2014 Kouhei Sutou <kou@cozmixng.org>
9
9
  * Copyright 2005 Øyvind Kolås <pippin@freedesktop.org>
10
10
  * Copyright 2004-2005 MenTaLguY <mental@rydia.com>
11
11
  *
@@ -129,6 +129,51 @@ cr_destroy_with_destroy_check (VALUE self)
129
129
  return Qnil;
130
130
  }
131
131
 
132
+ static VALUE
133
+ cr_s_wrap (VALUE self, VALUE pointer)
134
+ {
135
+ VALUE result;
136
+ VALUE rb_cr;
137
+ cairo_t *cr;
138
+
139
+ if (NIL_P (rb_cairo__cFFIPointer))
140
+ {
141
+ rb_raise (rb_eNotImpError,
142
+ "%s: FFI::Pointer is required",
143
+ rb_id2name (rb_frame_this_func ()));
144
+ }
145
+
146
+ if (!RTEST (rb_obj_is_kind_of (pointer, rb_cairo__cFFIPointer)))
147
+ {
148
+ rb_raise (rb_eArgError,
149
+ "must be FFI::Pointer: %s",
150
+ rb_cairo__inspect (pointer));
151
+ }
152
+
153
+ {
154
+ VALUE rb_cr_address;
155
+ rb_cr_address = rb_funcall (pointer, rb_intern ("address"), 0);
156
+ cr = NUM2PTR (rb_cr_address);
157
+ cr_check_status (cr);
158
+ }
159
+
160
+ rb_cr = rb_obj_alloc (self);
161
+ cairo_reference (cr);
162
+ DATA_PTR (rb_cr) = cr;
163
+ rb_ivar_set (rb_cr, cr_id_surface, Qnil);
164
+
165
+ if (rb_block_given_p ())
166
+ {
167
+ result = rb_ensure (rb_yield, rb_cr, cr_destroy_with_destroy_check, rb_cr);
168
+ }
169
+ else
170
+ {
171
+ result = rb_cr;
172
+ }
173
+
174
+ return result;
175
+ }
176
+
132
177
  static VALUE
133
178
  cr_initialize (VALUE self, VALUE target)
134
179
  {
@@ -138,6 +183,7 @@ cr_initialize (VALUE self, VALUE target)
138
183
  cr = cairo_create (RVAL2CRSURFACE (target));
139
184
  cr_check_status (cr);
140
185
  rb_ivar_set (self, cr_id_surface, target);
186
+ rb_ivar_set (self, cr_id_source, Qnil);
141
187
  if (rb_ivar_defined (target, rb_cairo__io_id_output))
142
188
  cr_set_user_data (cr,
143
189
  &cr_object_holder_key,
@@ -149,6 +195,17 @@ cr_initialize (VALUE self, VALUE target)
149
195
  return result;
150
196
  }
151
197
 
198
+ static VALUE
199
+ cr_to_ptr (VALUE self)
200
+ {
201
+ if (NIL_P (rb_cairo__cFFIPointer))
202
+ return Qnil;
203
+
204
+ return rb_funcall (rb_cairo__cFFIPointer, rb_intern ("new"),
205
+ 1, PTR2NUM (_SELF));
206
+ }
207
+
208
+
152
209
  static VALUE
153
210
  cr_restore (VALUE self)
154
211
  {
@@ -1526,6 +1583,9 @@ Init_cairo_context (void)
1526
1583
  rb_cairo__initialize_gc_guard_holder_class (rb_cCairo_Context);
1527
1584
  rb_set_end_proc(cr_destroy_all_guarded_contexts_at_end, Qnil);
1528
1585
 
1586
+ /* For integrate other libraries such as a FFI based library. */
1587
+ rb_define_singleton_method (rb_cCairo_Context, "wrap", cr_s_wrap, 1);
1588
+
1529
1589
  /* Functions for manipulating state objects */
1530
1590
  rb_define_method (rb_cCairo_Context, "initialize", cr_initialize, 1);
1531
1591
  rb_define_method (rb_cCairo_Context, "destroy", cr_destroy, 0);
@@ -1675,5 +1735,7 @@ Init_cairo_context (void)
1675
1735
  rb_define_method (rb_cCairo_Context, "copy_path_flat", cr_copy_path_flat, 0);
1676
1736
  rb_define_method (rb_cCairo_Context, "append_path", cr_copy_append_path, 1);
1677
1737
 
1738
+ rb_define_method (rb_cCairo_Context, "to_ptr", cr_to_ptr, 0);
1739
+
1678
1740
  RB_CAIRO_DEF_SETTERS (rb_cCairo_Context);
1679
1741
  }
@@ -61,6 +61,9 @@ static VALUE rb_eCairo_DeviceError;
61
61
  static VALUE rb_eCairo_InvalidMeshConstruction;
62
62
  static VALUE rb_eCairo_DeviceFinished;
63
63
  #endif
64
+ #if CAIRO_CHECK_VERSION(1, 14, 0)
65
+ static VALUE rb_eCairo_JBIG2GlobalMissing;
66
+ #endif
64
67
 
65
68
  void
66
69
  rb_cairo_check_status (cairo_status_t status)
@@ -192,6 +195,11 @@ rb_cairo_check_status (cairo_status_t status)
192
195
  rb_raise (rb_eCairo_DeviceFinished, "%s", string);
193
196
  break;
194
197
  #endif
198
+ #if CAIRO_CHECK_VERSION(1, 14, 0)
199
+ case CAIRO_STATUS_JBIG2_GLOBAL_MISSING:
200
+ rb_raise (rb_eCairo_JBIG2GlobalMissing, "%s", string);
201
+ break;
202
+ #endif
195
203
  #if CAIRO_CHECK_VERSION(1, 10, 0)
196
204
  case CAIRO_STATUS_LAST_STATUS:
197
205
  #else
@@ -285,6 +293,10 @@ rb_cairo__exception_to_status (VALUE exception)
285
293
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_DeviceError))
286
294
  return CAIRO_STATUS_DEVICE_ERROR;
287
295
  #endif
296
+ #if CAIRO_CHECK_VERSION(1, 14, 0)
297
+ else if (rb_cairo__is_kind_of (exception, rb_eCairo_JBIG2GlobalMissing))
298
+ return CAIRO_STATUS_JBIG2_GLOBAL_MISSING;
299
+ #endif
288
300
 
289
301
  return -1;
290
302
  }
@@ -426,4 +438,9 @@ Init_cairo_exception ()
426
438
  rb_define_class_under (rb_mCairo, "DeviceFinished",
427
439
  rb_eCairo_Error);
428
440
  #endif
441
+ #if CAIRO_CHECK_VERSION(1, 14, 0)
442
+ rb_eCairo_JBIG2GlobalMissing =
443
+ rb_define_class_under (rb_mCairo, "JBIG2GlobalMissing",
444
+ rb_eCairo_Error);
445
+ #endif
429
446
  }
@@ -111,6 +111,16 @@ cr_font_face_allocate (VALUE klass)
111
111
  return Data_Wrap_Struct (klass, NULL, cr_font_face_free, NULL);
112
112
  }
113
113
 
114
+ static VALUE
115
+ cr_font_face_quartz_supported_p (VALUE klass)
116
+ {
117
+ #ifdef CAIRO_HAS_QUARTZ_FONT
118
+ return Qtrue;
119
+ #else
120
+ return Qfalse;
121
+ #endif
122
+ }
123
+
114
124
  #if CAIRO_CHECK_VERSION(1, 7, 6)
115
125
  static VALUE
116
126
  cr_toy_font_face_initialize (int argc, VALUE *argv, VALUE self)
@@ -652,6 +662,9 @@ Init_cairo_font (void)
652
662
  rb_define_class_under (rb_mCairo, "FontFace", rb_cObject);
653
663
  rb_define_alloc_func (rb_cCairo_FontFace, cr_font_face_allocate);
654
664
 
665
+ rb_define_singleton_method (rb_cCairo_FontFace, "quartz_supported?",
666
+ cr_font_face_quartz_supported_p, 0);
667
+
655
668
  #if CAIRO_CHECK_VERSION(1, 7, 6)
656
669
  rb_cCairo_ToyFontFace =
657
670
  rb_define_class_under (rb_mCairo, "ToyFontFace", rb_cCairo_FontFace);
@@ -5,7 +5,7 @@
5
5
  * $Author: kou $
6
6
  * $Date: 2008-08-17 07:21:42 $
7
7
  *
8
- * Copyright 2005-2008 Kouhei Sutou <kou@cozmixng.org>
8
+ * Copyright 2005-2014 Kouhei Sutou <kou@cozmixng.org>
9
9
  *
10
10
  * This file is made available under the same terms as Ruby
11
11
  *
@@ -14,6 +14,8 @@
14
14
  #include "rb_cairo.h"
15
15
  #include "rb_cairo_private.h"
16
16
 
17
+ VALUE rb_cairo__cFFIPointer;
18
+
17
19
  static ID cr_id_normalize_const_name;
18
20
  static ID cr_id_objects;
19
21
  static ID cr_id_dup;
@@ -239,4 +241,15 @@ Init_cairo_private (void)
239
241
  cr_id_dup = rb_intern ("dup");
240
242
  cr_id_inspect = rb_intern ("inspect");
241
243
  cr_id_exit_application = rb_intern ("exit_application");
244
+
245
+ if (rb_const_defined (rb_cObject, rb_intern ("FFI")))
246
+ {
247
+ rb_cairo__cFFIPointer =
248
+ rb_const_get (rb_const_get (rb_cObject, rb_intern ("FFI")),
249
+ rb_intern ("Pointer"));
250
+ }
251
+ else
252
+ {
253
+ rb_cairo__cFFIPointer = Qnil;
254
+ }
242
255
  }
@@ -5,7 +5,7 @@
5
5
  * $Author: kou $
6
6
  * $Date: 2008-08-17 07:21:42 $
7
7
  *
8
- * Copyright 2005-2008 Kouhei Sutou <kou@cozmixng.org>
8
+ * Copyright 2005-2014 Kouhei Sutou <kou@cozmixng.org>
9
9
  *
10
10
  * This file is made available under the same terms as Ruby
11
11
  *
@@ -43,6 +43,15 @@
43
43
  # define RB_ERRINFO (ruby_errinfo)
44
44
  #endif
45
45
 
46
+ /* from dl/dl.h (ruby 1.9) */
47
+ #if SIZEOF_LONG == SIZEOF_VOIDP
48
+ # define PTR2NUM(x) (ULONG2NUM((unsigned long)(x)))
49
+ # define NUM2PTR(x) ((void *)(NUM2ULONG(x)))
50
+ #else
51
+ # define PTR2NUM(x) (ULL2NUM((unsigned long long)(x)))
52
+ # define NUM2PTR(x) ((void *)(NUM2ULL(x)))
53
+ #endif
54
+
46
55
  extern void Init_cairo_private (void);
47
56
  extern void Init_cairo_io (void);
48
57
  extern void Init_cairo_constants (void);
@@ -115,4 +124,6 @@ cairo_status_t rb_cairo__exception_to_status (VALUE exception);
115
124
  typedef VALUE (*cr_callback_func_t) (VALUE user_data);
116
125
  VALUE rb_cairo__invoke_callback (cr_callback_func_t func, VALUE user_data);
117
126
 
127
+ extern VALUE rb_cairo__cFFIPointer;
128
+
118
129
  #endif
@@ -54,7 +54,8 @@ enum ruby_value_type {
54
54
  # include <cairo-quartz.h>
55
55
  # define T_DATA RUBY_T_DATA
56
56
  # define RB_CAIRO_HAS_QUARTZ_SURFACE
57
- # ifdef RB_CAIRO_HAS_QUARTZ_IMAGE_SURFACE_TYPE
57
+ # ifdef CAIRO_HAS_QUARTZ_IMAGE_SURFACE
58
+ # include <cairo-quartz-image.h>
58
59
  # define RB_CAIRO_HAS_QUARTZ_IMAGE_SURFACE
59
60
  # endif
60
61
  #endif
@@ -829,6 +830,27 @@ cr_surface_get_device_offset (VALUE self)
829
830
  return rb_ary_new3 (2, rb_float_new (x_offset), rb_float_new (y_offset));
830
831
  }
831
832
 
833
+ #if CAIRO_CHECK_VERSION(1, 14, 0)
834
+ static VALUE
835
+ cr_surface_set_device_scale (VALUE self, VALUE x_scale, VALUE y_scale)
836
+ {
837
+ cairo_surface_set_device_scale (_SELF,
838
+ NUM2DBL (x_scale),
839
+ NUM2DBL (y_scale));
840
+ cr_surface_check_status (_SELF);
841
+ return self;
842
+ }
843
+
844
+ static VALUE
845
+ cr_surface_get_device_scale (VALUE self)
846
+ {
847
+ double x_scale, y_scale;
848
+
849
+ cairo_surface_get_device_scale (_SELF, &x_scale, &y_scale);
850
+ return rb_ary_new3 (2, rb_float_new (x_scale), rb_float_new (y_scale));
851
+ }
852
+ #endif
853
+
832
854
  static VALUE
833
855
  cr_surface_set_fallback_resolution (VALUE self,
834
856
  VALUE x_pixels_per_inch,
@@ -1199,8 +1221,10 @@ cr_ps_surface_set_eps (VALUE self, VALUE eps)
1199
1221
  /* Quartz-surface functions */
1200
1222
  #include <objc/objc-runtime.h>
1201
1223
 
1224
+ # ifdef HAVE_RUBY_COCOA
1202
1225
  BOOL rbobj_to_nsobj (VALUE obj, id* nsobj);
1203
1226
  VALUE ocid_to_rbobj (VALUE context_obj, id ocid);
1227
+ # endif
1204
1228
 
1205
1229
  static VALUE
1206
1230
  cr_quartz_surface_initialize (int argc, VALUE *argv, VALUE self)
@@ -1211,10 +1235,9 @@ cr_quartz_surface_initialize (int argc, VALUE *argv, VALUE self)
1211
1235
  cairo_surface_t *surface = NULL;
1212
1236
  cairo_format_t format = CAIRO_FORMAT_ARGB32;
1213
1237
  VALUE arg1, arg2, arg3, rb_width, rb_height;
1214
- #ifdef HAVE_RUBY_COCOA
1238
+ # ifdef HAVE_RUBY_COCOA
1215
1239
  static VALUE rb_cOSXCGContextRef = Qnil;
1216
- #endif
1217
- static VALUE rb_cFFIPointer = Qnil;
1240
+ # endif
1218
1241
 
1219
1242
  rb_scan_args (argc, argv, "21", &arg1, &arg2, &arg3);
1220
1243
 
@@ -1235,27 +1258,23 @@ cr_quartz_surface_initialize (int argc, VALUE *argv, VALUE self)
1235
1258
  format = RVAL2CRFORMAT (arg1);
1236
1259
  break;
1237
1260
  default:
1238
- #ifdef HAVE_RUBY_COCOA
1261
+ # ifdef HAVE_RUBY_COCOA
1239
1262
  if (NIL_P (rb_cOSXCGContextRef))
1240
1263
  rb_cOSXCGContextRef =
1241
1264
  rb_const_get (rb_const_get (rb_cObject, rb_intern ("OSX")),
1242
1265
  rb_intern ("CGContextRef"));
1243
- #endif
1244
-
1245
- if (NIL_P (rb_cFFIPointer))
1246
- rb_cFFIPointer =
1247
- rb_const_get (rb_const_get (rb_cObject, rb_intern ("FFI")),
1248
- rb_intern ("Pointer"));
1266
+ # endif
1249
1267
 
1250
- #ifdef HAVE_RUBY_COCOA
1268
+ # ifdef HAVE_RUBY_COCOA
1251
1269
  if (RTEST (rb_obj_is_kind_of (arg1, rb_cOSXCGContextRef)))
1252
1270
  {
1253
1271
  rbobj_to_nsobj (arg1, &objc_object);
1254
1272
  }
1255
1273
  else
1256
- #endif
1274
+ # endif
1257
1275
  {
1258
- if (RTEST (rb_obj_is_kind_of (arg1, rb_cFFIPointer)))
1276
+ if (!NIL_P (rb_cairo__cFFIPointer) &&
1277
+ RTEST (rb_obj_is_kind_of (arg1, rb_cairo__cFFIPointer)))
1259
1278
  {
1260
1279
  VALUE rb_objc_pointer;
1261
1280
  rb_objc_pointer = rb_funcall (arg1,
@@ -1305,27 +1324,25 @@ cr_quartz_surface_initialize (int argc, VALUE *argv, VALUE self)
1305
1324
  static VALUE
1306
1325
  cr_quartz_surface_get_cg_context (VALUE self)
1307
1326
  {
1327
+ # ifdef HAVE_RUBY_COCOA
1308
1328
  CGContextRef context;
1309
1329
  id objc_object;
1310
1330
 
1311
1331
  context = cairo_quartz_surface_get_cg_context (_SELF);
1312
1332
  objc_object = (id)context;
1313
1333
  return ocid_to_rbobj (Qnil, objc_object);
1334
+ # else
1335
+ rb_raise (rb_eNotImpError,
1336
+ "%s#cg_context requires RubyCocoa",
1337
+ rb_obj_classname(self));
1338
+ return Qnil;
1339
+ # endif
1314
1340
  }
1315
1341
  #endif
1316
1342
 
1317
1343
  #ifdef CAIRO_HAS_WIN32_SURFACE
1318
1344
  /* Win32 surface functions */
1319
1345
 
1320
- /* from dl/dl.h (ruby 1.9) */
1321
- # if SIZEOF_LONG == SIZEOF_VOIDP
1322
- # define PTR2NUM(x) (ULONG2NUM((unsigned long)(x)))
1323
- # define NUM2PTR(x) ((void *)(NUM2ULONG(x)))
1324
- # else
1325
- # define PTR2NUM(x) (ULL2NUM((unsigned long long)(x)))
1326
- # define NUM2PTR(x) ((void *)(NUM2ULL(x)))
1327
- # endif
1328
-
1329
1346
  static VALUE
1330
1347
  cr_win32_surface_initialize (int argc, VALUE *argv, VALUE self)
1331
1348
  {
@@ -1467,6 +1484,7 @@ cr_win32_printing_surface_initialize (VALUE self, VALUE hdc)
1467
1484
  #endif
1468
1485
 
1469
1486
  #ifdef RB_CAIRO_HAS_QUARTZ_IMAGE_SURFACE
1487
+
1470
1488
  /* Quartz image surface functions */
1471
1489
  static VALUE
1472
1490
  cr_quartz_image_surface_initialize (VALUE self, VALUE image_surface)
@@ -2005,6 +2023,12 @@ Init_cairo_surface (void)
2005
2023
  cr_surface_set_device_offset, 2);
2006
2024
  rb_define_method (rb_cCairo_Surface, "device_offset",
2007
2025
  cr_surface_get_device_offset, 0);
2026
+ #if CAIRO_CHECK_VERSION(1, 14, 0)
2027
+ rb_define_method (rb_cCairo_Surface, "set_device_scale",
2028
+ cr_surface_set_device_scale, 2);
2029
+ rb_define_method (rb_cCairo_Surface, "device_scale",
2030
+ cr_surface_get_device_scale, 0);
2031
+ #endif
2008
2032
  rb_define_method (rb_cCairo_Surface, "set_fallback_resolution",
2009
2033
  cr_surface_set_fallback_resolution, 2);
2010
2034
  #if CAIRO_CHECK_VERSION(1, 7, 2)
@@ -2,7 +2,9 @@ module Cairo
2
2
  class Surface
3
3
  class << self
4
4
  def supported?(type)
5
- supported_predicate = "#{type.to_s.downcase}_supported?"
5
+ type_components = type.to_s.split(/([A-Z][a-z\d]+)/).reject(&:empty?)
6
+ snake_case_type_name = type_components.join("_").downcase
7
+ supported_predicate = "#{snake_case_type_name}_supported?"
6
8
  return false unless respond_to?(supported_predicate)
7
9
  send(supported_predicate)
8
10
  end
@@ -1,5 +1,6 @@
1
1
  require 'cairo'
2
2
  require 'stringio'
3
+ require 'test/unit/notify'
3
4
 
4
5
  module CairoTestUtils
5
6
  private
@@ -17,6 +18,10 @@ module CairoTestUtils
17
18
  /cygwin|mingw|mswin32|bccwin32/.match(RUBY_PLATFORM) ? true : false
18
19
  end
19
20
 
21
+ def quartz?
22
+ Cairo::FontFace.quartz_supported?
23
+ end
24
+
20
25
  def only_device(name)
21
26
  only_cairo_version(1, 10)
22
27
 
@@ -13,4 +13,15 @@ class ConstantsTest < Test::Unit::TestCase
13
13
  [0,
14
14
  Cairo::TextClusterFlag::BACKWARD])
15
15
  end
16
+
17
+ def test_new_constants_since_1_14_0
18
+ if Cairo.satisfied_version?(1, 14, 0)
19
+ assertion = :assert_const_defined
20
+ else
21
+ assertion = :assert_not_const_defined
22
+ end
23
+ send(assertion, Cairo::MimeType, :JBIG2)
24
+ send(assertion, Cairo::MimeType, :JBIG2_GLOBAL)
25
+ send(assertion, Cairo::MimeType, :JBIG2_GLOBAL_ID)
26
+ end
16
27
  end
@@ -73,7 +73,7 @@ class ContextTest < Test::Unit::TestCase
73
73
 
74
74
  face = context.font_face
75
75
  default_font_family = ""
76
- # default_font_family = "Helvetica" if quartz?
76
+ default_font_family = "Helvetica" if quartz?
77
77
  default_font_family = "Arial" if win32?
78
78
  assert_equal([default_font_family,
79
79
  Cairo::FONT_SLANT_NORMAL,
@@ -16,6 +16,15 @@ class ExceptionTest < Test::Unit::TestCase
16
16
  send(assertion, "InvalidWeight")
17
17
  end
18
18
 
19
+ def test_new_symbols_since_1_14_0
20
+ if Cairo.satisfied_version?(1, 14, 0)
21
+ assertion = :assert_defined
22
+ else
23
+ assertion = :assert_not_defined
24
+ end
25
+ send(assertion, "JBIG2GlobalMissing")
26
+ end
27
+
19
28
  private
20
29
  def assert_defined(name)
21
30
  assert_true(Cairo.const_defined?(name))
@@ -8,7 +8,7 @@ class FontFaceTest < Test::Unit::TestCase
8
8
 
9
9
  face = Cairo::ToyFontFace.new
10
10
  default_font_family = ""
11
- # default_font_family = "Helvetica" if quartz?
11
+ default_font_family = "Helvetica" if quartz?
12
12
  default_font_family = "Arial" if win32?
13
13
  assert_equal([default_font_family,
14
14
  Cairo::FONT_SLANT_NORMAL,
@@ -0,0 +1,13 @@
1
+ class QuartzImageSurfaceTest < Test::Unit::TestCase
2
+ include CairoTestUtils
3
+
4
+ def setup
5
+ only_surface("QuartzImage")
6
+ end
7
+
8
+ def test_quartz_image_surface
9
+ surface = Cairo::ImageSurface.new(100, 100)
10
+ quartz_surface = Cairo::QuartzImageSurface.new(surface)
11
+ assert_kind_of(Cairo::QuartzImageSurface, quartz_surface)
12
+ end
13
+ end
@@ -28,6 +28,16 @@ class SurfaceTest < Test::Unit::TestCase
28
28
  end
29
29
  end
30
30
 
31
+ def test_device_scale
32
+ only_cairo_version(1, 14, 0)
33
+ surface = Cairo::ImageSurface.new(100, 100)
34
+
35
+ assert_equal([1.0, 1.0], surface.device_scale)
36
+
37
+ surface.set_device_scale(3.0, 4.0)
38
+ assert_equal([3.0, 4.0], surface.device_scale)
39
+ end
40
+
31
41
  def test_fallback_resolution
32
42
  only_cairo_version(1, 7, 2)
33
43
 
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cairo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.9
4
+ version: 1.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-05 00:00:00.000000000 Z
11
+ date: 2014-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pkg-config
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.1.5
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.1.5
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: test-unit-notify
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake-compiler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: packnga
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  description: Ruby bindings for cairo
@@ -95,84 +95,85 @@ files:
95
95
  - Gemfile
96
96
  - NEWS
97
97
  - README.rdoc
98
- - ext/cairo/extconf.rb
99
98
  - Rakefile
99
+ - ext/cairo/cairo.def
100
+ - ext/cairo/depend
101
+ - ext/cairo/extconf.rb
102
+ - ext/cairo/rb_cairo.c
103
+ - ext/cairo/rb_cairo.h
104
+ - ext/cairo/rb_cairo_constants.c
105
+ - ext/cairo/rb_cairo_context.c
106
+ - ext/cairo/rb_cairo_device.c
107
+ - ext/cairo/rb_cairo_exception.c
108
+ - ext/cairo/rb_cairo_font_extents.c
109
+ - ext/cairo/rb_cairo_font_face.c
110
+ - ext/cairo/rb_cairo_font_options.c
111
+ - ext/cairo/rb_cairo_glyph.c
112
+ - ext/cairo/rb_cairo_io.c
113
+ - ext/cairo/rb_cairo_io.h
114
+ - ext/cairo/rb_cairo_matrix.c
115
+ - ext/cairo/rb_cairo_path.c
116
+ - ext/cairo/rb_cairo_pattern.c
117
+ - ext/cairo/rb_cairo_private.c
118
+ - ext/cairo/rb_cairo_private.h
119
+ - ext/cairo/rb_cairo_rectangle.c
120
+ - ext/cairo/rb_cairo_region.c
121
+ - ext/cairo/rb_cairo_scaled_font.c
122
+ - ext/cairo/rb_cairo_surface.c
123
+ - ext/cairo/rb_cairo_text_cluster.c
124
+ - ext/cairo/rb_cairo_text_extents.c
100
125
  - lib/cairo.rb
101
- - lib/cairo/device.rb
102
- - lib/cairo/path.rb
103
- - lib/cairo/context/triangle.rb
104
- - lib/cairo/context/path.rb
126
+ - lib/cairo/color.rb
127
+ - lib/cairo/colors.rb
128
+ - lib/cairo/constants.rb
129
+ - lib/cairo/context.rb
130
+ - lib/cairo/context/blur.rb
105
131
  - lib/cairo/context/circle.rb
106
132
  - lib/cairo/context/color.rb
107
- - lib/cairo/context/blur.rb
133
+ - lib/cairo/context/path.rb
108
134
  - lib/cairo/context/rectangle.rb
109
- - lib/cairo/context.rb
135
+ - lib/cairo/context/triangle.rb
136
+ - lib/cairo/device.rb
110
137
  - lib/cairo/paper.rb
111
- - lib/cairo/color.rb
112
- - lib/cairo/constants.rb
113
- - lib/cairo/surface.rb
114
- - lib/cairo/colors.rb
115
- - lib/cairo/point.rb
116
- - lib/cairo/pattern.rb
117
138
  - lib/cairo/papers.rb
139
+ - lib/cairo/path.rb
140
+ - lib/cairo/pattern.rb
141
+ - lib/cairo/point.rb
142
+ - lib/cairo/surface.rb
143
+ - samples/agg/aa_test.rb
144
+ - samples/blur.rb
145
+ - samples/pac-nomralize.rb
146
+ - samples/pac-tee.rb
118
147
  - samples/pac.rb
119
148
  - samples/png.rb
120
- - samples/pac-tee.rb
121
149
  - samples/scalable.rb
122
- - samples/pac-nomralize.rb
123
150
  - samples/text-on-path.rb
124
- - samples/blur.rb
125
- - samples/agg/aa_test.rb
126
151
  - samples/text2.rb
127
- - ext/cairo/cairo.def
128
- - ext/cairo/depend
129
- - ext/cairo/rb_cairo_surface.c
130
- - ext/cairo/rb_cairo_scaled_font.c
131
- - ext/cairo/rb_cairo_font_options.c
132
- - ext/cairo/rb_cairo_font_face.c
133
- - ext/cairo/rb_cairo_region.c
134
- - ext/cairo/rb_cairo_io.c
135
- - ext/cairo/rb_cairo_path.c
136
- - ext/cairo/rb_cairo_exception.c
137
- - ext/cairo/rb_cairo_font_extents.c
138
- - ext/cairo/rb_cairo_context.c
139
- - ext/cairo/rb_cairo.c
140
- - ext/cairo/rb_cairo_text_cluster.c
141
- - ext/cairo/rb_cairo_text_extents.c
142
- - ext/cairo/rb_cairo_pattern.c
143
- - ext/cairo/rb_cairo_private.c
144
- - ext/cairo/rb_cairo_matrix.c
145
- - ext/cairo/rb_cairo_glyph.c
146
- - ext/cairo/rb_cairo_rectangle.c
147
- - ext/cairo/rb_cairo_constants.c
148
- - ext/cairo/rb_cairo_device.c
149
- - ext/cairo/rb_cairo.h
150
- - ext/cairo/rb_cairo_io.h
151
- - ext/cairo/rb_cairo_private.h
152
- - test/test_text_extents.rb
153
- - test/test_font_face.rb
154
- - test/test_region.rb
152
+ - test/cairo-test-utils.rb
153
+ - test/run-test.rb
154
+ - test/test_color.rb
155
+ - test/test_constants.rb
156
+ - test/test_context.rb
155
157
  - test/test_exception.rb
156
158
  - test/test_font_extents.rb
157
- - test/test_scaled_font.rb
159
+ - test/test_font_face.rb
160
+ - test/test_font_options.rb
161
+ - test/test_image_surface.rb
158
162
  - test/test_paper.rb
159
- - test/test_tee_surface.rb
160
- - test/test_text_to_glyphs_data.rb
161
- - test/test_constants.rb
162
- - test/test_script_surface.rb
163
- - test/run-test.rb
164
- - test/test_xml_device.rb
163
+ - test/test_quartz_image_surface.rb
164
+ - test/test_raster_source_pattern.rb
165
165
  - test/test_recording_surface.rb
166
- - test/test_color.rb
166
+ - test/test_region.rb
167
+ - test/test_scaled_font.rb
168
+ - test/test_script_device.rb
169
+ - test/test_script_surface.rb
167
170
  - test/test_surface.rb
171
+ - test/test_tee_surface.rb
168
172
  - test/test_text_cluster.rb
169
- - test/cairo-test-utils.rb
170
- - test/test_font_options.rb
171
- - test/test_context.rb
172
- - test/test_script_device.rb
173
+ - test/test_text_extents.rb
174
+ - test/test_text_to_glyphs_data.rb
175
+ - test/test_xml_device.rb
173
176
  - test/test_xml_surface.rb
174
- - test/test_raster_source_pattern.rb
175
- - test/test_image_surface.rb
176
177
  homepage: http://cairographics.org/rcairo
177
178
  licenses:
178
179
  - Ruby's
@@ -183,17 +184,17 @@ require_paths:
183
184
  - lib
184
185
  required_ruby_version: !ruby/object:Gem::Requirement
185
186
  requirements:
186
- - - '>='
187
+ - - ">="
187
188
  - !ruby/object:Gem::Version
188
189
  version: '0'
189
190
  required_rubygems_version: !ruby/object:Gem::Requirement
190
191
  requirements:
191
- - - '>='
192
+ - - ">="
192
193
  - !ruby/object:Gem::Version
193
194
  version: '0'
194
195
  requirements: []
195
- rubyforge_project: cairo
196
- rubygems_version: 2.0.14
196
+ rubyforge_project:
197
+ rubygems_version: 2.2.2
197
198
  signing_key:
198
199
  specification_version: 4
199
200
  summary: Ruby bindings for cairo
@@ -216,6 +217,7 @@ test_files:
216
217
  - test/test_surface.rb
217
218
  - test/test_text_cluster.rb
218
219
  - test/cairo-test-utils.rb
220
+ - test/test_quartz_image_surface.rb
219
221
  - test/test_font_options.rb
220
222
  - test/test_context.rb
221
223
  - test/test_script_device.rb