cairo 1.17.5 → 1.17.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/NEWS +63 -0
- data/ext/cairo/rb_cairo.c +1 -1
- data/ext/cairo/rb_cairo.h +2 -2
- data/ext/cairo/rb_cairo_constants.c +12 -2
- data/ext/cairo/rb_cairo_context.c +59 -21
- data/ext/cairo/rb_cairo_device.c +24 -15
- data/ext/cairo/rb_cairo_exception.c +20 -2
- data/ext/cairo/rb_cairo_font_extents.c +21 -4
- data/ext/cairo/rb_cairo_font_face.c +85 -24
- data/ext/cairo/rb_cairo_font_options.c +27 -15
- data/ext/cairo/rb_cairo_glyph.c +16 -13
- data/ext/cairo/rb_cairo_matrix.c +18 -15
- data/ext/cairo/rb_cairo_path.c +30 -45
- data/ext/cairo/rb_cairo_pattern.c +27 -19
- data/ext/cairo/rb_cairo_quartz_surface.c +7 -2
- data/ext/cairo/rb_cairo_rectangle.c +15 -4
- data/ext/cairo/rb_cairo_region.c +22 -14
- data/ext/cairo/rb_cairo_scaled_font.c +24 -15
- data/ext/cairo/rb_cairo_surface.c +82 -32
- data/ext/cairo/rb_cairo_text_cluster.c +21 -15
- data/ext/cairo/rb_cairo_text_extents.c +21 -4
- data/test/test_context.rb +14 -0
- data/test/test_font_face.rb +165 -70
- data/test/test_quartz_image_surface.rb +5 -3
- data/test/test_svg_surface.rb +5 -1
- metadata +6 -6
data/test/test_font_face.rb
CHANGED
@@ -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, "
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
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
|
165
|
-
attr_reader :
|
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, "
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
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, "
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
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
|
-
|
10
|
-
|
11
|
-
|
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
|
data/test/test_svg_surface.rb
CHANGED
@@ -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
|
-
|
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.
|
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:
|
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.
|
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:
|