cairo 1.15.13-x86-mingw32 → 1.15.14-x86-mingw32

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.
Files changed (151) hide show
  1. checksums.yaml +4 -4
  2. data/NEWS +24 -0
  3. data/README.rdoc +11 -40
  4. data/Rakefile +4 -2
  5. data/ext/cairo/rb_cairo.h +1 -1
  6. data/ext/cairo/rb_cairo_context.c +35 -3
  7. data/ext/cairo/rb_cairo_font_options.c +5 -6
  8. data/ext/cairo/rb_cairo_private.h +2 -2
  9. data/ext/cairo/rb_cairo_scaled_font.c +11 -2
  10. data/ext/cairo/rb_cairo_surface.c +89 -48
  11. data/lib/2.2/cairo.so +0 -0
  12. data/lib/2.3/cairo.so +0 -0
  13. data/lib/2.4/cairo.so +0 -0
  14. data/lib/2.5/cairo.so +0 -0
  15. data/test/{cairo-test-utils.rb → helper.rb} +4 -5
  16. data/test/run-test.rb +3 -10
  17. data/test/test_context.rb +6 -6
  18. data/test/test_font_extents.rb +1 -1
  19. data/test/test_font_face.rb +1 -1
  20. data/test/test_font_options.rb +1 -1
  21. data/test/test_image_surface.rb +2 -2
  22. data/test/test_pdf_surface.rb +1 -1
  23. data/test/test_quartz_image_surface.rb +1 -1
  24. data/test/test_raster_source_pattern.rb +13 -13
  25. data/test/test_recording_surface.rb +2 -2
  26. data/test/test_region.rb +1 -1
  27. data/test/test_scaled_font.rb +1 -1
  28. data/test/test_script_device.rb +1 -1
  29. data/test/test_script_surface.rb +1 -1
  30. data/test/test_surface.rb +5 -5
  31. data/test/test_svg_surface.rb +1 -1
  32. data/test/test_tee_surface.rb +2 -2
  33. data/test/test_text_cluster.rb +1 -1
  34. data/test/test_text_extents.rb +1 -1
  35. data/test/test_text_to_glyphs_data.rb +1 -1
  36. data/test/test_xml_device.rb +1 -1
  37. data/test/test_xml_surface.rb +2 -2
  38. data/vendor/local/bin/fc-cache.exe +0 -0
  39. data/vendor/local/bin/fc-cat.exe +0 -0
  40. data/vendor/local/bin/fc-conflist.exe +0 -0
  41. data/vendor/local/bin/fc-list.exe +0 -0
  42. data/vendor/local/bin/fc-match.exe +0 -0
  43. data/vendor/local/bin/fc-pattern.exe +0 -0
  44. data/vendor/local/bin/fc-query.exe +0 -0
  45. data/vendor/local/bin/fc-scan.exe +0 -0
  46. data/vendor/local/bin/fc-validate.exe +0 -0
  47. data/vendor/local/bin/libcairo-2.dll +0 -0
  48. data/vendor/local/bin/libcairo-gobject-2.dll +0 -0
  49. data/vendor/local/bin/libcairo-script-interpreter-2.dll +0 -0
  50. data/vendor/local/bin/libfontconfig-1.dll +0 -0
  51. data/vendor/local/bin/libfreetype-6.dll +0 -0
  52. data/vendor/local/bin/libpixman-1-0.dll +0 -0
  53. data/vendor/local/bin/libpng-config +1 -1
  54. data/vendor/local/bin/libpng16-16.dll +0 -0
  55. data/vendor/local/bin/libpng16-config +1 -1
  56. data/vendor/local/bin/libxml2-2.dll +0 -0
  57. data/vendor/local/bin/png-fix-itxt.exe +0 -0
  58. data/vendor/local/bin/pngfix.exe +0 -0
  59. data/vendor/local/bin/xmlcatalog.exe +0 -0
  60. data/vendor/local/bin/xmllint.exe +0 -0
  61. data/vendor/local/bin/zlib1211.dll +0 -0
  62. data/vendor/local/include/freetype2/freetype/config/ftconfig.h +82 -3
  63. data/vendor/local/include/freetype2/freetype/config/ftheader.h +43 -85
  64. data/vendor/local/include/freetype2/freetype/config/ftoption.h +43 -56
  65. data/vendor/local/include/freetype2/freetype/config/ftstdlib.h +1 -1
  66. data/vendor/local/include/freetype2/freetype/freetype.h +185 -85
  67. data/vendor/local/include/freetype2/freetype/ftadvanc.h +1 -1
  68. data/vendor/local/include/freetype2/freetype/ftbbox.h +2 -2
  69. data/vendor/local/include/freetype2/freetype/ftbdf.h +1 -1
  70. data/vendor/local/include/freetype2/freetype/ftbitmap.h +2 -2
  71. data/vendor/local/include/freetype2/freetype/ftbzip2.h +1 -1
  72. data/vendor/local/include/freetype2/freetype/ftcache.h +1 -16
  73. data/vendor/local/include/freetype2/freetype/ftchapters.h +3 -0
  74. data/vendor/local/include/freetype2/freetype/ftcid.h +2 -2
  75. data/vendor/local/include/freetype2/freetype/ftdriver.h +1225 -0
  76. data/vendor/local/include/freetype2/freetype/fterrdef.h +1 -1
  77. data/vendor/local/include/freetype2/freetype/fterrors.h +1 -1
  78. data/vendor/local/include/freetype2/freetype/ftfntfmt.h +1 -1
  79. data/vendor/local/include/freetype2/freetype/ftgasp.h +6 -1
  80. data/vendor/local/include/freetype2/freetype/ftglyph.h +3 -3
  81. data/vendor/local/include/freetype2/freetype/ftgxval.h +5 -5
  82. data/vendor/local/include/freetype2/freetype/ftgzip.h +4 -1
  83. data/vendor/local/include/freetype2/freetype/ftimage.h +18 -18
  84. data/vendor/local/include/freetype2/freetype/ftincrem.h +2 -13
  85. data/vendor/local/include/freetype2/freetype/ftlcdfil.h +5 -18
  86. data/vendor/local/include/freetype2/freetype/ftlist.h +1 -1
  87. data/vendor/local/include/freetype2/freetype/ftlzw.h +1 -1
  88. data/vendor/local/include/freetype2/freetype/ftmac.h +1 -1
  89. data/vendor/local/include/freetype2/freetype/ftmm.h +99 -11
  90. data/vendor/local/include/freetype2/freetype/ftmodapi.h +12 -11
  91. data/vendor/local/include/freetype2/freetype/ftmoderr.h +1 -1
  92. data/vendor/local/include/freetype2/freetype/ftotval.h +1 -1
  93. data/vendor/local/include/freetype2/freetype/ftoutln.h +4 -7
  94. data/vendor/local/include/freetype2/freetype/ftparams.h +205 -0
  95. data/vendor/local/include/freetype2/freetype/ftpfr.h +4 -4
  96. data/vendor/local/include/freetype2/freetype/ftrender.h +2 -2
  97. data/vendor/local/include/freetype2/freetype/ftsizes.h +1 -1
  98. data/vendor/local/include/freetype2/freetype/ftsnames.h +8 -42
  99. data/vendor/local/include/freetype2/freetype/ftstroke.h +6 -6
  100. data/vendor/local/include/freetype2/freetype/ftsynth.h +1 -1
  101. data/vendor/local/include/freetype2/freetype/ftsystem.h +1 -1
  102. data/vendor/local/include/freetype2/freetype/fttrigon.h +1 -1
  103. data/vendor/local/include/freetype2/freetype/fttypes.h +2 -2
  104. data/vendor/local/include/freetype2/freetype/ftwinfnt.h +2 -2
  105. data/vendor/local/include/freetype2/freetype/t1tables.h +10 -1
  106. data/vendor/local/include/freetype2/freetype/ttnameid.h +2 -2
  107. data/vendor/local/include/freetype2/freetype/tttables.h +1 -1
  108. data/vendor/local/include/freetype2/freetype/tttags.h +1 -1
  109. data/vendor/local/include/freetype2/ft2build.h +1 -1
  110. data/vendor/local/include/libpng16/png.h +40 -40
  111. data/vendor/local/include/libpng16/pngconf.h +15 -14
  112. data/vendor/local/include/libpng16/pnglibconf.h +1 -1
  113. data/vendor/local/include/png.h +40 -40
  114. data/vendor/local/include/pngconf.h +15 -14
  115. data/vendor/local/include/pnglibconf.h +1 -1
  116. data/vendor/local/lib/libcairo-gobject.dll.a +0 -0
  117. data/vendor/local/lib/libcairo-gobject.la +1 -1
  118. data/vendor/local/lib/libcairo-script-interpreter.a +0 -0
  119. data/vendor/local/lib/libcairo-script-interpreter.dll.a +0 -0
  120. data/vendor/local/lib/libcairo.a +0 -0
  121. data/vendor/local/lib/libcairo.dll.a +0 -0
  122. data/vendor/local/lib/libfontconfig.dll.a +0 -0
  123. data/vendor/local/lib/libfreetype.a +0 -0
  124. data/vendor/local/lib/libfreetype.dll.a +0 -0
  125. data/vendor/local/lib/libfreetype.la +3 -3
  126. data/vendor/local/lib/libpixman-1.dll.a +0 -0
  127. data/vendor/local/lib/libpng.a +0 -0
  128. data/vendor/local/lib/libpng.dll.a +0 -0
  129. data/vendor/local/lib/libpng.la +2 -2
  130. data/vendor/local/lib/libpng16.a +0 -0
  131. data/vendor/local/lib/libpng16.dll.a +0 -0
  132. data/vendor/local/lib/libpng16.la +2 -2
  133. data/vendor/local/lib/libxml2.dll.a +0 -0
  134. data/vendor/local/lib/libz.dll.a +0 -0
  135. data/vendor/local/lib/pkgconfig/freetype2.pc +2 -2
  136. data/vendor/local/lib/pkgconfig/libpng.pc +1 -1
  137. data/vendor/local/lib/pkgconfig/libpng16.pc +1 -1
  138. data/vendor/local/share/aclocal/freetype2.m4 +1 -1
  139. data/vendor/local/share/license/freetype/README +9 -9
  140. data/vendor/local/share/license/freetype/README.git +1 -1
  141. data/vendor/local/share/license/libpng/README +2 -2
  142. data/vendor/local/share/man/man3/libpng.3 +50 -54
  143. data/vendor/local/share/man/man3/libpngpf.3 +8 -4
  144. metadata +9 -14
  145. data/vendor/local/bin/freetype-config +0 -211
  146. data/vendor/local/include/freetype2/freetype/ftautoh.h +0 -533
  147. data/vendor/local/include/freetype2/freetype/ftcffdrv.h +0 -321
  148. data/vendor/local/include/freetype2/freetype/ftpcfdrv.h +0 -105
  149. data/vendor/local/include/freetype2/freetype/ftttdrv.h +0 -328
  150. data/vendor/local/include/freetype2/freetype/ttunpat.h +0 -63
  151. data/vendor/local/share/man/man1/freetype-config.1 +0 -146
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 576a2b90551ac295a957ca6ac41a15ba6d221f169fce91e371b6b070a3391da3
4
- data.tar.gz: 02e0c8ff46322f9155ea8dd91ecc7d83358e07ec38ef44cff8de6ef6905c9833
3
+ metadata.gz: 349002686f2c39be90d746a2a5b38c651436cdd6b6417f528d5f47dfe3ecbeca
4
+ data.tar.gz: 3c7d7b1ff3f65a01c8b3aec7671f05766c7d79f101119212a53d92b2a583bdbd
5
5
  SHA512:
6
- metadata.gz: 00e9bc905e4168f1c1ae5a5deae28e94fc819fb7ea9d664c0f72fa895062fefd0335e5d010ed65c056840962c8c2b7f0b2d4ea1f8b8024e25af43c88f09cbd05
7
- data.tar.gz: 17425c93106d5faba1beabefc24aa76ccac4cb6e8f920b6e062cdcbade5c86ff7dade7e3b079bda5051b2fb9b1bbd7990008a1db2b35a8830dc441255fd82483
6
+ metadata.gz: da3c7bdefc4be2d9f2a2f169747f00d1b771de2d4144c1d3e8167a48f629fb6d954783a373ea0e1f5f53356b7736b070b0b74b1a6d921b219b89226cdae654e9
7
+ data.tar.gz: 1685efadc26ca1b91fa2e78f926ac9c0d129f5fd84dadb590e1956976b142da9ce3dc227181329044362249327b101c04f20a4aea98d71479a838a77fbeae43e
data/NEWS CHANGED
@@ -1,3 +1,27 @@
1
+ Release 1.15.14 (2018-08-20) Kouhei Sutou <kou@cozmixng.org>
2
+ ============================================================
3
+
4
+ Improvements
5
+ ------------
6
+
7
+ * Added Cairo::Surface.create {}. Cairo::Surface.new {} is deprecated.
8
+
9
+ * Added Cairo::Context.create {}. Cairo::Context.new {} is deprecated.
10
+
11
+ * Windows: Added support for installing a normal gem (not fat gem)
12
+ by "gem install --platform ruby". If you use Bundler, use "bundle
13
+ config --local force_ruby_platform true" and "bundle exec ruby -rdevkit".
14
+
15
+ * Changed to use SPDX license ID in gemspec.
16
+
17
+ Fixes
18
+ -----
19
+
20
+ * Fixed a bug that CRFONTOPTIOSN2RVAL() doesn't copy the target
21
+ options.
22
+ * Other CR*2RVAL() copy or refer the target objects. So
23
+ CRFONTOPTIONS2RVAL() must copy for consistency.
24
+
1
25
  Release 1.15.13 (2018-05-01) Kouhei Sutou <kou@cozmixng.org>
2
26
  ============================================================
3
27
 
@@ -8,12 +8,12 @@ rcairo
8
8
 
9
9
  Ruby bindings for cairo // cairo extension for Ruby
10
10
 
11
- http://cairographics.org/
11
+ https://cairographics.org/
12
12
 
13
13
  == Dependencies
14
14
 
15
- * ruby >= 1.9.3 (2.2 also supported!)
16
- * cairo >= 1.2.0 (1.12.0 also supported!)
15
+ * ruby >= 2.2.1
16
+ * cairo >= 1.2.0
17
17
 
18
18
  == Install
19
19
 
@@ -27,56 +27,27 @@ This way is recommended.
27
27
 
28
28
  For experimental users.
29
29
 
30
- Download rcairo-X.Y.Z.tar.gz from http://cairographics.org/releases/
30
+ Add the following to your Gemfile:
31
31
 
32
- Extracting:
33
- % tar xvzf rcairo-X.Y.Z.tar.gz
32
+ gem "cairo", github: "rcairo/rcairo"
34
33
 
35
- Compiling:
36
- % cd rcairo-X.Y.Z
37
- % ruby extconf.rb # to check for dependencies and create Makefiles
38
- % make # to compile
34
+ Then run the following command:
39
35
 
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.
46
-
47
- Options to extconf.rb:
48
-
49
- * --without-vendor-override: Use system libraries instead of those found in
50
- vendor/local for compiling
51
-
52
- == Windows
53
-
54
- cairo-X.Y.Z-x86-mingw32.gem includes cairo related binaries.
55
-
56
- * cairo related binaries:
57
- http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/
58
-
59
- * cairo-X.Y.Z-a_win32.zip
60
- * cairo-dev-X.Y.Z-a_win32.zip
61
- * libpng-X.Y.Z-a_win32.zip
62
- * zlib-X.Y.Z-a_win32.zip
63
- * expat_X.Y.Z-a_win32.zip
64
- * fontconfig_X.Y.Z-a_win32.zip
65
- * freetype_X.Y.Z-a_win32.zip
36
+ % bundle install
66
37
 
67
38
  == Documents
68
39
 
69
40
  * Reference manual:
70
- http://rcairo.github.io/doc/
41
+ https://rcairo.github.io/doc/
71
42
  * Repository of the reference manual:
72
- http://github.com/rcairo/doc
43
+ https://github.com/rcairo/doc
73
44
  * An article for rcairo on Rubyst Magazine a.k.a. RubiMa (in Japanese):
74
- http://jp.rubyist.net/magazine/?0019-cairo
45
+ https://magazine.rubyist.net/articles/0019/0019-cairo.html
75
46
 
76
47
  == Source
77
48
 
78
49
  There is the rcairo repository at GitHub:
79
- http://github.com/rcairo/rcairo
50
+ https://github.com/rcairo/rcairo
80
51
 
81
52
  == Mailing list
82
53
 
data/Rakefile CHANGED
@@ -54,6 +54,8 @@ Rake::ExtensionTask.new("cairo", spec) do |ext|
54
54
  ext.cross_compile = true
55
55
  ext.cross_compiling do |_spec|
56
56
  if /mingw|mswin/ =~ _spec.platform.to_s
57
+ _spec.metadata.delete("msys2_mingw_dependencies")
58
+
57
59
  binary_files = []
58
60
  Find.find(binary_dir) do |name|
59
61
  next unless File.file?(name)
@@ -440,8 +442,8 @@ end
440
442
 
441
443
  windows_task = WindowsTask.new(spec) do |task|
442
444
  zlib_version = "1.2.11"
443
- libpng_version = "1.6.34"
444
- freetype_version = "2.8.1"
445
+ libpng_version = "1.6.35"
446
+ freetype_version = "2.9.1"
445
447
  task.packages = [
446
448
  {
447
449
  # We should use the same version as Ruby Installer.
@@ -73,7 +73,7 @@ RB_CAIRO_BEGIN_DECLS
73
73
 
74
74
  #define RB_CAIRO_VERSION_MAJOR 1
75
75
  #define RB_CAIRO_VERSION_MINOR 15
76
- #define RB_CAIRO_VERSION_MICRO 13
76
+ #define RB_CAIRO_VERSION_MICRO 14
77
77
 
78
78
  RB_CAIRO_VAR VALUE rb_mCairo;
79
79
  RB_CAIRO_VAR VALUE rb_cCairo_Context;
@@ -5,7 +5,7 @@
5
5
  * $Author: kou $
6
6
  * $Date: 2008-09-26 13:52:08 $
7
7
  *
8
- * Copyright 2005-2016 Kouhei Sutou <kou@cozmixng.org>
8
+ * Copyright 2005-2018 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
  *
@@ -25,6 +25,7 @@
25
25
 
26
26
  VALUE rb_cCairo_Context;
27
27
 
28
+ static ID cr_id_new;
28
29
  static ID cr_id_surface, cr_id_source;
29
30
  static ID cr_id_plus, cr_id_minus, cr_id_multi, cr_id_div;
30
31
  static cairo_user_data_key_t cr_object_holder_key;
@@ -141,6 +142,22 @@ cr_get_reference_count (VALUE self)
141
142
  return UINT2NUM (reference_count);
142
143
  }
143
144
 
145
+ static VALUE
146
+ cr_s_create (int argc, VALUE *argv, VALUE klass)
147
+ {
148
+ VALUE rb_cr;
149
+ rb_cr = rb_funcallv (klass, cr_id_new, argc, argv);
150
+ if (rb_block_given_p ())
151
+ {
152
+ return rb_ensure (rb_yield, rb_cr,
153
+ cr_destroy_with_destroy_check, rb_cr);
154
+ }
155
+ else
156
+ {
157
+ return rb_cr;
158
+ }
159
+ }
160
+
144
161
  static VALUE
145
162
  cr_s_wrap (VALUE self, VALUE pointer)
146
163
  {
@@ -1230,11 +1247,22 @@ cr_set_font_options (VALUE self, VALUE options)
1230
1247
  static VALUE
1231
1248
  cr_get_font_options (VALUE self)
1232
1249
  {
1233
- cairo_font_options_t *options = cairo_font_options_create ();
1250
+ cairo_font_options_t *options;
1251
+ VALUE rb_options;
1252
+
1253
+ options = cairo_font_options_create ();
1234
1254
  rb_cairo_check_status (cairo_font_options_status (options));
1255
+
1256
+ /* TODO: Use rb_ensure() */
1257
+ rb_options = CRFONTOPTIONS2RVAL (options);
1258
+ cairo_font_options_destroy (options);
1259
+
1260
+ options = RVAL2CRFONTOPTIONS (rb_options);
1235
1261
  cairo_get_font_options (_SELF, options);
1262
+ cr_check_status (_SELF);
1236
1263
  rb_cairo_check_status (cairo_font_options_status (options));
1237
- return CRFONTOPTIONS2RVAL (options);
1264
+
1265
+ return rb_options;
1238
1266
  }
1239
1267
 
1240
1268
  static VALUE
@@ -1663,6 +1691,8 @@ cr_destroy_all_guarded_contexts_at_end (VALUE data)
1663
1691
  void
1664
1692
  Init_cairo_context (void)
1665
1693
  {
1694
+ cr_id_new = rb_intern ("new");
1695
+
1666
1696
  cr_id_surface = rb_intern ("surface");
1667
1697
  cr_id_source = rb_intern ("source");
1668
1698
 
@@ -1679,6 +1709,8 @@ Init_cairo_context (void)
1679
1709
  rb_cairo__initialize_gc_guard_holder_class (rb_cCairo_Context);
1680
1710
  rb_set_end_proc(cr_destroy_all_guarded_contexts_at_end, Qnil);
1681
1711
 
1712
+ rb_define_singleton_method (rb_cCairo_Context, "create", cr_s_create, -1);
1713
+
1682
1714
  /* For integrate other libraries such as a FFI based library. */
1683
1715
  rb_define_singleton_method (rb_cCairo_Context, "wrap", cr_s_wrap, 1);
1684
1716
 
@@ -50,8 +50,11 @@ rb_cairo_font_options_to_ruby_object (cairo_font_options_t *options)
50
50
  {
51
51
  if (options)
52
52
  {
53
+ cairo_font_options_t *copied_options;
54
+ copied_options = cairo_font_options_copy (options);
55
+ cr_options_check_status (copied_options);
53
56
  return Data_Wrap_Struct (rb_cCairo_FontOptions, NULL,
54
- cr_options_free, options);
57
+ cr_options_free, copied_options);
55
58
  }
56
59
  else
57
60
  {
@@ -79,11 +82,7 @@ cr_options_create (VALUE self)
79
82
  static VALUE
80
83
  cr_options_copy (VALUE self)
81
84
  {
82
- cairo_font_options_t *options;
83
-
84
- options = cairo_font_options_copy (_SELF (self));
85
- cr_options_check_status (options);
86
- return CRFONTOPTIONS2RVAL (options);
85
+ return CRFONTOPTIONS2RVAL (_SELF (self));
87
86
  }
88
87
 
89
88
  static VALUE
@@ -5,7 +5,7 @@
5
5
  * $Author: kou $
6
6
  * $Date: 2008-08-17 07:21:42 $
7
7
  *
8
- * Copyright 2005-2014 Kouhei Sutou <kou@cozmixng.org>
8
+ * Copyright 2005-2018 Kouhei Sutou <kou@cozmixng.org>
9
9
  *
10
10
  * This file is made available under the same terms as Ruby
11
11
  *
@@ -126,6 +126,6 @@ VALUE rb_cairo__invoke_callback (cr_callback_func_t func, VALUE user_data);
126
126
 
127
127
  extern VALUE rb_cairo__cFFIPointer;
128
128
 
129
- void rb_cairo__surface_yield_and_finish (VALUE self);
129
+ VALUE rb_cairo__surface_yield_and_finish (VALUE self);
130
130
 
131
131
  #endif
@@ -181,12 +181,21 @@ static VALUE
181
181
  cr_scaled_font_get_font_options (VALUE self)
182
182
  {
183
183
  cairo_font_options_t *options;
184
+ VALUE rb_options;
184
185
 
185
- options = cairo_font_options_create();
186
+ options = cairo_font_options_create ();
187
+ rb_cairo_check_status (cairo_font_options_status (options));
188
+
189
+ /* TODO: Use rb_ensure() */
190
+ rb_options = CRFONTOPTIONS2RVAL (options);
191
+ cairo_font_options_destroy (options);
192
+
193
+ options = RVAL2CRFONTOPTIONS (rb_options);
186
194
  cairo_scaled_font_get_font_options (_SELF (self), options);
187
195
  cr_scaled_font_check_status (_SELF (self));
188
196
  rb_cairo_check_status (cairo_font_options_status (options));
189
- return CRFONTOPTIONS2RVAL (options);
197
+
198
+ return rb_options;
190
199
  }
191
200
 
192
201
  #if CAIRO_CHECK_VERSION(1, 7, 2)
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  * Ruby Cairo Binding
4
4
  *
5
- * Copyright 2005-2017 Kouhei Sutou <kou@cozmixng.org>
5
+ * Copyright 2005-2018 Kouhei Sutou <kou@cozmixng.org>
6
6
  * Copyright 2014 Patrick Hanevold <patrick.hanevold@gmail.com>
7
7
  * Copyright 2005 Øyvind Kolås <pippin@freedesktop.org>
8
8
  * Copyright 2004-2005 MenTaLguY <mental@rydia.com>
@@ -90,6 +90,7 @@ VALUE rb_cCairo_SkiaSurface = Qnil;
90
90
  VALUE rb_cCairo_SubSurface = Qnil;
91
91
  VALUE rb_cCairo_CoglSurface = Qnil;
92
92
 
93
+ static ID cr_id_new;
93
94
  static ID cr_id_parse;
94
95
  static ID cr_id_size;
95
96
  static ID cr_id_set_unit;
@@ -217,6 +218,67 @@ cr_surface_get_klass (cairo_surface_t *surface)
217
218
  return klass;
218
219
  }
219
220
 
221
+ static void
222
+ rb_cairo_surface_adjust_memory_usage (cairo_surface_t *surface,
223
+ cairo_bool_t new)
224
+ {
225
+ #ifdef HAVE_RB_GC_ADJUST_MEMORY_USAGE
226
+ if (cairo_surface_get_type (surface) == CAIRO_SURFACE_TYPE_IMAGE)
227
+ {
228
+ ssize_t memory_usage_diff;
229
+ memory_usage_diff =
230
+ cairo_image_surface_get_stride (surface) *
231
+ cairo_image_surface_get_height (surface);
232
+ if (!new)
233
+ memory_usage_diff = -memory_usage_diff;
234
+ rb_gc_adjust_memory_usage (memory_usage_diff);
235
+ }
236
+ #endif
237
+ }
238
+
239
+ static void
240
+ cr_surface_destroy_raw (cairo_surface_t *surface)
241
+ {
242
+ rb_cairo_surface_adjust_memory_usage (surface, CR_FALSE);
243
+ cairo_surface_destroy (surface);
244
+ }
245
+
246
+ static VALUE
247
+ cr_surface_destroy (VALUE self)
248
+ {
249
+ cairo_surface_t *surface;
250
+
251
+ surface = _SELF;
252
+ cr_surface_destroy_raw (surface);
253
+ DATA_PTR (self) = NULL;
254
+
255
+ return self;
256
+ }
257
+
258
+ static VALUE
259
+ cr_surface_destroy_with_destroy_check (VALUE self)
260
+ {
261
+ if (_SELF)
262
+ cr_surface_destroy (self);
263
+ return Qnil;
264
+ }
265
+
266
+ static VALUE
267
+ cr_surface_create (int argc, VALUE *argv, VALUE klass)
268
+ {
269
+ VALUE rb_surface;
270
+ rb_surface = rb_funcallv (klass, cr_id_new, argc, argv);
271
+ if (rb_block_given_p ())
272
+ {
273
+ return rb_ensure (rb_cairo__surface_yield_and_finish, rb_surface,
274
+ cr_surface_destroy_with_destroy_check, rb_surface);
275
+ }
276
+ else
277
+ {
278
+ return rb_surface;
279
+ }
280
+ }
281
+
220
282
  static VALUE
221
283
  cr_surface_image_supported_p (VALUE klass)
222
284
  {
@@ -349,24 +411,6 @@ cr_surface_xml_supported_p (VALUE klass)
349
411
  #endif
350
412
  }
351
413
 
352
- static void
353
- rb_cairo_surface_adjust_memory_usage (cairo_surface_t *surface,
354
- cairo_bool_t new)
355
- {
356
- #ifdef HAVE_RB_GC_ADJUST_MEMORY_USAGE
357
- if (cairo_surface_get_type (surface) == CAIRO_SURFACE_TYPE_IMAGE)
358
- {
359
- ssize_t memory_usage_diff;
360
- memory_usage_diff =
361
- cairo_image_surface_get_stride (surface) *
362
- cairo_image_surface_get_height (surface);
363
- if (!new)
364
- memory_usage_diff = -memory_usage_diff;
365
- rb_gc_adjust_memory_usage (memory_usage_diff);
366
- }
367
- #endif
368
- }
369
-
370
414
  /* constructor/de-constructor */
371
415
  cairo_surface_t *
372
416
  rb_cairo_surface_from_ruby_object (VALUE obj)
@@ -402,9 +446,7 @@ cr_surface_free (void *ptr)
402
446
  if (!surface)
403
447
  return;
404
448
 
405
- rb_cairo_surface_adjust_memory_usage (surface, CR_FALSE);
406
-
407
- cairo_surface_destroy (surface);
449
+ cr_surface_destroy_raw (surface);
408
450
  }
409
451
 
410
452
  VALUE
@@ -453,18 +495,6 @@ cr_surface_initialize (int argc, VALUE *argv, VALUE self)
453
495
  }
454
496
 
455
497
  /* Surface manipulation */
456
- static VALUE
457
- cr_surface_destroy (VALUE self)
458
- {
459
- cairo_surface_t *surface;
460
-
461
- surface = _SELF;
462
- cairo_surface_destroy (surface);
463
- DATA_PTR (self) = NULL;
464
-
465
- return self;
466
- }
467
-
468
498
  static VALUE
469
499
  cr_surface_get_reference_count (VALUE self)
470
500
  {
@@ -497,20 +527,25 @@ cr_surface_finish (VALUE self)
497
527
  return self;
498
528
  }
499
529
 
500
- void
530
+ VALUE
501
531
  rb_cairo__surface_yield_and_finish (VALUE self)
502
532
  {
533
+ VALUE rb_result;
503
534
  cairo_surface_t *surface;
504
535
 
505
- rb_yield (self);
536
+ rb_result = rb_yield (self);
506
537
 
507
538
  surface = _SELF;
539
+ if (!surface)
540
+ return rb_result;
508
541
  if (cairo_surface_status (surface) != CAIRO_STATUS_SUCCESS)
509
- return;
542
+ return rb_result;
510
543
  if (cairo_surface_get_user_data (surface, &cr_finished_key))
511
- return;
544
+ return rb_result;
512
545
 
513
546
  cr_surface_finish (self);
547
+
548
+ return rb_result;
514
549
  }
515
550
 
516
551
  static VALUE
@@ -632,14 +667,6 @@ cr_surface_unmap_image (VALUE self, VALUE rb_mapped_image)
632
667
  #endif
633
668
 
634
669
  #if CAIRO_CHECK_VERSION(1, 10, 0)
635
- static VALUE
636
- cr_surface_destroy_with_destroy_check (VALUE self)
637
- {
638
- if (DATA_PTR (self))
639
- cr_surface_destroy (self);
640
- return Qnil;
641
- }
642
-
643
670
  static VALUE
644
671
  cr_surface_create_sub_rectangle_surface (VALUE self, VALUE x, VALUE y,
645
672
  VALUE width, VALUE height)
@@ -782,11 +809,22 @@ cr_surface_supported_mime_type_p (VALUE self, VALUE rb_mime_type)
782
809
  static VALUE
783
810
  cr_surface_get_font_options (VALUE self)
784
811
  {
785
- cairo_font_options_t *options = cairo_font_options_create();
812
+ cairo_font_options_t *options;
813
+ VALUE rb_options;
814
+
815
+ options = cairo_font_options_create ();
816
+ rb_cairo_check_status (cairo_font_options_status (options));
817
+
818
+ /* TODO: Use rb_ensure() */
819
+ rb_options = CRFONTOPTIONS2RVAL (options);
820
+ cairo_font_options_destroy (options);
821
+
822
+ options = RVAL2CRFONTOPTIONS (rb_options);
786
823
  cairo_surface_get_font_options (_SELF, options);
787
824
  rb_cairo_surface_check_status (_SELF);
788
825
  rb_cairo_check_status (cairo_font_options_status (options));
789
- return CRFONTOPTIONS2RVAL (options);
826
+
827
+ return rb_options;
790
828
  }
791
829
 
792
830
  static VALUE
@@ -1967,6 +2005,7 @@ cr_finish_all_guarded_surfaces_at_end (VALUE data)
1967
2005
  void
1968
2006
  Init_cairo_surface (void)
1969
2007
  {
2008
+ cr_id_new = rb_intern ("new");
1970
2009
  cr_id_parse = rb_intern ("parse");
1971
2010
  cr_id_size = rb_intern ("size");
1972
2011
  cr_id_set_unit = rb_intern ("unit=");
@@ -1982,6 +2021,8 @@ Init_cairo_surface (void)
1982
2021
  rb_cairo__initialize_gc_guard_holder_class (rb_cCairo_Surface);
1983
2022
  rb_set_end_proc(cr_finish_all_guarded_surfaces_at_end, Qnil);
1984
2023
 
2024
+ rb_define_singleton_method (rb_cCairo_Surface, "create",
2025
+ cr_surface_create, -1);
1985
2026
  rb_define_singleton_method (rb_cCairo_Surface, "image_supported?",
1986
2027
  cr_surface_image_supported_p, 0);
1987
2028
  rb_define_singleton_method (rb_cCairo_Surface, "pdf_supported?",