cairo 1.17.5 → 1.17.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -119,6 +119,13 @@ class FontFaceTest < Test::Unit::TestCase
119
119
  render_glyph_args << args
120
120
  end
121
121
 
122
+ render_color_glyph_args = []
123
+ if face.respond_to?(:on_render_color_glyph)
124
+ face.on_render_color_glyph do |*args|
125
+ render_color_glyph_args << args
126
+ end
127
+ end
128
+
122
129
  text_to_glyphs_args = []
123
130
  face.on_text_to_glyphs do |*args|
124
131
  text_to_glyphs_args << args
@@ -137,36 +144,56 @@ class FontFaceTest < Test::Unit::TestCase
137
144
  Cairo::Matrix.identity,
138
145
  Cairo::Matrix.identity,
139
146
  Cairo::FontOptions.new)
140
- result = scaled_font.text_to_glyphs(0, 0, "text")
141
- assert_equal([[[Cairo::ScaledFont, Cairo::Context, Cairo::FontExtents]],
142
- [[Cairo::ScaledFont, codepoint("t"),
143
- Cairo::Context, Cairo::TextExtents],
144
- [Cairo::ScaledFont, codepoint("e"),
145
- Cairo::Context, Cairo::TextExtents],
146
- [Cairo::ScaledFont, codepoint("x"),
147
- Cairo::Context, Cairo::TextExtents]],
148
- [[Cairo::ScaledFont, "text",
149
- Cairo::UserFontFace::TextToGlyphsData]],
150
- [[Cairo::ScaledFont, codepoint("t")],
151
- [Cairo::ScaledFont, codepoint("e")],
152
- [Cairo::ScaledFont, codepoint("x")],
153
- [Cairo::ScaledFont, codepoint("t")]],
154
- [[], [], Cairo::TextClusterFlag::BACKWARD]],
155
- [classify_cairo_object(init_args),
156
- classify_cairo_object(render_glyph_args),
157
- classify_cairo_object(text_to_glyphs_args),
158
- classify_cairo_object(unicode_to_glyph_args),
159
- result])
147
+ result = scaled_font.text_to_glyphs(0, 0, "abc")
148
+ expected = {
149
+ init_args: [
150
+ [Cairo::ScaledFont, Cairo::Context, Cairo::FontExtents],
151
+ ],
152
+ render_glyph_args: [
153
+ [Cairo::ScaledFont, codepoint("a"), Cairo::Context, Cairo::TextExtents],
154
+ [Cairo::ScaledFont, codepoint("b"), Cairo::Context, Cairo::TextExtents],
155
+ [Cairo::ScaledFont, codepoint("c"), Cairo::Context, Cairo::TextExtents],
156
+ ],
157
+ render_color_glyph_args: [],
158
+ text_to_glyphs_args: [
159
+ [Cairo::ScaledFont, "abc", Cairo::UserFontFace::TextToGlyphsData],
160
+ ],
161
+ unicode_to_glyph_args: [
162
+ [Cairo::ScaledFont, codepoint("a")],
163
+ [Cairo::ScaledFont, codepoint("b")],
164
+ [Cairo::ScaledFont, codepoint("c")],
165
+ ],
166
+ result: [[], [], Cairo::TextClusterFlag::BACKWARD],
167
+ }
168
+ actual = {
169
+ init_args: classify_cairo_object(init_args),
170
+ render_glyph_args: classify_cairo_object(render_glyph_args),
171
+ render_color_glyph_args: classify_cairo_object(render_color_glyph_args),
172
+ text_to_glyphs_args: classify_cairo_object(text_to_glyphs_args),
173
+ unicode_to_glyph_args: classify_cairo_object(unicode_to_glyph_args),
174
+ result: result,
175
+ }
176
+ if Cairo.satisfied_version?(1, 17, 6)
177
+ expected[:render_glyph_args],
178
+ expected[:render_color_glyph_args] =
179
+ expected[:render_color_glyph_args],
180
+ expected[:render_glyph_args]
181
+ end
182
+ assert_equal(expected, actual)
160
183
  end
161
184
 
162
185
  if Cairo.satisfied_version?(1, 7, 2)
163
186
  class CustomUserFontFace < Cairo::UserFontFace
164
- attr_reader :init_args, :render_glyph_args
165
- attr_reader :text_to_glyphs_args, :unicode_to_glyph_args
187
+ attr_reader :init_args
188
+ attr_reader :render_glyph_args
189
+ attr_reader :render_color_glyph_args
190
+ attr_reader :text_to_glyphs_args
191
+ attr_reader :unicode_to_glyph_args
166
192
  def initialize
167
193
  super
168
194
  @init_args = []
169
195
  @render_glyph_args = []
196
+ @render_color_glyph_args = []
170
197
  @text_to_glyphs_args = []
171
198
  @unicode_to_glyph_args = []
172
199
  end
@@ -179,6 +206,10 @@ class FontFaceTest < Test::Unit::TestCase
179
206
  @render_glyph_args << args
180
207
  end
181
208
 
209
+ def render_color_glyph(*args)
210
+ @render_color_glyph_args << args
211
+ end
212
+
182
213
  def text_to_glyphs(*args)
183
214
  @text_to_glyphs_args << args
184
215
  scaled_font, utf8, data = args
@@ -202,26 +233,54 @@ class FontFaceTest < Test::Unit::TestCase
202
233
  Cairo::Matrix.identity,
203
234
  Cairo::Matrix.identity,
204
235
  Cairo::FontOptions.new)
205
- 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])
236
+ result = scaled_font.text_to_glyphs(0, 0, "abc")
237
+ expected = {
238
+ init_args: [
239
+ [Cairo::ScaledFont, Cairo::Context, Cairo::FontExtents]
240
+ ],
241
+ text_to_glyphs_args: [
242
+ [Cairo::ScaledFont, "abc", Cairo::UserFontFace::TextToGlyphsData],
243
+ ],
244
+ unicode_to_glyph_args: [
245
+ [Cairo::ScaledFont, codepoint("a")],
246
+ [Cairo::ScaledFont, codepoint("b")],
247
+ [Cairo::ScaledFont, codepoint("c")],
248
+ ],
249
+ result: [
250
+ [],
251
+ [],
252
+ Cairo::TextClusterFlag::BACKWARD,
253
+ ],
254
+ }
255
+ actual = {
256
+ init_args: classify_cairo_object(face.init_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
+ if Cairo.satisfied_version?(1, 17, 6)
264
+ expected[:render_color_glyph_args] = [
265
+ [Cairo::ScaledFont, codepoint("a"), Cairo::Context, Cairo::TextExtents],
266
+ [Cairo::ScaledFont, codepoint("b"), Cairo::Context, Cairo::TextExtents],
267
+ [Cairo::ScaledFont, codepoint("c"), Cairo::Context, Cairo::TextExtents],
268
+ ]
269
+ actual[:render_color_glyph_args] =
270
+ classify_cairo_object(face.render_color_glyph_args)
271
+ expected[:render_glyph_args] = []
272
+ actual[:render_glyph_args] =
273
+ classify_cairo_object(face.render_glyph_args)
274
+ else
275
+ expected[:render_glyph_args] = [
276
+ [Cairo::ScaledFont, codepoint("a"), Cairo::Context, Cairo::TextExtents],
277
+ [Cairo::ScaledFont, codepoint("b"), Cairo::Context, Cairo::TextExtents],
278
+ [Cairo::ScaledFont, codepoint("c"), Cairo::Context, Cairo::TextExtents],
279
+ ]
280
+ actual[:render_glyph_args] =
281
+ classify_cairo_object(face.render_glyph_args)
282
+ end
283
+ assert_equal(expected, actual)
225
284
  end
226
285
 
227
286
  def test_user_font_face_class_and_callback
@@ -239,6 +298,13 @@ class FontFaceTest < Test::Unit::TestCase
239
298
  render_glyph_args << args
240
299
  end
241
300
 
301
+ render_color_glyph_args = []
302
+ if face.respond_to?(:on_render_color_glyph)
303
+ face.on_render_color_glyph do |*args|
304
+ render_color_glyph_args << args
305
+ end
306
+ end
307
+
242
308
  text_to_glyphs_args = []
243
309
  face.on_text_to_glyphs do |*args|
244
310
  text_to_glyphs_args << args
@@ -257,34 +323,63 @@ class FontFaceTest < Test::Unit::TestCase
257
323
  Cairo::Matrix.identity,
258
324
  Cairo::Matrix.identity,
259
325
  Cairo::FontOptions.new)
260
- result = scaled_font.text_to_glyphs(0, 0, "text")
261
- assert_equal([[[Cairo::ScaledFont, Cairo::Context, Cairo::FontExtents]],
262
- [[Cairo::ScaledFont, codepoint("t"),
263
- Cairo::Context, Cairo::TextExtents],
264
- [Cairo::ScaledFont, codepoint("e"),
265
- Cairo::Context, Cairo::TextExtents],
266
- [Cairo::ScaledFont, codepoint("x"),
267
- Cairo::Context, Cairo::TextExtents]],
268
- [[Cairo::ScaledFont, "text",
269
- Cairo::UserFontFace::TextToGlyphsData]],
270
- [[Cairo::ScaledFont, codepoint("t")],
271
- [Cairo::ScaledFont, codepoint("e")],
272
- [Cairo::ScaledFont, codepoint("x")],
273
- [Cairo::ScaledFont, codepoint("t")]],
274
- [],
275
- [],
276
- [],
277
- [],
278
- [[], [], Cairo::TextClusterFlag::BACKWARD]],
279
- [classify_cairo_object(init_args),
280
- classify_cairo_object(render_glyph_args),
281
- classify_cairo_object(text_to_glyphs_args),
282
- classify_cairo_object(unicode_to_glyph_args),
283
- classify_cairo_object(face.init_args),
284
- classify_cairo_object(face.render_glyph_args),
285
- classify_cairo_object(face.text_to_glyphs_args),
286
- classify_cairo_object(face.unicode_to_glyph_args),
287
- result])
326
+ result = scaled_font.text_to_glyphs(0, 0, "abc")
327
+ expected = {
328
+ callback_init_args: [
329
+ [
330
+ Cairo::ScaledFont, Cairo::Context, Cairo::FontExtents,
331
+ ],
332
+ ],
333
+ callback_render_glyph_args: [
334
+ [Cairo::ScaledFont, codepoint("a"), Cairo::Context, Cairo::TextExtents],
335
+ [Cairo::ScaledFont, codepoint("b"), Cairo::Context, Cairo::TextExtents],
336
+ [Cairo::ScaledFont, codepoint("c"), Cairo::Context, Cairo::TextExtents],
337
+ ],
338
+ callback_render_color_glyph_args: [],
339
+ callback_text_to_glyphs_args: [
340
+ [Cairo::ScaledFont, "abc", Cairo::UserFontFace::TextToGlyphsData],
341
+ ],
342
+ callback_unicode_to_glyph_args: [
343
+ [Cairo::ScaledFont, codepoint("a")],
344
+ [Cairo::ScaledFont, codepoint("b")],
345
+ [Cairo::ScaledFont, codepoint("c")],
346
+ ],
347
+ object_init_args: [],
348
+ object_render_glyph_args: [],
349
+ object_render_color_glyph_args: [],
350
+ object_text_to_glyphs_args: [],
351
+ object_unicode_to_glyph_args: [],
352
+ result: [[], [], Cairo::TextClusterFlag::BACKWARD],
353
+ }
354
+ actual = {
355
+ callback_init_args: classify_cairo_object(init_args),
356
+ callback_render_glyph_args:
357
+ classify_cairo_object(render_glyph_args),
358
+ callback_render_color_glyph_args:
359
+ classify_cairo_object(render_color_glyph_args),
360
+ callback_text_to_glyphs_args:
361
+ classify_cairo_object(text_to_glyphs_args),
362
+ callback_unicode_to_glyph_args:
363
+ classify_cairo_object(unicode_to_glyph_args),
364
+ object_init_args:
365
+ classify_cairo_object(face.init_args),
366
+ object_render_glyph_args:
367
+ classify_cairo_object(face.render_glyph_args),
368
+ object_render_color_glyph_args:
369
+ classify_cairo_object(face.render_color_glyph_args),
370
+ object_text_to_glyphs_args:
371
+ classify_cairo_object(face.text_to_glyphs_args),
372
+ object_unicode_to_glyph_args:
373
+ classify_cairo_object(face.unicode_to_glyph_args),
374
+ result: result,
375
+ }
376
+ if Cairo.satisfied_version?(1, 17, 6)
377
+ expected[:callback_render_glyph_args],
378
+ expected[:callback_render_color_glyph_args] =
379
+ expected[:callback_render_color_glyph_args],
380
+ expected[:callback_render_glyph_args]
381
+ end
382
+ assert_equal(expected, actual)
288
383
  end
289
384
 
290
385
  def classify_cairo_object(object)
@@ -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.8
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: 2021-02-04 00:00:00.000000000 Z
11
+ date: 2022-09-01 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.3.0.dev
239
- signing_key:
238
+ rubygems_version: 3.4.0.dev
239
+ signing_key:
240
240
  specification_version: 4
241
241
  summary: Ruby bindings for cairo
242
242
  test_files: