cairo 1.17.7 → 1.17.9

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f5ac730747ea5dada591e534a7c0653a0d1ad3fa3962dfdd01173e0074ff835c
4
- data.tar.gz: 2fbccb304f8b4dbd3a89df42c9f1779b45a84b2f4c9be5ab591992eb9d7c3d31
3
+ metadata.gz: 05f4568d5884a55b9ec5f2490536c75737a5513ee52db87d6a1847bccb233499
4
+ data.tar.gz: cf202c94b822be61b2d77fcbdf49a566022038ac23447a3f4cd8780cd5fe4de3
5
5
  SHA512:
6
- metadata.gz: 389eeca0e8c453e3c1b2ebe10053a1713c1c1ae93b22e46100b5bc1c39d566f00f60a1c676ae288e06fa9fdea6f24db8e107d53355bd52bc0e067e5b8b4fe073
7
- data.tar.gz: d107b587d530433a0288f73a5b8d85710e2923213347f88e09de92562645dbcd9e501f8f9ab1bd74bb9ae13559ee94999e94c7555cd96a345b9d1d75965b961c
6
+ metadata.gz: 569e8766de9065d5887b3de6bfe01b23fdf97f9865b392e85312a7e9e2015a7f0dfccef6ab91dccdc1cc91b48534437c3d61b927b4d799098975b0bc6fdcaa70
7
+ data.tar.gz: dcc158f18e380017c86d15dc94c66c0d45beb1463937f10366daf017913c1dbdcba82972efd1a76ac981ffc001328103364011816adf5c1e52cc0f8675531bdb
data/NEWS CHANGED
@@ -1,3 +1,62 @@
1
+ Release 1.17.9 (2023-06-14) Sutou Kouhei <kou@cozmixng.org>
2
+ ===========================================================
3
+
4
+ Improvements
5
+ ------------
6
+
7
+ * Dropped support for fat gem.
8
+ [GH-78][https://github.com/rcairo/rcairo/issues/78]
9
+ [Reported by Largo]
10
+
11
+ * Added support for auto native package installation with conda.
12
+
13
+ * Added support for cairo 1.17.8:
14
+
15
+ * Added Cairo::SVGFontError.
16
+
17
+ * Added Cairo::ColorMode.
18
+
19
+ * Added Cairo::FontOptions#color_mode.
20
+
21
+ * Added Cairo::FontOptions#color_mode=.
22
+
23
+ * Added Cairo::ColorPalette.
24
+
25
+ * Added Cairo::FontOptions#color_palette.
26
+
27
+ * Added Cairo::FontOptions#color_palette=.
28
+
29
+ * Added Cairo::FontOptions#set_custom_palette_color.
30
+
31
+ Fixes
32
+ -----
33
+
34
+ * Fixed the number of arguments of Cairo::GLSurface#initialize and
35
+ Cairo::GLTextureSurface#initialize.
36
+ [GH-79][https://github.com/rcairo/rcairo/issues/79]
37
+ [Patch by Dimitry Andric]
38
+
39
+ Thanks
40
+ ------
41
+
42
+ * Largo
43
+
44
+ * Dimitry Andric
45
+
46
+ Release 1.17.8 (2022-09-01) Sutou Kouhei <kou@cozmixng.org>
47
+ ===========================================================
48
+
49
+ Improvements
50
+ ------------
51
+
52
+ * Added support for Pathname for Cairo::Surface#write_to_png.
53
+ [GitHub#37][Reported by scivola]
54
+
55
+ Thanks
56
+ ------
57
+
58
+ * scivola
59
+
1
60
  Release 1.17.7 (2022-07-31) Sutou Kouhei <kou@cozmixng.org>
2
61
  ===========================================================
3
62
 
data/ext/cairo/extconf.rb CHANGED
@@ -49,6 +49,7 @@ end
49
49
 
50
50
  unless required_pkg_config_package([package, major, minor, micro],
51
51
  :arch_linux => "cairo",
52
+ :conda => "cairo",
52
53
  :debian => "libcairo2-dev",
53
54
  :homebrew => "cairo",
54
55
  :macports => "cairo",
data/ext/cairo/rb_cairo.h CHANGED
@@ -5,7 +5,7 @@
5
5
  * $Author: kou $
6
6
  * $Date: 2008-09-19 12:56:27 $
7
7
  *
8
- * Copyright 2006-2021 Sutou Kouhei <kou@cozmixng.org>
8
+ * Copyright 2006-2022 Sutou Kouhei <kou@cozmixng.org>
9
9
  * Copyright 2005 Øyvind Kolås <pippin@freedesktop.org>
10
10
  * Copyright 2004-2005 MenTaLguY <mental@rydia.com>
11
11
  *
@@ -65,7 +65,7 @@ RB_CAIRO_BEGIN_DECLS
65
65
 
66
66
  #define RB_CAIRO_VERSION_MAJOR 1
67
67
  #define RB_CAIRO_VERSION_MINOR 17
68
- #define RB_CAIRO_VERSION_MICRO 7
68
+ #define RB_CAIRO_VERSION_MICRO 9
69
69
 
70
70
  RB_CAIRO_VAR VALUE rb_mCairo;
71
71
  RB_CAIRO_VAR VALUE rb_cCairo_Context;
@@ -136,6 +136,8 @@ RB_CAIRO_VAR VALUE rb_mCairo_FontWeight;
136
136
  RB_CAIRO_VAR VALUE rb_mCairo_SubpixelOrder;
137
137
  RB_CAIRO_VAR VALUE rb_mCairo_HintStyle;
138
138
  RB_CAIRO_VAR VALUE rb_mCairo_HintMetrics;
139
+ RB_CAIRO_VAR VALUE rb_mCairo_ColorMode;
140
+ RB_CAIRO_VAR VALUE rb_mCairo_ColorPalette;
139
141
  RB_CAIRO_VAR VALUE rb_mCairo_FontType;
140
142
  RB_CAIRO_VAR VALUE rb_mCairo_PathDataType;
141
143
  RB_CAIRO_VAR VALUE rb_mCairo_Content;
@@ -266,6 +268,9 @@ VALUE rb_cairo_device_to_ruby_object (cairo_device_t *de
266
268
  #define RVAL2CRSUBPIXELORDER(obj) (rb_cairo_subpixel_order_from_ruby_object(obj))
267
269
  #define RVAL2CRHINTSTYLE(obj) (rb_cairo_hint_style_from_ruby_object(obj))
268
270
  #define RVAL2CRHINTMETRICS(obj) (rb_cairo_hint_metrics_from_ruby_object(obj))
271
+ #if CAIRO_CHECK_VERSION(1, 17, 8)
272
+ #define RVAL2CRCOLORMODE(obj) (rb_cairo_color_mode_from_ruby_object(obj))
273
+ #endif
269
274
  #define RVAL2CRPATHDATATYPE(obj) (rb_cairo_path_data_type_from_ruby_object(obj))
270
275
  #define RVAL2CRCONTENT(obj) (rb_cairo_content_from_ruby_object(obj))
271
276
  #define RVAL2CRFORMAT(obj) (rb_cairo_format_from_ruby_object(obj))
@@ -311,6 +316,9 @@ cairo_font_weight_t rb_cairo_font_weight_from_ruby_object (VALUE obj);
311
316
  cairo_subpixel_order_t rb_cairo_subpixel_order_from_ruby_object (VALUE obj);
312
317
  cairo_hint_style_t rb_cairo_hint_style_from_ruby_object (VALUE obj);
313
318
  cairo_hint_metrics_t rb_cairo_hint_metrics_from_ruby_object (VALUE obj);
319
+ #if CAIRO_CHECK_VERSION(1, 17, 8)
320
+ cairo_color_mode_t rb_cairo_color_mode_from_ruby_object (VALUE obj);
321
+ #endif
314
322
  cairo_path_data_type_t rb_cairo_path_data_type_from_ruby_object (VALUE obj);
315
323
  cairo_content_t rb_cairo_content_from_ruby_object (VALUE obj);
316
324
  cairo_format_t rb_cairo_format_from_ruby_object (VALUE obj);
@@ -5,7 +5,7 @@
5
5
  * $Author: kou $
6
6
  * $Date: 2008-09-19 12:56:27 $
7
7
  *
8
- * Copyright 2005-2022 Sutou Kouhei <kou@cozmixng.org>
8
+ * Copyright 2005-2023 Sutou Kouhei <kou@cozmixng.org>
9
9
  * Copyright 2005 Øyvind Kolås <pippin@freedesktop.org>
10
10
  * Copyright 2004-2005 MenTaLguY <mental@rydia.com>
11
11
  *
@@ -27,6 +27,8 @@ VALUE rb_mCairo_FontWeight;
27
27
  VALUE rb_mCairo_SubpixelOrder;
28
28
  VALUE rb_mCairo_HintStyle;
29
29
  VALUE rb_mCairo_HintMetrics;
30
+ VALUE rb_mCairo_ColorMode;
31
+ VALUE rb_mCairo_ColorPalette;
30
32
  VALUE rb_mCairo_PathDataType;
31
33
  VALUE rb_mCairo_Content;
32
34
  VALUE rb_mCairo_Format;
@@ -81,6 +83,9 @@ VALUE rb_mCairo_SVGUnit = Qnil;
81
83
  #define CAIRO_HINT_METRICS_MIN CAIRO_HINT_METRICS_DEFAULT
82
84
  #define CAIRO_HINT_METRICS_MAX CAIRO_HINT_METRICS_ON
83
85
 
86
+ #define CAIRO_COLOR_MODE_MIN CAIRO_COLOR_MODE_DEFAULT
87
+ #define CAIRO_COLOR_MODE_MAX CAIRO_COLOR_MODE_COLOR
88
+
84
89
  #define CAIRO_PATH_MIN CAIRO_PATH_MOVE_TO
85
90
  #define CAIRO_PATH_MAX CAIRO_PATH_CLOSE_PATH
86
91
 
@@ -182,6 +187,9 @@ DEFINE_RVAL2ENUM(font_weight, FONT_WEIGHT)
182
187
  DEFINE_RVAL2ENUM(subpixel_order, SUBPIXEL_ORDER)
183
188
  DEFINE_RVAL2ENUM(hint_style, HINT_STYLE)
184
189
  DEFINE_RVAL2ENUM(hint_metrics, HINT_METRICS)
190
+ #if CAIRO_CHECK_VERSION(1, 17, 8)
191
+ DEFINE_RVAL2ENUM(color_mode, COLOR_MODE)
192
+ #endif
185
193
  DEFINE_RVAL2ENUM(path_data_type, PATH)
186
194
  DEFINE_RVAL2ENUM(content, CONTENT)
187
195
  DEFINE_RVAL2ENUM(format, FORMAT)
@@ -529,6 +537,20 @@ Init_cairo_constants (void)
529
537
  rb_define_const (rb_mCairo_HintMetrics, "OFF",
530
538
  INT2FIX (CAIRO_HINT_METRICS_OFF));
531
539
 
540
+ #if CAIRO_CHECK_VERSION(1, 17, 8)
541
+ /* cairo_color_mode_t */
542
+ rb_mCairo_ColorMode = rb_define_module_under (rb_mCairo, "ColorMode");
543
+ rb_define_const (rb_mCairo_ColorMode, "DEFAULT",
544
+ INT2FIX (CAIRO_COLOR_MODE_DEFAULT));
545
+ rb_define_const (rb_mCairo_ColorMode, "NO_COLOR",
546
+ INT2FIX (CAIRO_COLOR_MODE_NO_COLOR));
547
+ rb_define_const (rb_mCairo_ColorMode, "COLOR",
548
+ INT2FIX (CAIRO_COLOR_MODE_COLOR));
549
+
550
+ rb_mCairo_ColorPalette = rb_define_module_under (rb_mCairo, "ColorPalette");
551
+ rb_define_const (rb_mCairo_ColorPalette, "DEFAULT",
552
+ INT2FIX (CAIRO_COLOR_PALETTE_DEFAULT));
553
+ #endif
532
554
 
533
555
  /* cairo_path_data_type_t */
534
556
  rb_mCairo_PathDataType = rb_define_module_under (rb_mCairo, "PathDataType");
@@ -126,20 +126,20 @@ cr_destroy (VALUE self)
126
126
  cr_set_user_data (cr, &cr_object_holder_key, NULL, NULL);
127
127
  cairo_destroy (cr);
128
128
 
129
- DATA_PTR (self) = NULL;
129
+ RTYPEDDATA_DATA (self) = NULL;
130
130
  return Qnil;
131
131
  }
132
132
 
133
133
  static VALUE
134
134
  cr_destroyed (VALUE self)
135
135
  {
136
- return CBOOL2RVAL (DATA_PTR (self) == NULL);
136
+ return CBOOL2RVAL (RTYPEDDATA_DATA (self) == NULL);
137
137
  }
138
138
 
139
139
  static VALUE
140
140
  cr_destroy_with_destroy_check (VALUE self)
141
141
  {
142
- if (DATA_PTR (self))
142
+ if (RTYPEDDATA_DATA (self))
143
143
  cr_destroy (self);
144
144
  return Qnil;
145
145
  }
@@ -202,7 +202,7 @@ cr_s_wrap (VALUE self, VALUE pointer)
202
202
 
203
203
  rb_cr = rb_obj_alloc (self);
204
204
  cairo_reference (cr);
205
- DATA_PTR (rb_cr) = cr;
205
+ RTYPEDDATA_DATA (rb_cr) = cr;
206
206
  rb_ivar_set (rb_cr, cr_id_surface, Qnil);
207
207
 
208
208
  if (rb_block_given_p ())
@@ -232,7 +232,7 @@ cr_initialize (VALUE self, VALUE target)
232
232
  &cr_object_holder_key,
233
233
  cr_object_holder_new (self),
234
234
  cr_object_holder_free);
235
- DATA_PTR (self) = cr;
235
+ RTYPEDDATA_DATA (self) = cr;
236
236
  if (rb_block_given_p ())
237
237
  result = rb_ensure (rb_yield, self, cr_destroy_with_destroy_check, self);
238
238
  return result;
@@ -215,7 +215,7 @@ cr_device_destroy (VALUE self)
215
215
 
216
216
  device = _SELF;
217
217
  cairo_device_destroy (device);
218
- DATA_PTR (self) = NULL;
218
+ RTYPEDDATA_DATA (self) = NULL;
219
219
 
220
220
  return self;
221
221
  }
@@ -335,7 +335,7 @@ cr_ ## type ## _device_initialize (VALUE self, \
335
335
  } \
336
336
  \
337
337
  cr_device_check_status (device); \
338
- DATA_PTR (self) = device; \
338
+ RTYPEDDATA_DATA (self) = device; \
339
339
  if (rb_block_given_p ()) \
340
340
  yield_and_finish (self); \
341
341
  return Qnil; \
@@ -5,7 +5,7 @@
5
5
  * $Author: kou $
6
6
  * $Date: 2008-08-16 12:52:16 $
7
7
  *
8
- * Copyright 2010-2022 Sutou Kouhei <kou@cozmixng.org>
8
+ * Copyright 2010-2023 Sutou Kouhei <kou@cozmixng.org>
9
9
  * Copyright 2005 Øyvind Kolås <pippin@freedesktop.org>
10
10
  * Copyright 2004-2005 MenTaLguY <mental@rydia.com>
11
11
  *
@@ -74,6 +74,9 @@ static VALUE rb_eCairo_TagError;
74
74
  #if CAIRO_CHECK_VERSION(1, 17, 6)
75
75
  static VALUE rb_eCairo_DirectWriteError;
76
76
  #endif
77
+ #if CAIRO_CHECK_VERSION(1, 17, 8)
78
+ static VALUE rb_eCairo_SVGFontError;
79
+ #endif
77
80
 
78
81
  void
79
82
  rb_cairo_check_status (cairo_status_t status)
@@ -229,6 +232,11 @@ rb_cairo_check_status (cairo_status_t status)
229
232
  rb_raise (rb_eCairo_DirectWriteError, "%s", string);
230
233
  break;
231
234
  #endif
235
+ #if CAIRO_CHECK_VERSION(1, 17, 8)
236
+ case CAIRO_STATUS_SVG_FONT_ERROR:
237
+ rb_raise (rb_eCairo_SVGFontError, "%s", string);
238
+ break;
239
+ #endif
232
240
  #if CAIRO_CHECK_VERSION(1, 10, 0)
233
241
  case CAIRO_STATUS_LAST_STATUS:
234
242
  #else
@@ -340,6 +348,10 @@ rb_cairo__exception_to_status (VALUE exception)
340
348
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_DirectWriteError))
341
349
  return CAIRO_STATUS_DWRITE_ERROR;
342
350
  #endif
351
+ #if CAIRO_CHECK_VERSION(1, 17, 8)
352
+ else if (rb_cairo__is_kind_of (exception, rb_eCairo_SVGFontError))
353
+ return CAIRO_STATUS_SVG_FONT_ERROR;
354
+ #endif
343
355
 
344
356
  return -1;
345
357
  }
@@ -506,4 +518,10 @@ Init_cairo_exception (void)
506
518
  rb_define_class_under (rb_mCairo, "DirectWriteError",
507
519
  rb_eCairo_Error);
508
520
  #endif
521
+
522
+ #if CAIRO_CHECK_VERSION(1, 17, 8)
523
+ rb_eCairo_SVGFontError =
524
+ rb_define_class_under (rb_mCairo, "SVGFontError",
525
+ rb_eCairo_Error);
526
+ #endif
509
527
  }
@@ -81,7 +81,7 @@ cr_font_extents_initialize (VALUE self)
81
81
  extents->max_x_advance = 1.0;
82
82
  extents->max_y_advance = 0.0;
83
83
 
84
- DATA_PTR (self) = extents;
84
+ RTYPEDDATA_DATA (self) = extents;
85
85
 
86
86
  return Qnil;
87
87
  }
@@ -283,7 +283,7 @@ cr_freetype_font_face_initialize (VALUE self, VALUE path)
283
283
  rb_cairo_check_status (status);
284
284
  }
285
285
 
286
- DATA_PTR (self) = face;
286
+ RTYPEDDATA_DATA (self) = face;
287
287
 
288
288
  return Qnil;
289
289
  }
@@ -332,7 +332,7 @@ cr_toy_font_face_initialize (int argc, VALUE *argv, VALUE self)
332
332
 
333
333
  face = cairo_toy_font_face_create (family, slant, weight);
334
334
  cr_font_face_check_status (face);
335
- DATA_PTR (self) = face;
335
+ RTYPEDDATA_DATA (self) = face;
336
336
 
337
337
  return Qnil;
338
338
  }
@@ -758,7 +758,7 @@ cr_user_font_face_initialize (VALUE self)
758
758
  rb_ivar_set (self, cr_id_text_to_glyphs, Qnil);
759
759
  rb_ivar_set (self, cr_id_unicode_to_glyph, Qnil);
760
760
 
761
- DATA_PTR (self) = face;
761
+ RTYPEDDATA_DATA (self) = face;
762
762
 
763
763
  return Qnil;
764
764
  }
@@ -5,7 +5,7 @@
5
5
  * $Author: kou $
6
6
  * $Date: 2008-09-19 12:56:27 $
7
7
  *
8
- * Copyright 2005-2022 Sutou Kouhei <kou@cozmixng.org>
8
+ * Copyright 2005-2023 Sutou Kouhei <kou@cozmixng.org>
9
9
  *
10
10
  * This file is made available under the same terms as Ruby
11
11
  *
@@ -87,7 +87,7 @@ cr_options_create (VALUE self)
87
87
 
88
88
  options = cairo_font_options_create ();
89
89
  cr_options_check_status (options);
90
- DATA_PTR (self) = options;
90
+ RTYPEDDATA_DATA (self) = options;
91
91
  return Qnil;
92
92
  }
93
93
 
@@ -196,6 +196,53 @@ cr_options_get_variations (VALUE self)
196
196
  }
197
197
  #endif
198
198
 
199
+ #if CAIRO_CHECK_VERSION(1, 17, 8)
200
+ static VALUE
201
+ cr_options_set_color_mode (VALUE self, VALUE mode)
202
+ {
203
+ cairo_font_options_set_color_mode (_SELF (self),
204
+ RVAL2CRCOLORMODE (mode));
205
+ return self;
206
+ }
207
+
208
+ static VALUE
209
+ cr_options_get_color_mode (VALUE self)
210
+ {
211
+ return INT2NUM (cairo_font_options_get_color_mode (_SELF (self)));
212
+ }
213
+
214
+ static VALUE
215
+ cr_options_set_color_palette (VALUE self, VALUE index)
216
+ {
217
+ cairo_font_options_set_color_palette (_SELF (self),
218
+ NUM2UINT (index));
219
+ return self;
220
+ }
221
+
222
+ static VALUE
223
+ cr_options_get_color_palette (VALUE self)
224
+ {
225
+ return UINT2NUM (cairo_font_options_get_color_palette (_SELF (self)));
226
+ }
227
+
228
+ static VALUE
229
+ cr_options_set_custom_palette_color (VALUE self,
230
+ VALUE index,
231
+ VALUE red,
232
+ VALUE green,
233
+ VALUE blue,
234
+ VALUE alpha)
235
+ {
236
+ cairo_font_options_set_custom_palette_color (_SELF (self),
237
+ NUM2UINT (index),
238
+ NUM2DBL (red),
239
+ NUM2DBL (green),
240
+ NUM2DBL (blue),
241
+ NUM2DBL (alpha));
242
+ return self;
243
+ }
244
+ #endif
245
+
199
246
  void
200
247
  Init_cairo_font_options (void)
201
248
  {
@@ -234,6 +281,18 @@ Init_cairo_font_options (void)
234
281
  rb_define_method (rb_cCairo_FontOptions, "variations",
235
282
  cr_options_get_variations, 0);
236
283
  #endif
284
+ #if CAIRO_CHECK_VERSION(1, 17, 8)
285
+ rb_define_method (rb_cCairo_FontOptions, "set_color_mode",
286
+ cr_options_set_color_mode, 1);
287
+ rb_define_method (rb_cCairo_FontOptions, "color_mode",
288
+ cr_options_get_color_mode, 0);
289
+ rb_define_method (rb_cCairo_FontOptions, "set_color_palette",
290
+ cr_options_set_color_palette, 1);
291
+ rb_define_method (rb_cCairo_FontOptions, "color_palette",
292
+ cr_options_get_color_palette, 0);
293
+ rb_define_method (rb_cCairo_FontOptions, "set_custom_palette_color",
294
+ cr_options_set_custom_palette_color, 5);
295
+ #endif
237
296
 
238
297
  RB_CAIRO_DEF_SETTERS (rb_cCairo_FontOptions);
239
298
  }
@@ -77,7 +77,7 @@ cr_glyph_initialize (VALUE self, VALUE index, VALUE x, VALUE y)
77
77
  glyph->x = NUM2DBL (x);
78
78
  glyph->y = NUM2DBL (y);
79
79
 
80
- DATA_PTR (self) = glyph;
80
+ RTYPEDDATA_DATA (self) = glyph;
81
81
  return Qnil;
82
82
  }
83
83
 
@@ -81,7 +81,7 @@ cr_matrix_initialize (VALUE self,
81
81
  NUM2DBL (xx), NUM2DBL (yx),
82
82
  NUM2DBL (xy), NUM2DBL (yy),
83
83
  NUM2DBL (x0), NUM2DBL (y0));
84
- DATA_PTR (self) = matrix;
84
+ RTYPEDDATA_DATA (self) = matrix;
85
85
  return Qnil;
86
86
  }
87
87
 
@@ -291,7 +291,7 @@ cr_path_initialize (VALUE self)
291
291
  path->status = CAIRO_STATUS_SUCCESS;
292
292
  path->data = NULL;
293
293
  path->num_data = 0;
294
- DATA_PTR (self) = path;
294
+ RTYPEDDATA_DATA (self) = path;
295
295
 
296
296
  return Qnil;
297
297
  }
@@ -259,7 +259,7 @@ cr_solid_pattern_initialize (int argc, VALUE *argv, VALUE self)
259
259
  }
260
260
 
261
261
  cr_pattern_check_status (pattern);
262
- DATA_PTR (self) = pattern;
262
+ RTYPEDDATA_DATA (self) = pattern;
263
263
  return Qnil;
264
264
  }
265
265
 
@@ -270,7 +270,7 @@ cr_surface_pattern_initialize (VALUE self, VALUE surface)
270
270
 
271
271
  pattern = cairo_pattern_create_for_surface (RVAL2CRSURFACE (surface));
272
272
  cr_pattern_check_status (pattern);
273
- DATA_PTR (self) = pattern;
273
+ RTYPEDDATA_DATA (self) = pattern;
274
274
  return Qnil;
275
275
  }
276
276
 
@@ -283,7 +283,7 @@ cr_linear_pattern_initialize (VALUE self, VALUE x0, VALUE y0,
283
283
  pattern = cairo_pattern_create_linear (NUM2DBL (x0), NUM2DBL (y0),
284
284
  NUM2DBL (x1), NUM2DBL (y1));
285
285
  cr_pattern_check_status (pattern);
286
- DATA_PTR (self) = pattern;
286
+ RTYPEDDATA_DATA (self) = pattern;
287
287
  return Qnil;
288
288
  }
289
289
 
@@ -298,7 +298,7 @@ cr_radial_pattern_initialize (VALUE self, VALUE cx0, VALUE cy0, VALUE radius0,
298
298
  NUM2DBL (cx1), NUM2DBL (cy1),
299
299
  NUM2DBL (radius1));
300
300
  cr_pattern_check_status (pattern);
301
- DATA_PTR (self) = pattern;
301
+ RTYPEDDATA_DATA (self) = pattern;
302
302
  return Qnil;
303
303
  }
304
304
 
@@ -526,7 +526,7 @@ cr_mesh_pattern_initialize (VALUE self)
526
526
 
527
527
  pattern = cairo_pattern_create_mesh ();
528
528
  cr_pattern_check_status (pattern);
529
- DATA_PTR (self) = pattern;
529
+ RTYPEDDATA_DATA (self) = pattern;
530
530
  return Qnil;
531
531
  }
532
532
 
@@ -924,7 +924,7 @@ cr_raster_source_pattern_initialize (int argc, VALUE *argv, VALUE self)
924
924
  content, width, height);
925
925
  cr_pattern_check_status (pattern);
926
926
 
927
- DATA_PTR (self) = pattern;
927
+ RTYPEDDATA_DATA (self) = pattern;
928
928
  rb_iv_set (self, "@acquire", Qnil);
929
929
  rb_iv_set (self, "@release", Qnil);
930
930
  rb_iv_set (self, "@snapshot", Qnil);
@@ -134,7 +134,7 @@ cr_quartz_surface_initialize (int argc, VALUE *argv, VALUE self)
134
134
  }
135
135
 
136
136
  rb_cairo_surface_check_status (surface);
137
- DATA_PTR (self) = surface;
137
+ RTYPEDDATA_DATA (self) = surface;
138
138
  if (rb_block_given_p ())
139
139
  rb_cairo__surface_yield_and_finish (self);
140
140
  return Qnil;
@@ -169,7 +169,7 @@ cr_quartz_image_surface_initialize (VALUE self, VALUE image_surface)
169
169
 
170
170
  surface = cairo_quartz_image_surface_create (RVAL2CRSURFACE (image_surface));
171
171
  rb_cairo_surface_check_status (surface);
172
- DATA_PTR (self) = surface;
172
+ RTYPEDDATA_DATA (self) = surface;
173
173
  rb_ivar_set (self, cr_id_image_surface, image_surface);
174
174
  if (rb_block_given_p ())
175
175
  rb_cairo__surface_yield_and_finish (self);
@@ -12,7 +12,7 @@
12
12
 
13
13
  VALUE rb_cCairo_Rectangle;
14
14
 
15
- #define _SELF ((cairo_rectangle_int_t *)DATA_PTR (self))
15
+ #define _SELF ((cairo_rectangle_int_t *)RTYPEDDATA_DATA (self))
16
16
 
17
17
  #if CAIRO_CHECK_VERSION(1, 10, 0)
18
18
  static const rb_data_type_t cr_rectangle_type = {
@@ -39,7 +39,7 @@ cr_rectangle_initialize (VALUE self, VALUE x, VALUE y,
39
39
  cairo_rectangle_int_t *rectangle;
40
40
 
41
41
  rectangle = ALLOC (cairo_rectangle_int_t);
42
- DATA_PTR (self) = rectangle;
42
+ RTYPEDDATA_DATA (self) = rectangle;
43
43
 
44
44
  rectangle->x = NUM2INT (x);
45
45
  rectangle->y = NUM2INT (y);
@@ -106,7 +106,7 @@ cr_region_initialize (int argc, VALUE *argv, VALUE self)
106
106
  region = cairo_region_create_rectangles (rectangles, argc);
107
107
  }
108
108
  cr_region_check_status (region);
109
- DATA_PTR (self) = region;
109
+ RTYPEDDATA_DATA (self) = region;
110
110
  return Qnil;
111
111
  }
112
112
 
@@ -87,7 +87,7 @@ cr_scaled_font_initialize (VALUE self, VALUE face, VALUE matrix,
87
87
  RVAL2CRMATRIX (ctm),
88
88
  RVAL2CRFONTOPTIONS (options));
89
89
  cr_scaled_font_check_status (font);
90
- DATA_PTR (self) = font;
90
+ RTYPEDDATA_DATA (self) = font;
91
91
  return Qnil;
92
92
  }
93
93
 
@@ -280,7 +280,7 @@ cr_surface_destroy (VALUE self)
280
280
 
281
281
  surface = _SELF;
282
282
  cr_surface_destroy_raw (surface);
283
- DATA_PTR (self) = NULL;
283
+ RTYPEDDATA_DATA (self) = NULL;
284
284
 
285
285
  return self;
286
286
  }
@@ -534,7 +534,7 @@ cr_surface_finish (VALUE self)
534
534
  cairo_surface_finish (surface);
535
535
  cairo_surface_set_user_data (surface, &cr_finished_key, (void *)CR_TRUE, NULL);
536
536
  cairo_surface_set_user_data (surface, &cr_object_holder_key, NULL, NULL);
537
- DATA_PTR (self) = NULL;
537
+ RTYPEDDATA_DATA (self) = NULL;
538
538
 
539
539
  if (closure && !NIL_P (closure->error))
540
540
  rb_exc_raise (closure->error);
@@ -750,6 +750,11 @@ cr_surface_write_to_png (VALUE self, VALUE filename)
750
750
  static VALUE
751
751
  cr_surface_write_to_png_generic (VALUE self, VALUE target)
752
752
  {
753
+ if (rb_respond_to (target, rb_cairo__io_id_to_path) &&
754
+ !rb_respond_to (target, rb_cairo__io_id_to_io))
755
+ {
756
+ target = rb_funcall (target, rb_cairo__io_id_to_path, 0);
757
+ }
753
758
  if (rb_respond_to (target, rb_cairo__io_id_write))
754
759
  return cr_surface_write_to_png_stream (self, target);
755
760
  else
@@ -1015,7 +1020,7 @@ cr_image_surface_create_from_png_generic (VALUE klass, VALUE target)
1015
1020
 
1016
1021
  rb_cairo_surface_check_status (surface);
1017
1022
  rb_surface = cr_surface_allocate (klass);
1018
- DATA_PTR (rb_surface) = surface;
1023
+ RTYPEDDATA_DATA (rb_surface) = surface;
1019
1024
  return rb_surface;
1020
1025
  }
1021
1026
  #endif
@@ -1072,7 +1077,7 @@ cr_image_surface_initialize (int argc, VALUE *argv, VALUE self)
1072
1077
  rb_cairo__inspect (rb_ary_new3 (4, arg1, arg2, arg3, arg4)));
1073
1078
 
1074
1079
  rb_cairo_surface_check_status (surface);
1075
- DATA_PTR (self) = surface;
1080
+ RTYPEDDATA_DATA (self) = surface;
1076
1081
  rb_cairo_surface_adjust_memory_usage (surface, CR_TRUE);
1077
1082
  if (rb_block_given_p ())
1078
1083
  rb_cairo__surface_yield_and_finish (self);
@@ -1193,7 +1198,7 @@ cr_ ## type ## _surface_initialize (int argc, VALUE *argv, VALUE self) \
1193
1198
  } \
1194
1199
  \
1195
1200
  rb_cairo_surface_check_status (surface); \
1196
- DATA_PTR (self) = surface; \
1201
+ RTYPEDDATA_DATA (self) = surface; \
1197
1202
  if (rb_block_given_p ()) \
1198
1203
  rb_cairo__surface_yield_and_finish (self); \
1199
1204
  return Qnil; \
@@ -1534,7 +1539,7 @@ cr_win32_surface_initialize (int argc, VALUE *argv, VALUE self)
1534
1539
  if (!surface)
1535
1540
  rb_cairo_check_status (CAIRO_STATUS_INVALID_FORMAT);
1536
1541
  rb_cairo_surface_check_status (surface);
1537
- DATA_PTR (self) = surface;
1542
+ RTYPEDDATA_DATA (self) = surface;
1538
1543
  if (rb_block_given_p ())
1539
1544
  rb_cairo__surface_yield_and_finish (self);
1540
1545
  return Qnil;
@@ -1610,7 +1615,7 @@ cr_win32_printing_surface_initialize (VALUE self, VALUE hdc)
1610
1615
 
1611
1616
  surface = cairo_win32_printing_surface_create (NUM2PTR (hdc));
1612
1617
  rb_cairo_surface_check_status (surface);
1613
- DATA_PTR (self) = surface;
1618
+ RTYPEDDATA_DATA (self) = surface;
1614
1619
  if (rb_block_given_p ())
1615
1620
  rb_cairo__surface_yield_and_finish (self);
1616
1621
  return Qnil;
@@ -1665,7 +1670,7 @@ cr_script_surface_initialize (int argc, VALUE *argv, VALUE self)
1665
1670
  surface = cairo_script_surface_create (device, content, width, height);
1666
1671
 
1667
1672
  rb_cairo_surface_check_status (surface);
1668
- DATA_PTR (self) = surface;
1673
+ RTYPEDDATA_DATA (self) = surface;
1669
1674
  if (rb_block_given_p ())
1670
1675
  rb_cairo__surface_yield_and_finish (self);
1671
1676
  return Qnil;
@@ -1720,7 +1725,7 @@ cr_recording_surface_initialize (int argc, VALUE *argv, VALUE self)
1720
1725
 
1721
1726
  surface = cairo_recording_surface_create (content, &extents);
1722
1727
  rb_cairo_surface_check_status (surface);
1723
- DATA_PTR (self) = surface;
1728
+ RTYPEDDATA_DATA (self) = surface;
1724
1729
  if (rb_block_given_p ())
1725
1730
  rb_cairo__surface_yield_and_finish (self);
1726
1731
  return Qnil;
@@ -1797,7 +1802,7 @@ cr_gl_surface_initialize (int argc, VALUE *argv, VALUE self)
1797
1802
  surface = cairo_gl_surface_create (device, content, width, height);
1798
1803
 
1799
1804
  rb_cairo_surface_check_status (surface);
1800
- DATA_PTR (self) = surface;
1805
+ RTYPEDDATA_DATA (self) = surface;
1801
1806
  if (rb_block_given_p ())
1802
1807
  rb_cairo__surface_yield_and_finish (self);
1803
1808
  return Qnil;
@@ -1844,7 +1849,7 @@ cr_gl_texture_surface_initialize (int argc, VALUE *argv, VALUE self)
1844
1849
  height);
1845
1850
 
1846
1851
  rb_cairo_surface_check_status (surface);
1847
- DATA_PTR (self) = surface;
1852
+ RTYPEDDATA_DATA (self) = surface;
1848
1853
  if (rb_block_given_p ())
1849
1854
  rb_cairo__surface_yield_and_finish (self);
1850
1855
  return Qnil;
@@ -1894,7 +1899,7 @@ cr_tee_surface_initialize (VALUE self, VALUE master)
1894
1899
 
1895
1900
  surface = cairo_tee_surface_create (RVAL2CRSURFACE (master));
1896
1901
  rb_cairo_surface_check_status (surface);
1897
- DATA_PTR (self) = surface;
1902
+ RTYPEDDATA_DATA (self) = surface;
1898
1903
  rb_iv_set (self, "surfaces", rb_ary_new3 (1, master));
1899
1904
  if (rb_block_given_p ())
1900
1905
  rb_cairo__surface_yield_and_finish (self);
@@ -2016,7 +2021,7 @@ cr_xml_surface_initialize (int argc, VALUE *argv, VALUE self)
2016
2021
  surface = cairo_xml_surface_create (device, content, width, height);
2017
2022
 
2018
2023
  rb_cairo_surface_check_status (surface);
2019
- DATA_PTR (self) = surface;
2024
+ RTYPEDDATA_DATA (self) = surface;
2020
2025
  if (rb_block_given_p ())
2021
2026
  rb_cairo__surface_yield_and_finish (self);
2022
2027
  return Qnil;
@@ -2347,7 +2352,7 @@ Init_cairo_surface (void)
2347
2352
  rb_define_class_under (rb_mCairo, "GLTextureSurface", rb_cCairo_GLSurface);
2348
2353
  #ifdef RB_CAIRO_HAS_GL_SURFACE
2349
2354
  rb_define_method (rb_cCairo_GLSurface, "initialize",
2350
- cr_gl_surface_initialize, 1);
2355
+ cr_gl_surface_initialize, -1);
2351
2356
 
2352
2357
  rb_define_method (rb_cCairo_GLSurface, "set_size",
2353
2358
  cr_gl_surface_set_size, 2);
@@ -2361,7 +2366,7 @@ Init_cairo_surface (void)
2361
2366
  RB_CAIRO_DEF_SETTERS (rb_cCairo_GLSurface);
2362
2367
 
2363
2368
  rb_define_method (rb_cCairo_GLTextureSurface, "initialize",
2364
- cr_gl_texture_surface_initialize, 1);
2369
+ cr_gl_texture_surface_initialize, -1);
2365
2370
 
2366
2371
  RB_CAIRO_DEF_SETTERS (rb_cCairo_GLTextureSurface);
2367
2372
  #endif
@@ -81,7 +81,7 @@ cr_text_cluster_initialize (VALUE self, VALUE num_bytes, VALUE num_glyphs)
81
81
  cluster->num_bytes = NUM2INT (num_bytes);
82
82
  cluster->num_glyphs = NUM2INT (num_glyphs);
83
83
 
84
- DATA_PTR (self) = cluster;
84
+ RTYPEDDATA_DATA (self) = cluster;
85
85
  return Qnil;
86
86
  }
87
87
 
@@ -82,7 +82,7 @@ cr_text_extents_initialize (VALUE self)
82
82
  extents->x_advance = 1.0;
83
83
  extents->y_advance = 0.0;
84
84
 
85
- DATA_PTR (self) = extents;
85
+ RTYPEDDATA_DATA (self) = extents;
86
86
 
87
87
  return Qnil;
88
88
  }
data/lib/cairo.rb CHANGED
@@ -1,28 +1,3 @@
1
- # vim: filetype=ruby:expandtab:shiftwidth=2:tabstop=8:softtabstop=2 :
2
-
3
- if /mingw|mswin|mswin32/ =~ RUBY_PLATFORM
4
- require "pathname"
5
- base_dir = Pathname(File.dirname(__FILE__))
6
- base_dir = base_dir.parent + "vendor" + "local"
7
- if base_dir.exist?
8
- base_dir = base_dir.to_s.gsub(/\//, "\\")
9
- begin
10
- require "ruby_installer/runtime"
11
- rescue LoadError
12
- else
13
- RubyInstaller::Runtime.add_dll_directory("#{base_dir}\\bin")
14
- end
15
- ENV["PATH"] = %w(bin lib).collect do |dir|
16
- "#{base_dir}\\#{dir};"
17
- end.join("") + ENV["PATH"]
18
- else
19
- require "rbconfig"
20
- ENV["PATH"] = %w(bin lib).collect do |dir|
21
- "#{RbConfig::CONFIG["prefix"]}\\lib\\GTK\\#{dir};"
22
- end.join("") + ENV["PATH"]
23
- end
24
- end
25
-
26
1
  require "time"
27
2
 
28
3
  module Cairo
@@ -46,13 +21,7 @@ end
46
21
 
47
22
  require "cairo/color"
48
23
  require "cairo/paper"
49
-
50
- begin
51
- major, minor, _ = RUBY_VERSION.split(/\./)
52
- require "#{major}.#{minor}/cairo.so"
53
- rescue LoadError
54
- require "cairo.so"
55
- end
24
+ require "cairo.so"
56
25
  require "cairo/constants"
57
26
 
58
27
  module Cairo
@@ -24,4 +24,16 @@ class ConstantsTest < Test::Unit::TestCase
24
24
  send(assertion, Cairo::MimeType, :JBIG2_GLOBAL)
25
25
  send(assertion, Cairo::MimeType, :JBIG2_GLOBAL_ID)
26
26
  end
27
+
28
+ def test_new_constants_since_1_17_8
29
+ if Cairo.satisfied_version?(1, 17, 8)
30
+ assert_const_defined(Cairo::ColorMode, :DEFAULT)
31
+ assert_const_defined(Cairo::ColorMode, :COLOR)
32
+ assert_const_defined(Cairo::ColorMode, :NO_COLOR)
33
+ assert_const_defined(Cairo::ColorPalette, :DEFAULT)
34
+ else
35
+ assert_not_const_defined(Cairo, :ColorMode)
36
+ assert_not_const_defined(Cairo, :ColorPalette)
37
+ end
38
+ end
27
39
  end
data/test/test_context.rb CHANGED
@@ -105,6 +105,7 @@ class ContextTest < Test::Unit::TestCase
105
105
  sub_test_case("#tag") do
106
106
  setup do
107
107
  only_cairo_version(1, 15, 4)
108
+ only_not_windows
108
109
  end
109
110
 
110
111
  test("LINK") do
@@ -62,4 +62,23 @@ class FontOptionsTest < Test::Unit::TestCase
62
62
  @options.variations = "wdth=200"
63
63
  assert_equal("wdth=200", @options.variations)
64
64
  end
65
+
66
+ test "color mode" do
67
+ only_cairo_version(1, 17, 8)
68
+ assert_equal(Cairo::ColorMode::DEFAULT, @options.color_mode)
69
+ @options.color_mode = Cairo::ColorMode::COLOR
70
+ assert_equal(Cairo::ColorMode::COLOR, @options.color_mode)
71
+ end
72
+
73
+ test "color palette" do
74
+ only_cairo_version(1, 17, 8)
75
+ assert_equal(Cairo::ColorPalette::DEFAULT, @options.color_palette)
76
+ @options.set_custom_palette_color(1,
77
+ 1.0,
78
+ 0.2,
79
+ 0.0,
80
+ 0.8)
81
+ @options.color_palette = 1
82
+ assert_equal(1, @options.color_palette)
83
+ end
65
84
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cairo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.17.7
4
+ version: 1.17.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-31 00:00:00.000000000 Z
11
+ date: 2023-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: native-package-installer
@@ -219,7 +219,7 @@ metadata:
219
219
  mailing_list_uri: https://cairographics.org/cgi-bin/mailman/listinfo/cairo
220
220
  source_code_uri: https://github.com/rcairo/rcairo
221
221
  msys2_mingw_dependencies: cairo
222
- post_install_message:
222
+ post_install_message:
223
223
  rdoc_options: []
224
224
  require_paths:
225
225
  - lib
@@ -235,8 +235,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
235
235
  version: '0'
236
236
  requirements:
237
237
  - cairo >= 1.2.0
238
- rubygems_version: 3.4.0.dev
239
- signing_key:
238
+ rubygems_version: 3.5.0.dev
239
+ signing_key:
240
240
  specification_version: 4
241
241
  summary: Ruby bindings for cairo
242
242
  test_files: