rubyquartz 0.1.2 → 0.1.3
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.
- data/COPYRIGHT +1 -1
- data/History.txt +4 -0
- data/Manifest.txt +5 -0
- data/README.txt +1 -1
- data/Rakefile +2 -2
- data/ext/bitmap.c +1 -1
- data/ext/bitmap.h +1 -1
- data/ext/bitmap_context.c +1 -1
- data/ext/bitmap_context.h +1 -1
- data/ext/color.c +1 -1
- data/ext/color.h +1 -1
- data/ext/colorspace.c +1 -1
- data/ext/colorspace.h +1 -1
- data/ext/context.c +17 -3
- data/ext/context.h +1 -1
- data/ext/extconf.rb +8 -7
- data/ext/font.c +1 -1
- data/ext/font.h +1 -1
- data/ext/function.c +1 -1
- data/ext/function.h +1 -1
- data/ext/image.c +1 -1
- data/ext/image.h +1 -1
- data/ext/image_source.c +1 -1
- data/ext/image_source.h +1 -1
- data/ext/pdf_context.c +85 -0
- data/ext/pdf_context.h +31 -0
- data/ext/pdf_document.c +1 -1
- data/ext/pdf_document.h +1 -1
- data/ext/pdf_page.c +1 -1
- data/ext/pdf_page.h +1 -1
- data/ext/point.c +1 -1
- data/ext/point.h +1 -1
- data/ext/rect.c +16 -1
- data/ext/rect.h +2 -1
- data/ext/rubyquartz.c +3 -1
- data/ext/rubyquartz.h +1 -1
- data/ext/rubyquartz_prefix.h +1 -1
- data/ext/shading.c +1 -1
- data/ext/shading.h +1 -1
- data/ext/size.c +1 -1
- data/ext/size.h +1 -1
- data/ext/text.c +1 -1
- data/ext/text.h +1 -1
- data/ext/utilities.c +8 -4
- data/ext/utilities.h +3 -1
- data/lib/rubyquartz.rb +3 -2
- data/lib/rubyquartz/bitmap.rb +1 -1
- data/lib/rubyquartz/bitmap_context.rb +1 -1
- data/lib/rubyquartz/color.rb +1 -1
- data/lib/rubyquartz/colorspace.rb +1 -1
- data/lib/rubyquartz/context.rb +1 -1
- data/lib/rubyquartz/font.rb +1 -1
- data/lib/rubyquartz/function.rb +1 -1
- data/lib/rubyquartz/image.rb +1 -1
- data/lib/rubyquartz/image_source.rb +1 -1
- data/lib/rubyquartz/pdf_context.rb +56 -0
- data/lib/rubyquartz/pdf_document.rb +1 -1
- data/lib/rubyquartz/pdf_page.rb +1 -1
- data/lib/rubyquartz/point.rb +1 -1
- data/lib/rubyquartz/rect.rb +19 -4
- data/lib/rubyquartz/shading.rb +1 -1
- data/lib/rubyquartz/size.rb +1 -1
- data/lib/rubyquartz/text.rb +1 -1
- data/test/images/TestPDFContext.test_init_with_path.pdf +0 -0
- data/test/rubyquartz_test.rb +16 -4
- data/test/tc_bitmap_context.rb +1 -1
- data/test/tc_color.rb +1 -1
- data/test/tc_context.rb +1 -1
- data/test/tc_font.rb +1 -1
- data/test/tc_image_source.rb +1 -1
- data/test/tc_pdf_context.rb +55 -0
- data/test/tc_pdf_document.rb +1 -1
- data/test/tc_pdf_page.rb +1 -1
- data/test/tc_text.rb +1 -1
- metadata +19 -9
data/COPYRIGHT
CHANGED
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
|
@@ -23,6 +23,8 @@ ext/image.c
|
|
|
23
23
|
ext/image.h
|
|
24
24
|
ext/image_source.c
|
|
25
25
|
ext/image_source.h
|
|
26
|
+
ext/pdf_context.c
|
|
27
|
+
ext/pdf_context.h
|
|
26
28
|
ext/pdf_document.c
|
|
27
29
|
ext/pdf_document.h
|
|
28
30
|
ext/pdf_page.c
|
|
@@ -52,6 +54,7 @@ lib/rubyquartz/font.rb
|
|
|
52
54
|
lib/rubyquartz/function.rb
|
|
53
55
|
lib/rubyquartz/image.rb
|
|
54
56
|
lib/rubyquartz/image_source.rb
|
|
57
|
+
lib/rubyquartz/pdf_context.rb
|
|
55
58
|
lib/rubyquartz/pdf_document.rb
|
|
56
59
|
lib/rubyquartz/pdf_page.rb
|
|
57
60
|
lib/rubyquartz/point.rb
|
|
@@ -82,6 +85,7 @@ test/images/TestContext.test_shadow.png
|
|
|
82
85
|
test/images/TestContext.test_stroke_rect.png
|
|
83
86
|
test/images/TestContext.test_text_bounds.png
|
|
84
87
|
test/images/TestContext.test_translate.png
|
|
88
|
+
test/images/TestPDFContext.test_init_with_path.pdf
|
|
85
89
|
test/inputs/circle.pdf
|
|
86
90
|
test/inputs/wash.png
|
|
87
91
|
test/rubyquartz_test.rb
|
|
@@ -90,6 +94,7 @@ test/tc_color.rb
|
|
|
90
94
|
test/tc_context.rb
|
|
91
95
|
test/tc_font.rb
|
|
92
96
|
test/tc_image_source.rb
|
|
97
|
+
test/tc_pdf_context.rb
|
|
93
98
|
test/tc_pdf_document.rb
|
|
94
99
|
test/tc_pdf_page.rb
|
|
95
100
|
test/tc_text.rb
|
data/README.txt
CHANGED
|
@@ -45,7 +45,7 @@ $ sudo make install
|
|
|
45
45
|
|
|
46
46
|
(based on the MIT License)
|
|
47
47
|
|
|
48
|
-
Copyright (c) 2006, The Omni Group, Inc. All rights reserved.
|
|
48
|
+
Copyright (c) 2006,2007, The Omni Group, Inc. All rights reserved.
|
|
49
49
|
|
|
50
50
|
OPEN PERMISSION TO USE AND REPRODUCE OMNI SOURCE CODE SOFTWARE
|
|
51
51
|
|
data/Rakefile
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright (c) 2006, The Omni Group, Inc. All rights reserved.
|
|
1
|
+
# Copyright (c) 2006,2007, The Omni Group, Inc. All rights reserved.
|
|
2
2
|
#
|
|
3
3
|
# OPEN PERMISSION TO USE AND REPRODUCE OMNI SOURCE CODE SOFTWARE
|
|
4
4
|
#
|
|
@@ -34,7 +34,7 @@ require 'rubyquartz'
|
|
|
34
34
|
Hoe.new('rubyquartz', Quartz::VERSION) do |p|
|
|
35
35
|
p.rubyforge_name = 'rubyquartz'
|
|
36
36
|
p.summary = 'Ruby Quartz is a bridge that allows Ruby programs to access the Mac OS X Quartz graphics libraries.'
|
|
37
|
-
p.description = p.paragraphs_of('README.txt', 2..
|
|
37
|
+
p.description = p.paragraphs_of('README.txt', 2..4).join("\n\n")
|
|
38
38
|
p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1].collect {|u| u.strip }
|
|
39
39
|
p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
|
|
40
40
|
p.author = "Timothy J. Wood"
|
data/ext/bitmap.c
CHANGED
data/ext/bitmap.h
CHANGED
data/ext/bitmap_context.c
CHANGED
data/ext/bitmap_context.h
CHANGED
data/ext/color.c
CHANGED
data/ext/color.h
CHANGED
data/ext/colorspace.c
CHANGED
data/ext/colorspace.h
CHANGED
data/ext/context.c
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright (c) 2006, The Omni Group, Inc. All rights reserved.
|
|
2
|
+
Copyright (c) 2006,2007, The Omni Group, Inc. All rights reserved.
|
|
3
3
|
|
|
4
4
|
OPEN PERMISSION TO USE AND REPRODUCE OMNI SOURCE CODE SOFTWARE
|
|
5
5
|
|
|
@@ -307,8 +307,19 @@ static VALUE context_draw_pdf_page(VALUE self, VALUE page_value)
|
|
|
307
307
|
// CGContextEndPage
|
|
308
308
|
// CGContextRetain
|
|
309
309
|
// CGContextRelease
|
|
310
|
-
|
|
311
|
-
|
|
310
|
+
|
|
311
|
+
static VALUE context_flush(VALUE self)
|
|
312
|
+
{
|
|
313
|
+
CGContextFlush(context_get(self));
|
|
314
|
+
return self;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
static VALUE context_synchronize(VALUE self)
|
|
318
|
+
{
|
|
319
|
+
CGContextSynchronize(context_get(self));
|
|
320
|
+
return self;
|
|
321
|
+
}
|
|
322
|
+
|
|
312
323
|
// CGContextSetShouldAntialias
|
|
313
324
|
// CGContextSetAllowsAntialiasing
|
|
314
325
|
// CGContextSetShouldSmoothFonts
|
|
@@ -387,6 +398,9 @@ void Init_context(void)
|
|
|
387
398
|
rb_define_method(context_class, "draw_shading", context_draw_shading, 1);
|
|
388
399
|
|
|
389
400
|
rb_define_method(context_class, "draw_pdf_page", context_draw_pdf_page, 1);
|
|
401
|
+
|
|
402
|
+
rb_define_method(context_class, "flush", context_flush, 0);
|
|
403
|
+
rb_define_method(context_class, "synchronize", context_synchronize, 0);
|
|
390
404
|
|
|
391
405
|
rb_define_method(context_class, "_draw_text", context_draw_text, 4);
|
|
392
406
|
}
|
data/ext/context.h
CHANGED
data/ext/extconf.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright (c) 2006, The Omni Group, Inc. All rights reserved.
|
|
1
|
+
# Copyright (c) 2006,2007, The Omni Group, Inc. All rights reserved.
|
|
2
2
|
#
|
|
3
3
|
# OPEN PERMISSION TO USE AND REPRODUCE OMNI SOURCE CODE SOFTWARE
|
|
4
4
|
#
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
# DEALINGS IN THE SOFTWARE.
|
|
25
25
|
|
|
26
26
|
require 'rbconfig'
|
|
27
|
+
|
|
27
28
|
# Xcode 2.2 moved ruby.h
|
|
28
29
|
unless File.exists? File.join(Config::CONFIG['archdir'], 'ruby.h')
|
|
29
30
|
Config::CONFIG['archdir'] = Config::CONFIG['archdir'].sub(/powerpc/, 'universal')
|
|
@@ -32,17 +33,17 @@ end
|
|
|
32
33
|
require 'mkmf'
|
|
33
34
|
|
|
34
35
|
# If your ruby is non-Universal, you can't build Univeral gems. So, we'll just build the gem for the current architecture. You can change this if you have a Universal ruby install.
|
|
35
|
-
|
|
36
|
-
$ARCH_FLAGS = '-arch ' + `arch`.chomp
|
|
36
|
+
$ARCH_FLAG = '-arch ' + `arch`.chomp
|
|
37
37
|
|
|
38
38
|
# Only export our main Init function, allowing us to use extern functions between the bundles w/o worries
|
|
39
39
|
# TODO: Does Ruby load the bundle within a private namespace anyway?
|
|
40
|
-
$CFLAGS = $
|
|
40
|
+
$CFLAGS = $ARCH_FLAG + ' -include rubyquartz_prefix.h -x objective-c -fobjc-exceptions -g -Werror -Wall -Wno-trigraphs -Wreturn-type -Wformat -Wmissing-braces -Wparentheses -Wswitch -Wunused-function -Wunused-label -Wunused-variable -Wunused-value -Wunknown-pragmas -Wsign-compare -Wnewline-eof -Wno-\#warnings'
|
|
41
41
|
|
|
42
42
|
# Pick one of these for release vs. debug
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
$CFLAGS += ' -O2 -Wuninitialized'
|
|
44
|
+
#$CFLAGS += ' -DDEBUG -O0 -fno-inline-functions'
|
|
45
45
|
|
|
46
|
-
$LDFLAGS = $
|
|
46
|
+
$LDFLAGS = $ARCH_FLAG + ' -framework Cocoa -framework ApplicationServices -framework CoreFoundation -exported_symbols_list ExportedSymbols.txt'
|
|
47
|
+
CONFIG['LDSHARED'] = 'cc ' + $ARCH_FLAG + ' -bundle'
|
|
47
48
|
|
|
48
49
|
create_makefile("rubyquartz_api")
|
data/ext/font.c
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2006, The Omni Group. All rights reserved.
|
|
2
|
+
* Copyright (c) 2006,2007, The Omni Group. All rights reserved.
|
|
3
3
|
*
|
|
4
4
|
* Redistribution and use in source and binary forms, with or without
|
|
5
5
|
* modification, are permitted provided that the following conditions
|
data/ext/font.h
CHANGED
data/ext/function.c
CHANGED
data/ext/function.h
CHANGED
data/ext/image.c
CHANGED
data/ext/image.h
CHANGED
data/ext/image_source.c
CHANGED
data/ext/image_source.h
CHANGED
data/ext/pdf_context.c
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (c) 2006,2007, The Omni Group, Inc. All rights reserved.
|
|
3
|
+
|
|
4
|
+
OPEN PERMISSION TO USE AND REPRODUCE OMNI SOURCE CODE SOFTWARE
|
|
5
|
+
|
|
6
|
+
Omni Source Code software is available from The Omni Group on their web
|
|
7
|
+
site at www.omnigroup.com.
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
|
10
|
+
copy of this software and associated documentation files (the "Software"),
|
|
11
|
+
to deal in the Software without restriction, including without limitation
|
|
12
|
+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
13
|
+
and/or sell copies of the Software, and to permit persons to whom the
|
|
14
|
+
Software is furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
Any original copyright notices and this permission notice shall be included
|
|
17
|
+
in all copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
24
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
25
|
+
DEALINGS IN THE SOFTWARE.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
#include "context.h"
|
|
29
|
+
|
|
30
|
+
#include "rect.h"
|
|
31
|
+
|
|
32
|
+
const char *PDFContextClassName = "PDFContext";
|
|
33
|
+
|
|
34
|
+
VALUE pdf_context_class;
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
CGContextRef pdf_context_get(VALUE self)
|
|
38
|
+
{
|
|
39
|
+
// CGPDFContextRef doesn't have its own CFTypeID.
|
|
40
|
+
// TODO: Subclassability?
|
|
41
|
+
if (CLASS_OF(self) != pdf_context_class)
|
|
42
|
+
rb_raise(rb_eArgError, "Argument must be a PDFContext");
|
|
43
|
+
|
|
44
|
+
return context_get(self);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
static VALUE pdf_context_initialize_with_path(VALUE self, VALUE path, VALUE media_box_value)
|
|
48
|
+
{
|
|
49
|
+
CGContextRef *ctx;
|
|
50
|
+
Data_Get_Struct(self, CGContextRef, ctx);
|
|
51
|
+
if (!ctx)
|
|
52
|
+
rb_raise(rb_eException, "Context not initialized correctly");
|
|
53
|
+
|
|
54
|
+
CGRect mediaBox = rect_from_rect_value(media_box_value);
|
|
55
|
+
CFURLRef url = _create_url_for_path(path);
|
|
56
|
+
CFDictionaryRef auxiliaryInfo = NULL;
|
|
57
|
+
|
|
58
|
+
*ctx = CGPDFContextCreateWithURL(url, &mediaBox, auxiliaryInfo);
|
|
59
|
+
return self;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// TODO: Trying to draw into a PDF context w/o a current page can crash. We should catch this and raise instead.
|
|
63
|
+
static VALUE pdf_context_begin_page(VALUE self)
|
|
64
|
+
{
|
|
65
|
+
CGContextRef ctx = pdf_context_get(self);
|
|
66
|
+
CFDictionaryRef pageInfo = NULL;
|
|
67
|
+
CGPDFContextBeginPage(ctx, pageInfo);
|
|
68
|
+
return self;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
static VALUE pdf_context_end_page(VALUE self)
|
|
72
|
+
{
|
|
73
|
+
CGContextRef ctx = pdf_context_get(self);
|
|
74
|
+
CGPDFContextEndPage(ctx);
|
|
75
|
+
return self;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
void Init_pdf_context()
|
|
79
|
+
{
|
|
80
|
+
pdf_context_class = rb_define_class_under(module, PDFContextClassName, context_class);
|
|
81
|
+
rb_define_private_method(pdf_context_class, "_initialize_with_path", pdf_context_initialize_with_path, 2);
|
|
82
|
+
|
|
83
|
+
rb_define_method(pdf_context_class, "begin_page", pdf_context_begin_page, 0);
|
|
84
|
+
rb_define_method(pdf_context_class, "end_page", pdf_context_end_page, 0);
|
|
85
|
+
}
|
data/ext/pdf_context.h
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (c) 2006,2007, The Omni Group, Inc. All rights reserved.
|
|
3
|
+
|
|
4
|
+
OPEN PERMISSION TO USE AND REPRODUCE OMNI SOURCE CODE SOFTWARE
|
|
5
|
+
|
|
6
|
+
Omni Source Code software is available from The Omni Group on their web
|
|
7
|
+
site at www.omnigroup.com.
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
|
10
|
+
copy of this software and associated documentation files (the "Software"),
|
|
11
|
+
to deal in the Software without restriction, including without limitation
|
|
12
|
+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
13
|
+
and/or sell copies of the Software, and to permit persons to whom the
|
|
14
|
+
Software is furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
Any original copyright notices and this permission notice shall be included
|
|
17
|
+
in all copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
24
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
25
|
+
DEALINGS IN THE SOFTWARE.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
extern void Init_pdf_context(void);
|
|
29
|
+
extern VALUE pdf_context_class;
|
|
30
|
+
|
|
31
|
+
extern CGContextRef pdf_context_get(VALUE self);
|
data/ext/pdf_document.c
CHANGED
data/ext/pdf_document.h
CHANGED
data/ext/pdf_page.c
CHANGED
data/ext/pdf_page.h
CHANGED
data/ext/point.c
CHANGED
data/ext/point.h
CHANGED
data/ext/rect.c
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright (c) 2006, The Omni Group, Inc. All rights reserved.
|
|
2
|
+
Copyright (c) 2006,2007, The Omni Group, Inc. All rights reserved.
|
|
3
3
|
|
|
4
4
|
OPEN PERMISSION TO USE AND REPRODUCE OMNI SOURCE CODE SOFTWARE
|
|
5
5
|
|
|
@@ -33,13 +33,28 @@ DEALINGS IN THE SOFTWARE.
|
|
|
33
33
|
|
|
34
34
|
VALUE rect_class;
|
|
35
35
|
|
|
36
|
+
static ID id_min_x;
|
|
37
|
+
static ID id_min_y;
|
|
38
|
+
static ID id_width;
|
|
39
|
+
static ID id_height;
|
|
40
|
+
|
|
36
41
|
VALUE rect_value_from_rect(CGRect rect)
|
|
37
42
|
{
|
|
38
43
|
VALUE origin_size[2] = {point_value_from_point(rect.origin), size_value_from_size(rect.size)};
|
|
39
44
|
return rb_class_new_instance(2, origin_size, rect_class);
|
|
40
45
|
}
|
|
41
46
|
|
|
47
|
+
CGRect rect_from_rect_value(VALUE rect_value)
|
|
48
|
+
{
|
|
49
|
+
return CGRectMake(_value_get_double_attr(rect_value, id_min_x), _value_get_double_attr(rect_value, id_min_y), _value_get_double_attr(rect_value, id_width), _value_get_double_attr(rect_value, id_height));
|
|
50
|
+
}
|
|
51
|
+
|
|
42
52
|
void Init_rect(void)
|
|
43
53
|
{
|
|
44
54
|
rect_class = rb_define_class_under(module, "Rect", rb_cObject);
|
|
55
|
+
|
|
56
|
+
id_min_x = rb_intern("min_x");
|
|
57
|
+
id_min_y = rb_intern("min_y");
|
|
58
|
+
id_width = rb_intern("width");
|
|
59
|
+
id_height = rb_intern("height");
|
|
45
60
|
}
|
data/ext/rect.h
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright (c) 2006, The Omni Group, Inc. All rights reserved.
|
|
2
|
+
Copyright (c) 2006,2007, The Omni Group, Inc. All rights reserved.
|
|
3
3
|
|
|
4
4
|
OPEN PERMISSION TO USE AND REPRODUCE OMNI SOURCE CODE SOFTWARE
|
|
5
5
|
|
|
@@ -30,3 +30,4 @@ extern void Init_rect(void);
|
|
|
30
30
|
extern VALUE rect_class;
|
|
31
31
|
|
|
32
32
|
extern VALUE rect_value_from_rect(CGRect rect);
|
|
33
|
+
extern CGRect rect_from_rect_value(VALUE rect_value);
|
data/ext/rubyquartz.c
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright (c) 2006, The Omni Group, Inc. All rights reserved.
|
|
2
|
+
Copyright (c) 2006,2007, The Omni Group, Inc. All rights reserved.
|
|
3
3
|
|
|
4
4
|
OPEN PERMISSION TO USE AND REPRODUCE OMNI SOURCE CODE SOFTWARE
|
|
5
5
|
|
|
@@ -41,6 +41,7 @@ DEALINGS IN THE SOFTWARE.
|
|
|
41
41
|
#include "image_source.h"
|
|
42
42
|
#include "pdf_document.h"
|
|
43
43
|
#include "pdf_page.h"
|
|
44
|
+
#include "pdf_context.h"
|
|
44
45
|
|
|
45
46
|
VALUE module;
|
|
46
47
|
|
|
@@ -77,4 +78,5 @@ void Init_rubyquartz_api()
|
|
|
77
78
|
Init_image_source();
|
|
78
79
|
Init_pdf_document();
|
|
79
80
|
Init_pdf_page();
|
|
81
|
+
Init_pdf_context();
|
|
80
82
|
}
|
data/ext/rubyquartz.h
CHANGED
data/ext/rubyquartz_prefix.h
CHANGED
data/ext/shading.c
CHANGED
data/ext/shading.h
CHANGED
data/ext/size.c
CHANGED
data/ext/size.h
CHANGED
data/ext/text.c
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2006, The Omni Group. All rights reserved.
|
|
2
|
+
* Copyright (c) 2006,2007, The Omni Group. All rights reserved.
|
|
3
3
|
*
|
|
4
4
|
* Redistribution and use in source and binary forms, with or without
|
|
5
5
|
* modification, are permitted provided that the following conditions
|
data/ext/text.h
CHANGED
data/ext/utilities.c
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright (c) 2006, The Omni Group, Inc. All rights reserved.
|
|
2
|
+
Copyright (c) 2006,2007, The Omni Group, Inc. All rights reserved.
|
|
3
3
|
|
|
4
4
|
OPEN PERMISSION TO USE AND REPRODUCE OMNI SOURCE CODE SOFTWARE
|
|
5
5
|
|
|
@@ -31,6 +31,10 @@ DEALINGS IN THE SOFTWARE.
|
|
|
31
31
|
#import <Foundation/NSObject.h>
|
|
32
32
|
#import <objc/objc-runtime.h>
|
|
33
33
|
|
|
34
|
+
#if !defined(MAC_OS_X_VERSION_10_5) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
|
|
35
|
+
static inline const char *class_getName(Class cls) { return cls->name; }
|
|
36
|
+
#endif
|
|
37
|
+
|
|
34
38
|
VALUE _symbol_for_string(CFStringRef str)
|
|
35
39
|
{
|
|
36
40
|
CFDataRef utf8 = CFStringCreateExternalRepresentation(kCFAllocatorDefault, str, kCFStringEncodingUTF8, '?');
|
|
@@ -155,17 +159,17 @@ id _objc_type_get(VALUE self, Class cls)
|
|
|
155
159
|
|
|
156
160
|
id result = *obj;
|
|
157
161
|
if (!result)
|
|
158
|
-
rb_raise(rb_eArgError, "No %s wrapped in %s", cls
|
|
162
|
+
rb_raise(rb_eArgError, "No %s wrapped in %s", class_getName(cls), rb_obj_classname(self));
|
|
159
163
|
|
|
160
164
|
if (![result isKindOfClass:cls])
|
|
161
|
-
rb_raise(rb_eArgError, "%s is wrapping something other than a %s", rb_obj_classname(self), cls
|
|
165
|
+
rb_raise(rb_eArgError, "%s is wrapping something other than a %s", rb_obj_classname(self), class_getName(cls));
|
|
162
166
|
return result;
|
|
163
167
|
}
|
|
164
168
|
|
|
165
169
|
void _objc_type_set(VALUE self, Class cls, id value)
|
|
166
170
|
{
|
|
167
171
|
if (value && ![value isKindOfClass:cls])
|
|
168
|
-
rb_raise(rb_eArgError, "Attempt to set a non-%s value on a %s", cls
|
|
172
|
+
rb_raise(rb_eArgError, "Attempt to set a non-%s value on a %s", class_getName(cls), rb_obj_classname(self));
|
|
169
173
|
|
|
170
174
|
id *obj;
|
|
171
175
|
Data_Get_Struct(self, id, obj);
|
data/ext/utilities.h
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright (c) 2006, The Omni Group, Inc. All rights reserved.
|
|
2
|
+
Copyright (c) 2006,2007, The Omni Group, Inc. All rights reserved.
|
|
3
3
|
|
|
4
4
|
OPEN PERMISSION TO USE AND REPRODUCE OMNI SOURCE CODE SOFTWARE
|
|
5
5
|
|
|
@@ -41,3 +41,5 @@ extern void _cftype_set(VALUE self, CFTypeID typeID, const char *typeName, CFTyp
|
|
|
41
41
|
|
|
42
42
|
extern id _objc_type_get(VALUE self, Class cls);
|
|
43
43
|
extern void _objc_type_set(VALUE self, Class cls, id value);
|
|
44
|
+
|
|
45
|
+
#define _value_get_double_attr(self, attr) (NUM2DBL(rb_funcall((self), (attr), 0)))
|
data/lib/rubyquartz.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright (c) 2006, The Omni Group, Inc. All rights reserved.
|
|
1
|
+
# Copyright (c) 2006,2007, The Omni Group, Inc. All rights reserved.
|
|
2
2
|
#
|
|
3
3
|
# OPEN PERMISSION TO USE AND REPRODUCE OMNI SOURCE CODE SOFTWARE
|
|
4
4
|
#
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
# DEALINGS IN THE SOFTWARE.
|
|
25
25
|
|
|
26
26
|
module Quartz
|
|
27
|
-
VERSION = '0.1.
|
|
27
|
+
VERSION = '0.1.3'
|
|
28
28
|
|
|
29
29
|
public
|
|
30
30
|
def self.check_memory
|
|
@@ -57,3 +57,4 @@ require 'rubyquartz/shading'
|
|
|
57
57
|
require 'rubyquartz/image_source'
|
|
58
58
|
require 'rubyquartz/pdf_document'
|
|
59
59
|
require 'rubyquartz/pdf_page'
|
|
60
|
+
require 'rubyquartz/pdf_context'
|
data/lib/rubyquartz/bitmap.rb
CHANGED
data/lib/rubyquartz/color.rb
CHANGED
data/lib/rubyquartz/context.rb
CHANGED
data/lib/rubyquartz/font.rb
CHANGED
data/lib/rubyquartz/function.rb
CHANGED
data/lib/rubyquartz/image.rb
CHANGED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Copyright (c) 2006,2007, The Omni Group, Inc. All rights reserved.
|
|
2
|
+
#
|
|
3
|
+
# OPEN PERMISSION TO USE AND REPRODUCE OMNI SOURCE CODE SOFTWARE
|
|
4
|
+
#
|
|
5
|
+
# Omni Source Code software is available from The Omni Group on their web
|
|
6
|
+
# site at www.omnigroup.com.
|
|
7
|
+
#
|
|
8
|
+
# Permission is hereby granted, free of charge, to any person obtaining a
|
|
9
|
+
# copy of this software and associated documentation files (the "Software"),
|
|
10
|
+
# to deal in the Software without restriction, including without limitation
|
|
11
|
+
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
12
|
+
# and/or sell copies of the Software, and to permit persons to whom the
|
|
13
|
+
# Software is furnished to do so, subject to the following conditions:
|
|
14
|
+
#
|
|
15
|
+
# Any original copyright notices and this permission notice shall be included
|
|
16
|
+
# in all copies or substantial portions of the Software.
|
|
17
|
+
#
|
|
18
|
+
# THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
23
|
+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
24
|
+
# DEALINGS IN THE SOFTWARE.
|
|
25
|
+
|
|
26
|
+
module Quartz
|
|
27
|
+
class PDFContext
|
|
28
|
+
|
|
29
|
+
def initialize(options={})
|
|
30
|
+
super()
|
|
31
|
+
|
|
32
|
+
path = options[:path]
|
|
33
|
+
if path
|
|
34
|
+
box = options[:media] || Rect.new(0, 0, 100, 100)
|
|
35
|
+
_initialize_with_path(path, box)
|
|
36
|
+
return
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
raise "Cannot determine how to create PDFContext from given options"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def page
|
|
44
|
+
begin_page
|
|
45
|
+
success = true
|
|
46
|
+
begin
|
|
47
|
+
yield self
|
|
48
|
+
ensure
|
|
49
|
+
end_page
|
|
50
|
+
success = false
|
|
51
|
+
end
|
|
52
|
+
success
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
end
|
|
56
|
+
end
|
data/lib/rubyquartz/pdf_page.rb
CHANGED
data/lib/rubyquartz/point.rb
CHANGED
data/lib/rubyquartz/rect.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright (c) 2006, The Omni Group, Inc. All rights reserved.
|
|
1
|
+
# Copyright (c) 2006,2007, The Omni Group, Inc. All rights reserved.
|
|
2
2
|
#
|
|
3
3
|
# OPEN PERMISSION TO USE AND REPRODUCE OMNI SOURCE CODE SOFTWARE
|
|
4
4
|
#
|
|
@@ -27,9 +27,17 @@ module Quartz
|
|
|
27
27
|
class Rect
|
|
28
28
|
attr_accessor :origin, :size
|
|
29
29
|
|
|
30
|
-
def initialize(
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
def initialize(*args)
|
|
31
|
+
case args.size
|
|
32
|
+
when 2:
|
|
33
|
+
@origin = Point.new(args[0].x.to_f, args[0].y.to_f)
|
|
34
|
+
@size = Size.new(args[1].width.to_f, args[1].height.to_f)
|
|
35
|
+
when 4:
|
|
36
|
+
@origin = Point.new(args[0].to_f, args[1].to_f)
|
|
37
|
+
@size = Size.new(args[2].to_f, args[3].to_f)
|
|
38
|
+
else
|
|
39
|
+
raise "Wrong number of arguments; must supply 2 or 4 arguments."
|
|
40
|
+
end
|
|
33
41
|
end
|
|
34
42
|
|
|
35
43
|
def inset(dx, dy)
|
|
@@ -63,6 +71,13 @@ module Quartz
|
|
|
63
71
|
@origin.y + @size.height / 2.0
|
|
64
72
|
end
|
|
65
73
|
|
|
74
|
+
def width
|
|
75
|
+
@size.width
|
|
76
|
+
end
|
|
77
|
+
def height
|
|
78
|
+
@size.height
|
|
79
|
+
end
|
|
80
|
+
|
|
66
81
|
def cut(edge, amount)
|
|
67
82
|
origin = @origin.dup
|
|
68
83
|
size = @size.dup
|
data/lib/rubyquartz/shading.rb
CHANGED
data/lib/rubyquartz/size.rb
CHANGED
data/lib/rubyquartz/text.rb
CHANGED
|
Binary file
|
data/test/rubyquartz_test.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright (c) 2006, The Omni Group, Inc. All rights reserved.
|
|
1
|
+
# Copyright (c) 2006,2007, The Omni Group, Inc. All rights reserved.
|
|
2
2
|
#
|
|
3
3
|
# OPEN PERMISSION TO USE AND REPRODUCE OMNI SOURCE CODE SOFTWARE
|
|
4
4
|
#
|
|
@@ -33,12 +33,24 @@ module TestQuartz
|
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
# For now we just to byte-to-byte comparisons of the images
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
|
|
37
|
+
def image_type
|
|
38
|
+
"png"
|
|
39
|
+
end
|
|
40
|
+
def image_name
|
|
41
|
+
"#{self.class.name}.#{method_name}.#{image_type}"
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def archive_image(ctx, path)
|
|
38
45
|
current_img = ctx.copy_image
|
|
46
|
+
current_img.write_png_to_file(path)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def assert_image_equal(ctx)
|
|
39
50
|
current_image_path = "/tmp/#{image_name}"
|
|
40
|
-
current_img.write_png_to_file(current_image_path)
|
|
41
51
|
expected_image_path = "test/images/#{image_name}"
|
|
52
|
+
|
|
53
|
+
archive_image(ctx, current_image_path)
|
|
42
54
|
|
|
43
55
|
output = `cmp '#{current_image_path}' '#{expected_image_path}' 2>&1`
|
|
44
56
|
if $? != 0
|
data/test/tc_bitmap_context.rb
CHANGED
data/test/tc_color.rb
CHANGED
data/test/tc_context.rb
CHANGED
data/test/tc_font.rb
CHANGED
data/test/tc_image_source.rb
CHANGED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Copyright (c) 2006,2007, The Omni Group, Inc. All rights reserved.
|
|
2
|
+
#
|
|
3
|
+
# OPEN PERMISSION TO USE AND REPRODUCE OMNI SOURCE CODE SOFTWARE
|
|
4
|
+
#
|
|
5
|
+
# Omni Source Code software is available from The Omni Group on their web
|
|
6
|
+
# site at www.omnigroup.com.
|
|
7
|
+
#
|
|
8
|
+
# Permission is hereby granted, free of charge, to any person obtaining a
|
|
9
|
+
# copy of this software and associated documentation files (the "Software"),
|
|
10
|
+
# to deal in the Software without restriction, including without limitation
|
|
11
|
+
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
12
|
+
# and/or sell copies of the Software, and to permit persons to whom the
|
|
13
|
+
# Software is furnished to do so, subject to the following conditions:
|
|
14
|
+
#
|
|
15
|
+
# Any original copyright notices and this permission notice shall be included
|
|
16
|
+
# in all copies or substantial portions of the Software.
|
|
17
|
+
#
|
|
18
|
+
# THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
23
|
+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
24
|
+
# DEALINGS IN THE SOFTWARE.
|
|
25
|
+
|
|
26
|
+
require 'rubyquartz_test'
|
|
27
|
+
include Quartz
|
|
28
|
+
|
|
29
|
+
class TestPDFContext < TestQuartz::TestCase
|
|
30
|
+
|
|
31
|
+
def setup
|
|
32
|
+
super
|
|
33
|
+
@rgb = ColorSpace.new(:name => ColorSpace::GENERIC_RGB)
|
|
34
|
+
@output_path = "/tmp/#{self.class.name}.#{method_name}.pdf"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def test_init_with_path
|
|
38
|
+
ctx = PDFContext.new(:path => @output_path)
|
|
39
|
+
ctx.page {|c|
|
|
40
|
+
c.stroke_color = Color.new(@rgb, 0, 1, 0, 1)
|
|
41
|
+
c.stroke_rect(10.5, 10.5, 80, 80)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
assert_image_equal(ctx)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Override test helpers
|
|
48
|
+
def image_type
|
|
49
|
+
"pdf"
|
|
50
|
+
end
|
|
51
|
+
def archive_image(ctx, path)
|
|
52
|
+
# Nothing to do here if we are writing to a file
|
|
53
|
+
# TODO: Handle the case of a data consumer when we support that at all
|
|
54
|
+
end
|
|
55
|
+
end
|
data/test/tc_pdf_document.rb
CHANGED
data/test/tc_pdf_page.rb
CHANGED
data/test/tc_text.rb
CHANGED
metadata
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
|
-
rubygems_version: 0.9.
|
|
2
|
+
rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
|
4
4
|
name: rubyquartz
|
|
5
5
|
version: !ruby/object:Gem::Version
|
|
6
|
-
version: 0.1.
|
|
7
|
-
date:
|
|
6
|
+
version: 0.1.3
|
|
7
|
+
date: 2007-10-28 00:00:00 -07:00
|
|
8
8
|
summary: Ruby Quartz is a bridge that allows Ruby programs to access the Mac OS X Quartz graphics libraries.
|
|
9
9
|
require_paths:
|
|
10
10
|
- lib
|
|
@@ -12,7 +12,7 @@ require_paths:
|
|
|
12
12
|
email: tjw@omnigroup.com
|
|
13
13
|
homepage: http://rubyquartz.rubyforge.org/
|
|
14
14
|
rubyforge_project: rubyquartz
|
|
15
|
-
description: "Ruby Quartz is a bridge that allows Ruby programs to access the Mac OS X Quartz graphics libraries. Ruby Quartz is licensied under a BSD license, see the COPYRIGHT file for more information. More information on the project home page: http://rubyquartz.rubyforge.org.
|
|
15
|
+
description: "Ruby Quartz is a bridge that allows Ruby programs to access the Mac OS X Quartz graphics libraries. Ruby Quartz is licensied under a BSD license, see the COPYRIGHT file for more information. More information on the project home page: http://rubyquartz.rubyforge.org."
|
|
16
16
|
autorequire:
|
|
17
17
|
default_executable:
|
|
18
18
|
bindir: bin
|
|
@@ -55,6 +55,8 @@ files:
|
|
|
55
55
|
- ext/image.h
|
|
56
56
|
- ext/image_source.c
|
|
57
57
|
- ext/image_source.h
|
|
58
|
+
- ext/pdf_context.c
|
|
59
|
+
- ext/pdf_context.h
|
|
58
60
|
- ext/pdf_document.c
|
|
59
61
|
- ext/pdf_document.h
|
|
60
62
|
- ext/pdf_page.c
|
|
@@ -84,6 +86,7 @@ files:
|
|
|
84
86
|
- lib/rubyquartz/function.rb
|
|
85
87
|
- lib/rubyquartz/image.rb
|
|
86
88
|
- lib/rubyquartz/image_source.rb
|
|
89
|
+
- lib/rubyquartz/pdf_context.rb
|
|
87
90
|
- lib/rubyquartz/pdf_document.rb
|
|
88
91
|
- lib/rubyquartz/pdf_page.rb
|
|
89
92
|
- lib/rubyquartz/point.rb
|
|
@@ -114,6 +117,7 @@ files:
|
|
|
114
117
|
- test/images/TestContext.test_stroke_rect.png
|
|
115
118
|
- test/images/TestContext.test_text_bounds.png
|
|
116
119
|
- test/images/TestContext.test_translate.png
|
|
120
|
+
- test/images/TestPDFContext.test_init_with_path.pdf
|
|
117
121
|
- test/inputs/circle.pdf
|
|
118
122
|
- test/inputs/wash.png
|
|
119
123
|
- test/rubyquartz_test.rb
|
|
@@ -122,6 +126,7 @@ files:
|
|
|
122
126
|
- test/tc_context.rb
|
|
123
127
|
- test/tc_font.rb
|
|
124
128
|
- test/tc_image_source.rb
|
|
129
|
+
- test/tc_pdf_context.rb
|
|
125
130
|
- test/tc_pdf_document.rb
|
|
126
131
|
- test/tc_pdf_page.rb
|
|
127
132
|
- test/tc_text.rb
|
|
@@ -131,13 +136,18 @@ test_files:
|
|
|
131
136
|
- test/tc_context.rb
|
|
132
137
|
- test/tc_font.rb
|
|
133
138
|
- test/tc_image_source.rb
|
|
139
|
+
- test/tc_pdf_context.rb
|
|
134
140
|
- test/tc_pdf_document.rb
|
|
135
141
|
- test/tc_pdf_page.rb
|
|
136
142
|
- test/tc_text.rb
|
|
137
|
-
rdoc_options:
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
143
|
+
rdoc_options:
|
|
144
|
+
- --main
|
|
145
|
+
- README.txt
|
|
146
|
+
extra_rdoc_files:
|
|
147
|
+
- History.txt
|
|
148
|
+
- Manifest.txt
|
|
149
|
+
- README.txt
|
|
150
|
+
- ext/ExportedSymbols.txt
|
|
141
151
|
executables: []
|
|
142
152
|
|
|
143
153
|
extensions:
|
|
@@ -152,5 +162,5 @@ dependencies:
|
|
|
152
162
|
requirements:
|
|
153
163
|
- - ">="
|
|
154
164
|
- !ruby/object:Gem::Version
|
|
155
|
-
version: 1.
|
|
165
|
+
version: 1.3.0
|
|
156
166
|
version:
|