cairo 1.15.7 → 1.15.8

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
  SHA1:
3
- metadata.gz: 4b195848c10f04c8b6e02ee066b56f40674d5c22
4
- data.tar.gz: 8183351ea4c31f32d4044ed4eea60258442a6c1b
3
+ metadata.gz: 2b22425c165bdcbbbd24e9cc9adf49ed2c1f4bc2
4
+ data.tar.gz: df429f0add4ae2634cfe16a76d04308de871d0fe
5
5
  SHA512:
6
- metadata.gz: 2eeb466bda32a84bd015fc083dcb07525ba643d64a13c3e5ea4dca7637f297e767ad7059dea1fce96d5ded05a086239162e1f7482e7ae969d0e50c2c2530d91a
7
- data.tar.gz: 6f8b0f47e8f4e413e19d5a5fcd09e9f24ee49fcbc147e5019916ccbf45a6b5dbff80dc68c9f0f1c57f14c3fe4eb6f7ec8b6e7a51fb3fadf3407a1c95deaac7f9
6
+ metadata.gz: be2b5ceea15d49c2162c53ec90e0f690c9d864a77e6085a35303eba82c5b34b495a9afa572c1f819d14570522d67b86bdcb6ce776e3cefbf3c8ca62358b434a8
7
+ data.tar.gz: e006f69e3e8e83a38b6ec91d7a9b0df13a69b0aa05dbe8a34cd9bf0186dbe81397a00df69a2df27de3f97e2ce6e2a98ce12fd4343e60a78f402f52eacacc5afc
data/NEWS CHANGED
@@ -1,3 +1,27 @@
1
+ Release 1.15.8 (2017-05-29) Kouhei Sutou <kou@cozmixng.org>
2
+ ===========================================================
3
+
4
+ Improvements
5
+ ------------
6
+
7
+ * Added Cairo::FreeTypeFotnFace.
8
+ [GitHub#45][Patch by Stafford Brunk]
9
+
10
+ * Windows: Supported Ruby 2.4.
11
+ [ruby-list:50525][Reported by 5.5]
12
+
13
+ * Windows: Supported MSYS2.
14
+
15
+ * Windows: Updated bundled libraries:
16
+ * zlib: 1.2.8 -> 1.2.11
17
+
18
+ Thanks
19
+ ------
20
+
21
+ * Stafford Brunk
22
+
23
+ * 5.5
24
+
1
25
  Release 1.15.7 (2017-05-01) Kouhei Sutou <kou@cozmixng.org>
2
26
  ===========================================================
3
27
 
data/Rakefile CHANGED
@@ -420,8 +420,11 @@ class ZlibBuilder
420
420
  include Rake::DSL
421
421
 
422
422
  def build(package, install_dir)
423
+ version_for_path = package.version.gsub(".", "")
424
+ dll_name = "zlib#{version_for_path}.dll"
423
425
  sh("make",
424
426
  "PREFIX=#{package.windows.build_host}-",
427
+ "SHAREDLIB=#{dll_name}",
425
428
  "-f",
426
429
  "win32/Makefile.gcc")
427
430
  include_path = install_dir + "include"
@@ -432,6 +435,7 @@ class ZlibBuilder
432
435
  "LIBRARY_PATH=#{library_path}",
433
436
  "BINARY_PATH=#{binary_path}",
434
437
  "SHARED_MODE=1",
438
+ "SHAREDLIB=#{dll_name}",
435
439
  "-f",
436
440
  "win32/Makefile.gcc",
437
441
  "install")
@@ -439,16 +443,17 @@ class ZlibBuilder
439
443
  end
440
444
 
441
445
  windows_task = WindowsTask.new(spec) do |task|
446
+ zlib_version = "1.2.11"
442
447
  task.packages = [
443
448
  {
444
449
  # We should use the same version as Ruby Installer.
445
450
  :name => "zlib",
446
- :version => "1.2.8",
447
- :download_base_url => "https://downloads.sourceforge.net/project/libpng/zlib/1.2.8",
451
+ :version => zlib_version,
452
+ :download_base_url => "https://downloads.sourceforge.net/project/libpng/zlib/#{zlib_version}",
448
453
  :compression_method => "gz",
449
454
  :windows => {
450
455
  :builder => ZlibBuilder.new,
451
- :built_file => "bin/zlib1.dll",
456
+ :built_file => "bin/zlib#{zlib_version.gsub(".", "")}.dll",
452
457
  },
453
458
  },
454
459
  {
@@ -22,6 +22,7 @@ EXPORTS
22
22
  rb_cCairo_RasterSourcePattern DATA
23
23
 
24
24
  rb_cCairo_FontFace DATA
25
+ rb_cCairo_FreeTypeFontFace DATA
25
26
  rb_cCairo_ToyFontFace DATA
26
27
  rb_cCairo_UserFontFace DATA
27
28
  rb_cCairo_UserFontFace_TextToGlyphsData DATA
@@ -61,10 +61,13 @@ unless required_pkg_config_package([package, major, minor, micro],
61
61
  :debian => "libcairo2-dev",
62
62
  :redhat => "cairo-devel",
63
63
  :homebrew => "cairo",
64
- :macports => "cairo")
64
+ :macports => "cairo",
65
+ :msys2 => "cairo")
65
66
  exit(false)
66
67
  end
67
68
 
69
+ PKGConfig.have_package("cairo-ft")
70
+
68
71
  checking_for(checking_message("Mac OS X")) do
69
72
  case RUBY_PLATFORM
70
73
  when /darwin/
@@ -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 7
76
+ #define RB_CAIRO_VERSION_MICRO 8
77
77
 
78
78
  RB_CAIRO_VAR VALUE rb_mCairo;
79
79
  RB_CAIRO_VAR VALUE rb_cCairo_Context;
@@ -96,6 +96,7 @@ RB_CAIRO_VAR VALUE rb_cCairo_RadialPattern;
96
96
  RB_CAIRO_VAR VALUE rb_cCairo_MeshPattern;
97
97
  RB_CAIRO_VAR VALUE rb_cCairo_RasterSourcePattern;
98
98
  RB_CAIRO_VAR VALUE rb_cCairo_FontFace;
99
+ RB_CAIRO_VAR VALUE rb_cCairo_FreeTypeFontFace;
99
100
  RB_CAIRO_VAR VALUE rb_cCairo_ToyFontFace;
100
101
  RB_CAIRO_VAR VALUE rb_cCairo_UserFontFace;
101
102
  RB_CAIRO_VAR VALUE rb_cCairo_UserFontFace_TextToGlyphsData;
@@ -17,10 +17,20 @@
17
17
  #include "rb_cairo_private.h"
18
18
 
19
19
  VALUE rb_cCairo_FontFace;
20
+ VALUE rb_cCairo_FreeTypeFontFace = Qnil;
20
21
  VALUE rb_cCairo_ToyFontFace = Qnil;
21
22
  VALUE rb_cCairo_UserFontFace = Qnil;
22
23
  VALUE rb_cCairo_UserFontFace_TextToGlyphsData = Qnil;
23
24
 
25
+ #ifdef CAIRO_HAS_FT_FONT
26
+ # include <cairo-ft.h>
27
+
28
+ static cairo_user_data_key_t cr_freetype_face_key;
29
+ static FT_Library cr_freetype_library;
30
+ static int cr_freetype_n_faces = 0;
31
+ static cairo_bool_t cr_freetype_finishing = CR_FALSE;
32
+ #endif
33
+
24
34
  #if CAIRO_CHECK_VERSION(1, 7, 6)
25
35
  static cairo_user_data_key_t ruby_object_key;
26
36
  static ID cr_id_call;
@@ -84,6 +94,11 @@ rb_cairo_font_face_to_ruby_object (cairo_font_face_t *face)
84
94
 
85
95
  switch (cairo_font_face_get_type (face))
86
96
  {
97
+ #ifdef CAIRO_HAS_FT_FONT
98
+ case CAIRO_FONT_TYPE_FT:
99
+ klass = rb_cCairo_FreeTypeFontFace;
100
+ break;
101
+ #endif
87
102
  #if CAIRO_CHECK_VERSION(1, 7, 6)
88
103
  case CAIRO_FONT_TYPE_TOY:
89
104
  klass = rb_cCairo_ToyFontFace;
@@ -121,6 +136,143 @@ cr_font_face_quartz_supported_p (VALUE klass)
121
136
  #endif
122
137
  }
123
138
 
139
+ static VALUE
140
+ cr_font_face_freetype_supported_p (VALUE klass)
141
+ {
142
+ #ifdef CAIRO_HAS_FT_FONT
143
+ return Qtrue;
144
+ #else
145
+ return Qfalse;
146
+ #endif
147
+ }
148
+
149
+ #ifdef CAIRO_HAS_FT_FONT
150
+ static VALUE
151
+ cr_freetype_done_library (VALUE data)
152
+ {
153
+ cr_freetype_finishing = CR_TRUE;
154
+ if (cr_freetype_n_faces == 0)
155
+ FT_Done_FreeType (cr_freetype_library);
156
+ return Qnil;
157
+ }
158
+
159
+ static void
160
+ cr_freetype_done_face (void *data)
161
+ {
162
+ FT_Face face = data;
163
+
164
+ FT_Done_Face (face);
165
+ cr_freetype_n_faces--;
166
+ if (cr_freetype_n_faces == 0 && cr_freetype_finishing)
167
+ FT_Done_FreeType (cr_freetype_library);
168
+ }
169
+
170
+ static cairo_bool_t
171
+ cr_freetype_error_detail (FT_Error error,
172
+ const char **name,
173
+ const char **message)
174
+ {
175
+ #undef __FTERRORS_H__
176
+ #define FT_STRINGIFY(v) #v
177
+ #define FT_ERRORDEF(e, v, s) {FT_STRINGIFY(e), v, s},
178
+ #define FT_ERROR_START_LIST {
179
+ #define FT_ERROR_END_LIST {NULL, 0, NULL}};
180
+ size_t i = 0;
181
+ static const struct {
182
+ const char *name;
183
+ FT_Error code;
184
+ const char *message;
185
+ } errors[] =
186
+ #include FT_ERRORS_H
187
+ for (i = 0; i < (sizeof (errors) / sizeof (errors[0])); i++)
188
+ {
189
+ if (errors[i].code == error)
190
+ {
191
+ *name = errors[i].name;
192
+ *message = errors[i].message;
193
+ return CR_TRUE;
194
+ }
195
+ }
196
+
197
+ return CR_FALSE;
198
+ }
199
+
200
+ static void
201
+ cr_freetype_error_check (FT_Error error,
202
+ const char *message,
203
+ VALUE related_object)
204
+ {
205
+ const char *name = NULL;
206
+ const char *system_message = NULL;
207
+ const char *error_class_name;
208
+ VALUE rb_eCairo_FreeTypeError;
209
+
210
+ if (error == FT_Err_Ok)
211
+ return;
212
+
213
+ cr_freetype_error_detail (error, &name, &system_message);
214
+ #if CAIRO_CHECK_VERSION(1, 15, 4)
215
+ error_class_name = "FreeTypeError";
216
+ #else
217
+ error_class_name = "Error";
218
+ #endif
219
+ rb_eCairo_FreeTypeError =
220
+ rb_const_get (rb_mCairo, rb_intern (error_class_name));
221
+ if (NIL_P (related_object))
222
+ {
223
+ rb_raise (rb_eCairo_FreeTypeError,
224
+ "%s: %s[%d]: %s",
225
+ message,
226
+ name ? name : "unknown",
227
+ error,
228
+ system_message ? system_message : "unknown");
229
+ }
230
+ else
231
+ {
232
+ rb_raise (rb_eCairo_FreeTypeError,
233
+ "%s: %s[%d]: %s: %+" PRIsVALUE,
234
+ message,
235
+ name ? name : "unknown",
236
+ error,
237
+ system_message ? system_message : "unknown",
238
+ related_object);
239
+ }
240
+ }
241
+
242
+ static VALUE
243
+ cr_freetype_font_face_initialize (VALUE self, VALUE path)
244
+ {
245
+ FT_Face freetype_face;
246
+ FT_Error error;
247
+ cairo_font_face_t *face;
248
+ cairo_status_t status;
249
+
250
+ error = FT_New_Face (cr_freetype_library,
251
+ StringValueCStr(path),
252
+ 0,
253
+ &freetype_face);
254
+ cr_freetype_error_check (error, "failed to open FreeType font", path);
255
+ cr_freetype_n_faces++;
256
+
257
+ face = cairo_ft_font_face_create_for_ft_face (freetype_face, 0);
258
+ cr_font_face_check_status (face);
259
+ status =
260
+ cairo_font_face_set_user_data (face,
261
+ &cr_freetype_face_key,
262
+ freetype_face,
263
+ (cairo_destroy_func_t) cr_freetype_done_face);
264
+ if (status != CAIRO_STATUS_SUCCESS) {
265
+ cairo_font_face_destroy (face);
266
+ FT_Done_Face (freetype_face);
267
+ rb_cairo_check_status (status);
268
+ }
269
+
270
+ DATA_PTR (self) = face;
271
+
272
+ return Qnil;
273
+ }
274
+ #endif
275
+
124
276
  #if CAIRO_CHECK_VERSION(1, 7, 6)
125
277
  static VALUE
126
278
  cr_toy_font_face_initialize (int argc, VALUE *argv, VALUE self)
@@ -664,6 +816,26 @@ Init_cairo_font (void)
664
816
 
665
817
  rb_define_singleton_method (rb_cCairo_FontFace, "quartz_supported?",
666
818
  cr_font_face_quartz_supported_p, 0);
819
+ rb_define_singleton_method (rb_cCairo_FontFace, "freetype_supported?",
820
+ cr_font_face_freetype_supported_p, 0);
821
+
822
+ #ifdef CAIRO_HAS_FT_FONT
823
+ rb_cCairo_FreeTypeFontFace =
824
+ rb_define_class_under (rb_mCairo, "FreeTypeFontFace", rb_cCairo_FontFace);
825
+
826
+ {
827
+ FT_Error error;
828
+
829
+ error = FT_Init_FreeType (&cr_freetype_library);
830
+ cr_freetype_error_check (error, "failed to initialize FreeType", Qnil);
831
+
832
+ rb_define_finalizer (rb_cCairo_FreeTypeFontFace,
833
+ rb_proc_new (cr_freetype_done_library, Qnil));
834
+ }
835
+
836
+ rb_define_method (rb_cCairo_FreeTypeFontFace, "initialize",
837
+ cr_freetype_font_face_initialize, 1);
838
+ #endif
667
839
 
668
840
  #if CAIRO_CHECK_VERSION(1, 7, 6)
669
841
  rb_cCairo_ToyFontFace =
@@ -42,4 +42,8 @@ module CairoTestUtils
42
42
  omit("Only for #{name} device available")
43
43
  end
44
44
  end
45
+
46
+ def fixture_path(*components)
47
+ File.join(__dir__, "fixture", *components)
48
+ end
45
49
  end
@@ -3,6 +3,52 @@ require 'cairo'
3
3
  class FontFaceTest < Test::Unit::TestCase
4
4
  include CairoTestUtils
5
5
 
6
+ sub_test_case("FreeTypeFontFace") do
7
+ setup do
8
+ omit("Need FreeType support") unless Cairo::FontFace.freetype_supported?
9
+ end
10
+
11
+ sub_test_case("initialize") do
12
+ test("valid") do
13
+ assert_nothing_raised do
14
+ Cairo::FreeTypeFontFace.new(fixture_path("a.otf"))
15
+ end
16
+ end
17
+
18
+ sub_test_case("invalid") do
19
+ setup do
20
+ if Cairo.const_defined?(:FreeTypeError)
21
+ @error_class = Cairo::FreeTypeError
22
+ else
23
+ @error_class = Cairo::Error
24
+ end
25
+ end
26
+
27
+ test("broken") do
28
+ path = __FILE__
29
+ message = "failed to open FreeType font: "
30
+ message << "FT_Err_Unknown_File_Format[2]: "
31
+ message << "unknown file format: "
32
+ message << path.inspect
33
+ assert_raise(@error_class.new(message)) do
34
+ Cairo::FreeTypeFontFace.new(path)
35
+ end
36
+ end
37
+
38
+ test("nonexistent") do
39
+ path = fixture_path("nonexistent.otf")
40
+ message = "failed to open FreeType font: "
41
+ message << "FT_Err_Cannot_Open_Resource[1]: "
42
+ message << "cannot open resource: "
43
+ message << path.inspect
44
+ assert_raise(@error_class.new(message)) do
45
+ Cairo::FreeTypeFontFace.new(path)
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+
6
52
  def test_toy_font_face_new
7
53
  only_cairo_version(1, 7, 2)
8
54
 
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.15.7
4
+ version: 1.15.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-01 00:00:00.000000000 Z
11
+ date: 2017-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pkg-config
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.1.5
19
+ version: 1.2.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 1.1.5
26
+ version: 1.2.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: native-package-installer
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 1.0.3
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 1.0.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement