cairo 1.17.5 → 1.17.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5775df8bb8a56c3b4274ef0696f9364fe02490bea3164af4bd2b72bfcc6779e4
4
- data.tar.gz: ed53259db771ecd57cf7a923b2f9e2b63b312b44021e48ddc0e3ddfb7c1bafc4
3
+ metadata.gz: 7b1853ada5ca7f86bebe04e05e51c0b49a84fb7782bb2156db4d1825f75cc415
4
+ data.tar.gz: 326f5322f9e2b66e115d656a762384e5caaa18ecba44c576a805c5989278d330
5
5
  SHA512:
6
- metadata.gz: db3510810d933b993b021919b772bab5f4fcca734402a57b6fb86c3f3c53650b6ffbab494b9768cc1ea5809db78873f2d7b50031078e7cd5d542be5cdbd6e63f
7
- data.tar.gz: d1647888e3e61430a12b2d3268c10d8832d1dad85777d8eb4d99c1be1cb33fd7c73ad0b2a2deeb0fd691c61da148454aa373172749ecd50af9c62715989d6e91
6
+ metadata.gz: db4171dfe178c24f632f38fcbbd1960412160dd999bdd925b6501c663641a308acab2bd6fa2f9a84b3e18c30821ce3f6514b7dac809fd2b965f25c79051f66bd
7
+ data.tar.gz: d9ef0bedc2b597617415c88d3734a4fe33a38bffc7a49939d671e4eed88f0da07f741fad595315376a76504dca36f35186563945a124d43510338ecd16970337
data/NEWS CHANGED
@@ -1,3 +1,43 @@
1
+ Release 1.17.6 (2022-07-30) Sutou Kouhei <kou@cozmixng.org>
2
+ ===========================================================
3
+
4
+ Improvements
5
+ ------------
6
+
7
+ * Added support for cairo 1.17.6:
8
+
9
+ * Added Cairo::PDFVersion::VERSION_1_6.
10
+
11
+ * Added Cairo::PDFVersion::VERSION_1_7.
12
+
13
+ * Added Cairo::PDFSurface#set_metadata.
14
+
15
+ * Added Cairo::DirectWriteError.
16
+
17
+ * Added Cairo::Context#set_hairline.
18
+
19
+ * Added Cairo::Context#hairline?.
20
+
21
+ * Added Cairo::UserFont#on_render_color_glyph.
22
+
23
+ * Updated tests for cairo 1.17.6.
24
+ [GitHub#75][Reported by Mamoru TASAKA]
25
+
26
+ Fixes
27
+ -----
28
+
29
+ * Fixed a wrong conversion bug for the rest size argument in read
30
+ callback.
31
+
32
+ * Fixed a wrong conversion bug in Cairo::Options#hash.
33
+
34
+ * Fixed a GC related crash bug in Cairo::Surface#finish.
35
+
36
+ Thanks
37
+ ------
38
+
39
+ * Mamoru TASAKA
40
+
1
41
  Release 1.17.4 (2021-01-17) Sutou Kouhei <kou@cozmixng.org>
2
42
  ===========================================================
3
43
 
data/ext/cairo/rb_cairo.c CHANGED
@@ -46,7 +46,7 @@ rb_cairo_satisfied_version (int argc, VALUE *argv, VALUE self)
46
46
  }
47
47
 
48
48
  void
49
- Init_cairo ()
49
+ Init_cairo (void)
50
50
  {
51
51
  int major, minor, micro;
52
52
 
data/ext/cairo/rb_cairo.h CHANGED
@@ -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 5
68
+ #define RB_CAIRO_VERSION_MICRO 6
69
69
 
70
70
  RB_CAIRO_VAR VALUE rb_mCairo;
71
71
  RB_CAIRO_VAR VALUE rb_cCairo_Context;
@@ -5,7 +5,7 @@
5
5
  * $Author: kou $
6
6
  * $Date: 2008-09-19 12:56:27 $
7
7
  *
8
- * Copyright 2005-2019 Kouhei Sutou <kou@cozmixng.org>
8
+ * Copyright 2005-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
  *
@@ -113,7 +113,11 @@ VALUE rb_mCairo_SVGUnit = Qnil;
113
113
  #define CAIRO_PS_LEVEL_MAX CAIRO_PS_LEVEL_3
114
114
 
115
115
  #define CAIRO_PDF_VERSION_MIN CAIRO_PDF_VERSION_1_4
116
- #define CAIRO_PDF_VERSION_MAX CAIRO_PDF_VERSION_1_5
116
+ #if CAIRO_CHECK_VERSION(1, 17, 6)
117
+ # define CAIRO_PDF_VERSION_MAX CAIRO_PDF_VERSION_1_7
118
+ #else
119
+ # define CAIRO_PDF_VERSION_MAX CAIRO_PDF_VERSION_1_5
120
+ #endif
117
121
 
118
122
  #define CAIRO_TEXT_CLUSTER_FLAG_MIN 0
119
123
  #define CAIRO_TEXT_CLUSTER_FLAG_MAX CAIRO_TEXT_CLUSTER_FLAG_BACKWARD
@@ -644,6 +648,12 @@ Init_cairo_constants (void)
644
648
  INT2FIX (CAIRO_PDF_VERSION_1_4));
645
649
  rb_define_const (rb_mCairo_PDFVersion, "VERSION_1_5",
646
650
  INT2FIX (CAIRO_PDF_VERSION_1_5));
651
+ # if CAIRO_CHECK_VERSION(1, 17, 6)
652
+ rb_define_const (rb_mCairo_PDFVersion, "VERSION_1_6",
653
+ INT2FIX (CAIRO_PDF_VERSION_1_6));
654
+ rb_define_const (rb_mCairo_PDFVersion, "VERSION_1_7",
655
+ INT2FIX (CAIRO_PDF_VERSION_1_7));
656
+ # endif
647
657
 
648
658
  rb_define_singleton_method (rb_mCairo_PDFVersion, "list",
649
659
  cr_pdf_get_versions, 0);
@@ -523,6 +523,16 @@ cr_set_line_width (VALUE self, VALUE width)
523
523
  return self;
524
524
  }
525
525
 
526
+ #if CAIRO_CHECK_VERSION(1, 17, 6)
527
+ static VALUE
528
+ cr_set_hairline (VALUE self, VALUE hairline)
529
+ {
530
+ cairo_set_hairline (_SELF, RTEST (hairline));
531
+ cr_check_status (_SELF);
532
+ return self;
533
+ }
534
+ #endif
535
+
526
536
  static VALUE
527
537
  cr_set_line_cap (VALUE self, VALUE cap)
528
538
  {
@@ -1490,6 +1500,14 @@ cr_get_line_width (VALUE self)
1490
1500
  return rb_float_new (cairo_get_line_width (_SELF));
1491
1501
  }
1492
1502
 
1503
+ #if CAIRO_CHECK_VERSION(1, 17, 6)
1504
+ static VALUE
1505
+ cr_get_hairline (VALUE self)
1506
+ {
1507
+ return CBOOL2RVAL (cairo_get_hairline (_SELF));
1508
+ }
1509
+ #endif
1510
+
1493
1511
  static VALUE
1494
1512
  cr_get_line_cap (VALUE self)
1495
1513
  {
@@ -1751,6 +1769,9 @@ Init_cairo_context (void)
1751
1769
  rb_define_method (rb_cCairo_Context, "set_antialias", cr_set_antialias, 1);
1752
1770
  rb_define_method (rb_cCairo_Context, "set_fill_rule", cr_set_fill_rule, 1);
1753
1771
  rb_define_method (rb_cCairo_Context, "set_line_width", cr_set_line_width, 1);
1772
+ #if CAIRO_CHECK_VERSION(1, 17, 6)
1773
+ rb_define_method (rb_cCairo_Context, "set_hairline", cr_set_hairline, 1);
1774
+ #endif
1754
1775
  rb_define_method (rb_cCairo_Context, "set_line_cap", cr_set_line_cap, 1);
1755
1776
  rb_define_method (rb_cCairo_Context, "set_line_join", cr_set_line_join, 1);
1756
1777
  rb_define_method (rb_cCairo_Context, "set_dash", cr_set_dash, -1);
@@ -1862,6 +1883,9 @@ Init_cairo_context (void)
1862
1883
  cr_get_current_point, 0);
1863
1884
  rb_define_method (rb_cCairo_Context, "fill_rule", cr_get_fill_rule, 0);
1864
1885
  rb_define_method (rb_cCairo_Context, "line_width", cr_get_line_width, 0);
1886
+ #if CAIRO_CHECK_VERSION(1, 17, 6)
1887
+ rb_define_method (rb_cCairo_Context, "hairline?", cr_get_hairline, 0);
1888
+ #endif
1865
1889
  rb_define_method (rb_cCairo_Context, "line_cap", cr_get_line_cap, 0);
1866
1890
  rb_define_method (rb_cCairo_Context, "line_join", cr_get_line_join, 0);
1867
1891
  rb_define_method (rb_cCairo_Context, "miter_limit", cr_get_miter_limit, 0);
@@ -5,7 +5,7 @@
5
5
  * $Author: kou $
6
6
  * $Date: 2008-08-16 12:52:16 $
7
7
  *
8
- * Copyright 2010-2017 Kouhei Sutou <kou@cozmixng.org>
8
+ * Copyright 2010-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
  *
@@ -71,6 +71,9 @@ static VALUE rb_eCairo_FreeTypeError;
71
71
  static VALUE rb_eCairo_Win32GDIError;
72
72
  static VALUE rb_eCairo_TagError;
73
73
  #endif
74
+ #if CAIRO_CHECK_VERSION(1, 17, 6)
75
+ static VALUE rb_eCairo_DirectWriteError;
76
+ #endif
74
77
 
75
78
  void
76
79
  rb_cairo_check_status (cairo_status_t status)
@@ -221,6 +224,11 @@ rb_cairo_check_status (cairo_status_t status)
221
224
  rb_raise (rb_eCairo_TagError, "%s", string);
222
225
  break;
223
226
  #endif
227
+ #if CAIRO_CHECK_VERSION(1, 17, 6)
228
+ case CAIRO_STATUS_DWRITE_ERROR:
229
+ rb_raise (rb_eCairo_DirectWriteError, "%s", string);
230
+ break;
231
+ #endif
224
232
  #if CAIRO_CHECK_VERSION(1, 10, 0)
225
233
  case CAIRO_STATUS_LAST_STATUS:
226
234
  #else
@@ -328,12 +336,16 @@ rb_cairo__exception_to_status (VALUE exception)
328
336
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_TagError))
329
337
  return CAIRO_STATUS_TAG_ERROR;
330
338
  #endif
339
+ #if CAIRO_CHECK_VERSION(1, 17, 6)
340
+ else if (rb_cairo__is_kind_of (exception, rb_eCairo_DirectWriteError))
341
+ return CAIRO_STATUS_DWRITE_ERROR;
342
+ #endif
331
343
 
332
344
  return -1;
333
345
  }
334
346
 
335
347
  void
336
- Init_cairo_exception ()
348
+ Init_cairo_exception (void)
337
349
  {
338
350
  VALUE rb_eCairo_Error;
339
351
  rb_eCairo_Error =
@@ -488,4 +500,10 @@ Init_cairo_exception ()
488
500
  rb_define_class_under (rb_mCairo, "TagError",
489
501
  rb_eCairo_Error);
490
502
  #endif
503
+
504
+ #if CAIRO_CHECK_VERSION(1, 17, 6)
505
+ rb_eCairo_DirectWriteError =
506
+ rb_define_class_under (rb_mCairo, "DirectWriteError",
507
+ rb_eCairo_Error);
508
+ #endif
491
509
  }
@@ -5,7 +5,7 @@
5
5
  * $Author: kou $
6
6
  * $Date: 2008-09-26 14:13:58 $
7
7
  *
8
- * Copyright 2003-2019 Sutou Kouhei <kou@cozmixng.org>
8
+ * Copyright 2003-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
  *
@@ -39,6 +39,9 @@ static ID cr_id_new;
39
39
 
40
40
  static ID cr_id_init;
41
41
  static ID cr_id_render_glyph;
42
+ # if CAIRO_CHECK_VERSION(1, 17, 6)
43
+ static ID cr_id_render_color_glyph;
44
+ #endif
42
45
  static ID cr_id_text_to_glyphs;
43
46
  static ID cr_id_unicode_to_glyph;
44
47
 
@@ -463,10 +466,11 @@ cr_user_font_face_render_glyph_func_after (VALUE user_data)
463
466
  }
464
467
 
465
468
  static cairo_status_t
466
- cr_user_font_face_render_glyph_func (cairo_scaled_font_t *scaled_font,
467
- unsigned long glyph,
468
- cairo_t *cr,
469
- cairo_text_extents_t *extents)
469
+ cr_user_font_face_render_glyph_func_internal (cairo_scaled_font_t *scaled_font,
470
+ unsigned long glyph,
471
+ cairo_t *cr,
472
+ cairo_text_extents_t *extents,
473
+ ID id_registered_method_name)
470
474
  {
471
475
  cairo_status_t status = CAIRO_STATUS_SUCCESS;
472
476
  cairo_font_face_t *face;
@@ -477,10 +481,11 @@ cr_user_font_face_render_glyph_func (cairo_scaled_font_t *scaled_font,
477
481
  face = cairo_scaled_font_get_font_face (scaled_font);
478
482
  self = (VALUE)cairo_font_face_get_user_data (face, &ruby_object_key);
479
483
  receiver = rb_ivar_get (self, cr_id_render_glyph);
480
- if (NIL_P (receiver) && rb_obj_respond_to (self, cr_id_render_glyph, Qtrue))
484
+ if (NIL_P (receiver) &&
485
+ rb_obj_respond_to (self, id_registered_method_name, Qtrue))
481
486
  {
482
487
  receiver = self;
483
- id_method_name = cr_id_render_glyph;
488
+ id_method_name = id_registered_method_name;
484
489
  }
485
490
 
486
491
  if (!NIL_P (receiver))
@@ -507,6 +512,34 @@ cr_user_font_face_render_glyph_func (cairo_scaled_font_t *scaled_font,
507
512
  return status;
508
513
  }
509
514
 
515
+ static cairo_status_t
516
+ cr_user_font_face_render_glyph_func (cairo_scaled_font_t *scaled_font,
517
+ unsigned long glyph,
518
+ cairo_t *cr,
519
+ cairo_text_extents_t *extents)
520
+ {
521
+ return cr_user_font_face_render_glyph_func_internal (scaled_font,
522
+ glyph,
523
+ cr,
524
+ extents,
525
+ cr_id_render_glyph);
526
+ }
527
+
528
+ #if CAIRO_CHECK_VERSION(1, 17, 6)
529
+ static cairo_status_t
530
+ cr_user_font_face_render_color_glyph_func (cairo_scaled_font_t *scaled_font,
531
+ unsigned long glyph,
532
+ cairo_t *cr,
533
+ cairo_text_extents_t *extents)
534
+ {
535
+ return cr_user_font_face_render_glyph_func_internal (scaled_font,
536
+ glyph,
537
+ cr,
538
+ extents,
539
+ cr_id_render_color_glyph);
540
+ }
541
+ #endif
542
+
510
543
  typedef struct _cr_text_to_glyphs_after_hook_data {
511
544
  VALUE text_to_glyphs_data;
512
545
  cairo_glyph_t **glyphs;
@@ -703,6 +736,10 @@ cr_user_font_face_initialize (VALUE self)
703
736
  (face, cr_user_font_face_init_func);
704
737
  cairo_user_font_face_set_render_glyph_func
705
738
  (face, cr_user_font_face_render_glyph_func);
739
+ #if CAIRO_CHECK_VERSION(1, 17, 6)
740
+ cairo_user_font_face_set_render_color_glyph_func
741
+ (face, cr_user_font_face_render_color_glyph_func);
742
+ #endif
706
743
  cairo_user_font_face_set_text_to_glyphs_func
707
744
  (face, cr_user_font_face_text_to_glyphs_func);
708
745
  cairo_user_font_face_set_unicode_to_glyph_func
@@ -732,6 +769,15 @@ cr_user_font_face_on_render_glyph (VALUE self)
732
769
  return self;
733
770
  }
734
771
 
772
+ #if CAIRO_CHECK_VERSION(1, 17, 6)
773
+ static VALUE
774
+ cr_user_font_face_on_render_color_glyph (VALUE self)
775
+ {
776
+ rb_ivar_set (self, cr_id_render_color_glyph, rb_block_proc ());
777
+ return self;
778
+ }
779
+ #endif
780
+
735
781
  static VALUE
736
782
  cr_user_font_face_on_text_to_glyphs (VALUE self)
737
783
  {
@@ -804,6 +850,9 @@ Init_cairo_font (void)
804
850
 
805
851
  cr_id_init = rb_intern ("init");
806
852
  cr_id_render_glyph = rb_intern ("render_glyph");
853
+ # if CAIRO_CHECK_VERSION(1, 17, 6)
854
+ cr_id_render_color_glyph = rb_intern ("render_color_glyph");
855
+ #endif
807
856
  cr_id_text_to_glyphs = rb_intern ("text_to_glyphs");
808
857
  cr_id_unicode_to_glyph = rb_intern ("unicode_to_glyph");
809
858
 
@@ -867,6 +916,10 @@ Init_cairo_font (void)
867
916
  cr_user_font_face_on_init, 0);
868
917
  rb_define_method (rb_cCairo_UserFontFace, "on_render_glyph",
869
918
  cr_user_font_face_on_render_glyph, 0);
919
+ #if CAIRO_CHECK_VERSION(1, 17, 6)
920
+ rb_define_method (rb_cCairo_UserFontFace, "on_render_color_glyph",
921
+ cr_user_font_face_on_render_color_glyph, 0);
922
+ #endif
870
923
  rb_define_method (rb_cCairo_UserFontFace, "on_text_to_glyphs",
871
924
  cr_user_font_face_on_text_to_glyphs, 0);
872
925
  rb_define_method (rb_cCairo_UserFontFace, "on_unicode_to_glyph",
@@ -17,6 +17,8 @@
17
17
  #endif
18
18
 
19
19
  #ifdef CAIRO_HAS_QUARTZ_SURFACE
20
+ static ID cr_id_image_surface;
21
+
20
22
  # ifndef HAVE_TYPE_ENUM_RUBY_VALUE_TYPE
21
23
  enum ruby_value_type {
22
24
  RUBY_T_DATA = T_DATA
@@ -168,6 +170,7 @@ cr_quartz_image_surface_initialize (VALUE self, VALUE image_surface)
168
170
  surface = cairo_quartz_image_surface_create (RVAL2CRSURFACE (image_surface));
169
171
  rb_cairo_surface_check_status (surface);
170
172
  DATA_PTR (self) = surface;
173
+ rb_ivar_set (self, cr_id_image_surface, image_surface);
171
174
  if (rb_block_given_p ())
172
175
  rb_cairo__surface_yield_and_finish (self);
173
176
  return Qnil;
@@ -199,6 +202,8 @@ Init_cairo_quartz_surface (void)
199
202
 
200
203
  /* Quartz image surface */
201
204
  #ifdef RB_CAIRO_HAS_QUARTZ_IMAGE_SURFACE
205
+ cr_id_image_surface = rb_intern ("image_surface");
206
+
202
207
  rb_define_method (rb_cCairo_QuartzImageSurface, "initialize",
203
208
  cr_quartz_image_surface_initialize, 1);
204
209
  rb_define_method (rb_cCairo_QuartzImageSurface, "image",
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  * Ruby Cairo Binding
4
4
  *
5
- * Copyright 2005-2019 Kouhei Sutou <kou@cozmixng.org>
5
+ * Copyright 2005-2022 Sutou Kouhei <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>
@@ -232,6 +232,28 @@ rb_cairo_surface_adjust_memory_usage (cairo_surface_t *surface,
232
232
  #endif
233
233
  }
234
234
 
235
+ static cairo_surface_t *
236
+ rb_cairo_surface_from_ruby_object_without_null_check (VALUE obj)
237
+ {
238
+ cairo_surface_t *surface;
239
+ if (!rb_cairo__is_kind_of (obj, rb_cCairo_Surface))
240
+ {
241
+ rb_raise (rb_eTypeError, "not a cairo surface");
242
+ }
243
+ Data_Get_Struct (obj, cairo_surface_t, surface);
244
+ return surface;
245
+ }
246
+
247
+ cairo_surface_t *
248
+ rb_cairo_surface_from_ruby_object (VALUE obj)
249
+ {
250
+ cairo_surface_t *surface =
251
+ rb_cairo_surface_from_ruby_object_without_null_check (obj);
252
+ if (!surface)
253
+ rb_cairo_check_status (CAIRO_STATUS_NULL_POINTER);
254
+ return surface;
255
+ }
256
+
235
257
  static void
236
258
  cr_surface_destroy_raw (cairo_surface_t *surface)
237
259
  {
@@ -254,7 +276,7 @@ cr_surface_destroy (VALUE self)
254
276
  static VALUE
255
277
  cr_surface_destroy_with_destroy_check (VALUE self)
256
278
  {
257
- if (_SELF)
279
+ if (rb_cairo_surface_from_ruby_object_without_null_check (self))
258
280
  cr_surface_destroy (self);
259
281
  return Qnil;
260
282
  }
@@ -407,21 +429,6 @@ cr_surface_xml_supported_p (VALUE klass)
407
429
  #endif
408
430
  }
409
431
 
410
- /* constructor/de-constructor */
411
- cairo_surface_t *
412
- rb_cairo_surface_from_ruby_object (VALUE obj)
413
- {
414
- cairo_surface_t *surface;
415
- if (!rb_cairo__is_kind_of (obj, rb_cCairo_Surface))
416
- {
417
- rb_raise (rb_eTypeError, "not a cairo surface");
418
- }
419
- Data_Get_Struct (obj, cairo_surface_t, surface);
420
- if (!surface)
421
- rb_cairo_check_status (CAIRO_STATUS_NULL_POINTER);
422
- return surface;
423
- }
424
-
425
432
  static rb_cairo__object_holder_t *
426
433
  cr_object_holder_new (VALUE object)
427
434
  {
@@ -515,6 +522,7 @@ cr_surface_finish (VALUE self)
515
522
  cairo_surface_finish (surface);
516
523
  cairo_surface_set_user_data (surface, &cr_finished_key, (void *)CR_TRUE, NULL);
517
524
  cairo_surface_set_user_data (surface, &cr_object_holder_key, NULL, NULL);
525
+ DATA_PTR (self) = NULL;
518
526
 
519
527
  if (closure && !NIL_P (closure->error))
520
528
  rb_exc_raise (closure->error);
@@ -531,7 +539,7 @@ rb_cairo__surface_yield_and_finish (VALUE self)
531
539
 
532
540
  rb_result = rb_yield (self);
533
541
 
534
- surface = _SELF;
542
+ surface = rb_cairo_surface_from_ruby_object_without_null_check (self);
535
543
  if (!surface)
536
544
  return rb_result;
537
545
  if (cairo_surface_status (surface) != CAIRO_STATUS_SUCCESS)
@@ -1328,6 +1336,26 @@ cr_pdf_surface_set_thumbnail_size (VALUE self,
1328
1336
  return Qnil;
1329
1337
  }
1330
1338
  # endif
1339
+
1340
+ # if CAIRO_CHECK_VERSION(1, 17, 6)
1341
+ static VALUE
1342
+ cr_pdf_surface_set_custom_metadata (VALUE self,
1343
+ VALUE rb_name,
1344
+ VALUE rb_value)
1345
+ {
1346
+ cairo_surface_t *surface;
1347
+ const char *name;
1348
+ const char *value;
1349
+
1350
+ surface = _SELF;
1351
+ name = RVAL2CSTR (rb_name);
1352
+ value = RVAL2CSTR (rb_value);
1353
+ cairo_pdf_surface_set_custom_metadata (surface, name, value);
1354
+ rb_cairo_surface_check_status (surface);
1355
+
1356
+ return Qnil;
1357
+ }
1358
+ # endif
1331
1359
  #endif
1332
1360
 
1333
1361
  #ifdef CAIRO_HAS_PS_SURFACE
@@ -2177,6 +2205,11 @@ Init_cairo_surface (void)
2177
2205
  }
2178
2206
  # endif
2179
2207
 
2208
+ # if CAIRO_CHECK_VERSION(1, 17, 6)
2209
+ rb_define_method (rb_cCairo_PDFSurface, "set_custom_metadata",
2210
+ cr_pdf_surface_set_custom_metadata, 2);
2211
+ # endif
2212
+
2180
2213
  RB_CAIRO_DEF_SETTERS (rb_cCairo_PDFSurface);
2181
2214
  #endif
2182
2215
 
data/test/test_context.rb CHANGED
@@ -129,4 +129,18 @@ class ContextTest < Test::Unit::TestCase
129
129
  context.raw_address > 0
130
130
  end
131
131
  end
132
+
133
+ def test_hairline
134
+ only_cairo_version(1, 17, 6)
135
+
136
+ Cairo::Context.create(@surface) do |context|
137
+ assert do
138
+ not context.hairline?
139
+ end
140
+ context.hairline = true
141
+ assert do
142
+ context.hairline?
143
+ end
144
+ end
145
+ end
132
146
  end
@@ -161,12 +161,16 @@ class FontFaceTest < Test::Unit::TestCase
161
161
 
162
162
  if Cairo.satisfied_version?(1, 7, 2)
163
163
  class CustomUserFontFace < Cairo::UserFontFace
164
- attr_reader :init_args, :render_glyph_args
165
- attr_reader :text_to_glyphs_args, :unicode_to_glyph_args
164
+ attr_reader :init_args
165
+ attr_reader :render_glyph_args
166
+ attr_reader :render_color_glyph_args
167
+ attr_reader :text_to_glyphs_args
168
+ attr_reader :unicode_to_glyph_args
166
169
  def initialize
167
170
  super
168
171
  @init_args = []
169
172
  @render_glyph_args = []
173
+ @render_color_glyph_args = []
170
174
  @text_to_glyphs_args = []
171
175
  @unicode_to_glyph_args = []
172
176
  end
@@ -179,6 +183,10 @@ class FontFaceTest < Test::Unit::TestCase
179
183
  @render_glyph_args << args
180
184
  end
181
185
 
186
+ def render_color_glyph(*args)
187
+ @render_color_glyph_args << args
188
+ end
189
+
182
190
  def text_to_glyphs(*args)
183
191
  @text_to_glyphs_args << args
184
192
  scaled_font, utf8, data = args
@@ -203,25 +211,102 @@ class FontFaceTest < Test::Unit::TestCase
203
211
  Cairo::Matrix.identity,
204
212
  Cairo::FontOptions.new)
205
213
  result = scaled_font.text_to_glyphs(0, 0, "text")
206
- assert_equal([[[Cairo::ScaledFont, Cairo::Context, Cairo::FontExtents]],
207
- [[Cairo::ScaledFont, codepoint("t"),
208
- Cairo::Context, Cairo::TextExtents],
209
- [Cairo::ScaledFont, codepoint("e"),
210
- Cairo::Context, Cairo::TextExtents],
211
- [Cairo::ScaledFont, codepoint("x"),
212
- Cairo::Context, Cairo::TextExtents]],
213
- [[Cairo::ScaledFont, "text",
214
- Cairo::UserFontFace::TextToGlyphsData]],
215
- [[Cairo::ScaledFont, codepoint("t")],
216
- [Cairo::ScaledFont, codepoint("e")],
217
- [Cairo::ScaledFont, codepoint("x")],
218
- [Cairo::ScaledFont, codepoint("t")]],
219
- [[], [], Cairo::TextClusterFlag::BACKWARD]],
220
- [classify_cairo_object(face.init_args),
221
- classify_cairo_object(face.render_glyph_args),
222
- classify_cairo_object(face.text_to_glyphs_args),
223
- classify_cairo_object(face.unicode_to_glyph_args),
224
- result])
214
+ if Cairo.satisfied_version?(1, 17, 6)
215
+ assert_equal({
216
+ init_args: [
217
+ [Cairo::ScaledFont, Cairo::Context, Cairo::FontExtents]
218
+ ],
219
+ render_glyph_args: [],
220
+ render_color_glyph_args: [
221
+ [
222
+ Cairo::ScaledFont, codepoint("t"),
223
+ Cairo::Context, Cairo::TextExtents,
224
+ ],
225
+ [
226
+ Cairo::ScaledFont, codepoint("e"),
227
+ Cairo::Context, Cairo::TextExtents,
228
+ ],
229
+ [
230
+ Cairo::ScaledFont, codepoint("x"),
231
+ Cairo::Context, Cairo::TextExtents,
232
+ ],
233
+ ],
234
+ text_to_glyphs_args: [
235
+ [
236
+ Cairo::ScaledFont, "text",
237
+ Cairo::UserFontFace::TextToGlyphsData],
238
+ ],
239
+ unicode_to_glyph_args: [
240
+ [Cairo::ScaledFont, codepoint("t")],
241
+ [Cairo::ScaledFont, codepoint("e")],
242
+ [Cairo::ScaledFont, codepoint("x")],
243
+ [Cairo::ScaledFont, codepoint("t")],
244
+ ],
245
+ result: [
246
+ [],
247
+ [],
248
+ Cairo::TextClusterFlag::BACKWARD,
249
+ ],
250
+ },
251
+ {
252
+ init_args: classify_cairo_object(face.init_args),
253
+ render_glyph_args:
254
+ classify_cairo_object(face.render_glyph_args),
255
+ render_color_glyph_args:
256
+ classify_cairo_object(face.render_color_glyph_args),
257
+ text_to_glyphs_args:
258
+ classify_cairo_object(face.text_to_glyphs_args),
259
+ unicode_to_glyph_args:
260
+ classify_cairo_object(face.unicode_to_glyph_args),
261
+ result: result,
262
+ })
263
+ else
264
+ assert_equal({
265
+ init_args: [
266
+ [Cairo::ScaledFont, Cairo::Context, Cairo::FontExtents]
267
+ ],
268
+ render_glyph_args: [
269
+ [
270
+ Cairo::ScaledFont, codepoint("t"),
271
+ Cairo::Context, Cairo::TextExtents,
272
+ ],
273
+ [
274
+ Cairo::ScaledFont, codepoint("e"),
275
+ Cairo::Context, Cairo::TextExtents,
276
+ ],
277
+ [
278
+ Cairo::ScaledFont, codepoint("x"),
279
+ Cairo::Context, Cairo::TextExtents,
280
+ ],
281
+ ],
282
+ text_to_glyphs_args: [
283
+ [
284
+ Cairo::ScaledFont, "text",
285
+ Cairo::UserFontFace::TextToGlyphsData],
286
+ ],
287
+ unicode_to_glyph_args: [
288
+ [Cairo::ScaledFont, codepoint("t")],
289
+ [Cairo::ScaledFont, codepoint("e")],
290
+ [Cairo::ScaledFont, codepoint("x")],
291
+ [Cairo::ScaledFont, codepoint("t")],
292
+ ],
293
+ result: [
294
+ [],
295
+ [],
296
+ Cairo::TextClusterFlag::BACKWARD,
297
+ ],
298
+ },
299
+ {
300
+ init_args: classify_cairo_object(face.init_args),
301
+ render_glyph_args:
302
+ classify_cairo_object(face.render_glyph_args),
303
+ text_to_glyphs_args:
304
+ classify_cairo_object(face.text_to_glyphs_args),
305
+ unicode_to_glyph_args:
306
+ classify_cairo_object(face.unicode_to_glyph_args),
307
+ result: result,
308
+ })
309
+ end
225
310
  end
226
311
 
227
312
  def test_user_font_face_class_and_callback
@@ -6,8 +6,10 @@ class QuartzImageSurfaceTest < Test::Unit::TestCase
6
6
  end
7
7
 
8
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)
9
+ Cairo::ImageSurface.create(100, 100) do |surface|
10
+ Cairo::QuartzImageSurface.create(surface) do |quartz_surface|
11
+ assert_kind_of(Cairo::QuartzImageSurface, quartz_surface)
12
+ end
13
+ end
12
14
  end
13
15
  end
@@ -10,7 +10,11 @@ class SVGSurfaceTest < Test::Unit::TestCase
10
10
  only_cairo_version(1, 15, 10)
11
11
  output = StringIO.new
12
12
  surface = Cairo::SVGSurface.new(output, 10, 20)
13
- assert_equal(Cairo::SVGUnit::PT, surface.document_unit)
13
+ if Cairo.satisfied_version?(1, 17, 6)
14
+ assert_equal(Cairo::SVGUnit::USER, surface.document_unit)
15
+ else
16
+ assert_equal(Cairo::SVGUnit::PT, surface.document_unit)
17
+ end
14
18
  surface.document_unit = Cairo::SVGUnit::CM
15
19
  assert_equal(Cairo::SVGUnit::CM, surface.document_unit)
16
20
  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.5
4
+ version: 1.17.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-04 00:00:00.000000000 Z
11
+ date: 2022-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: native-package-installer
@@ -235,7 +235,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
235
235
  version: '0'
236
236
  requirements:
237
237
  - cairo >= 1.2.0
238
- rubygems_version: 3.3.0.dev
238
+ rubygems_version: 3.4.0.dev
239
239
  signing_key:
240
240
  specification_version: 4
241
241
  summary: Ruby bindings for cairo