cairo 1.8.3-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of cairo might be problematic. Click here for more details.
- data/AUTHORS +4 -0
- data/COPYING +59 -0
- data/GPL +340 -0
- data/NEWS +163 -0
- data/Rakefile +190 -0
- data/doc/doc.css +91 -0
- data/doc/en/cairo-antialias.html +38 -0
- data/doc/en/cairo-clip-not-representable-error.html +47 -0
- data/doc/en/cairo-color-base.html +69 -0
- data/doc/en/cairo-color-cmyk.html +157 -0
- data/doc/en/cairo-color-hsv.html +137 -0
- data/doc/en/cairo-color-rgb.html +142 -0
- data/doc/en/cairo-color-x11.html +173 -0
- data/doc/en/cairo-color.html +238 -0
- data/doc/en/cairo-content.html +37 -0
- data/doc/en/cairo-context-blur.html +39 -0
- data/doc/en/cairo-context-circle.html +39 -0
- data/doc/en/cairo-context-color.html +39 -0
- data/doc/en/cairo-context-path.html +44 -0
- data/doc/en/cairo-context-rectangle.html +39 -0
- data/doc/en/cairo-context-triangle.html +39 -0
- data/doc/en/cairo-context.html +643 -0
- data/doc/en/cairo-error.html +44 -0
- data/doc/en/cairo-extend.html +38 -0
- data/doc/en/cairo-file-not-found.html +47 -0
- data/doc/en/cairo-fill-rule.html +36 -0
- data/doc/en/cairo-filter.html +40 -0
- data/doc/en/cairo-font-extents.html +129 -0
- data/doc/en/cairo-font-face.html +38 -0
- data/doc/en/cairo-font-options.html +139 -0
- data/doc/en/cairo-font-slant.html +37 -0
- data/doc/en/cairo-font-type-mismatch.html +47 -0
- data/doc/en/cairo-font-weight.html +36 -0
- data/doc/en/cairo-format.html +46 -0
- data/doc/en/cairo-glyph.html +99 -0
- data/doc/en/cairo-gradient-pattern.html +74 -0
- data/doc/en/cairo-hint-metrics.html +37 -0
- data/doc/en/cairo-hint-style.html +39 -0
- data/doc/en/cairo-image-surface.html +82 -0
- data/doc/en/cairo-invalid-clusters.html +47 -0
- data/doc/en/cairo-invalid-content-error.html +47 -0
- data/doc/en/cairo-invalid-dash-error.html +47 -0
- data/doc/en/cairo-invalid-dsc-comment-error.html +47 -0
- data/doc/en/cairo-invalid-format-error.html +47 -0
- data/doc/en/cairo-invalid-index-error.html +47 -0
- data/doc/en/cairo-invalid-matrix-error.html +47 -0
- data/doc/en/cairo-invalid-path-data-error.html +47 -0
- data/doc/en/cairo-invalid-pop-group-error.html +47 -0
- data/doc/en/cairo-invalid-restore-error.html +47 -0
- data/doc/en/cairo-invalid-slant.html +47 -0
- data/doc/en/cairo-invalid-status-error.html +47 -0
- data/doc/en/cairo-invalid-stride-error.html +47 -0
- data/doc/en/cairo-invalid-string-error.html +47 -0
- data/doc/en/cairo-invalid-visual-error.html +47 -0
- data/doc/en/cairo-invalid-weight.html +47 -0
- data/doc/en/cairo-line-cap.html +37 -0
- data/doc/en/cairo-line-join.html +37 -0
- data/doc/en/cairo-linear-pattern.html +60 -0
- data/doc/en/cairo-matrix.html +259 -0
- data/doc/en/cairo-negative-count.html +47 -0
- data/doc/en/cairo-no-current-point-error.html +47 -0
- data/doc/en/cairo-null-pointer-error.html +47 -0
- data/doc/en/cairo-operator.html +48 -0
- data/doc/en/cairo-paper-parse-error.html +47 -0
- data/doc/en/cairo-paper-unknown-paper-name.html +66 -0
- data/doc/en/cairo-paper-unknown-unit.html +66 -0
- data/doc/en/cairo-paper-unrecognized-paper-description.html +66 -0
- data/doc/en/cairo-paper.html +184 -0
- data/doc/en/cairo-path-close-path.html +49 -0
- data/doc/en/cairo-path-curve-to.html +49 -0
- data/doc/en/cairo-path-data-type.html +38 -0
- data/doc/en/cairo-path-data.html +98 -0
- data/doc/en/cairo-path-line-to.html +49 -0
- data/doc/en/cairo-path-move-to.html +49 -0
- data/doc/en/cairo-path.html +155 -0
- data/doc/en/cairo-pattern-type-mismatch-error.html +47 -0
- data/doc/en/cairo-pattern.html +99 -0
- data/doc/en/cairo-pdf-surface.html +57 -0
- data/doc/en/cairo-point.html +74 -0
- data/doc/en/cairo-ps-level.html +49 -0
- data/doc/en/cairo-ps-surface.html +92 -0
- data/doc/en/cairo-quartz-image-surface.html +57 -0
- data/doc/en/cairo-quartz-surface.html +57 -0
- data/doc/en/cairo-radial-pattern.html +60 -0
- data/doc/en/cairo-read-error.html +47 -0
- data/doc/en/cairo-rectangle.html +89 -0
- data/doc/en/cairo-scaled-font.html +94 -0
- data/doc/en/cairo-solid-pattern.html +62 -0
- data/doc/en/cairo-subpixel-order.html +39 -0
- data/doc/en/cairo-surface-finished-error.html +47 -0
- data/doc/en/cairo-surface-pattern.html +57 -0
- data/doc/en/cairo-surface-type-mismatch-error.html +47 -0
- data/doc/en/cairo-surface.html +121 -0
- data/doc/en/cairo-svg-surface.html +77 -0
- data/doc/en/cairo-svg-version.html +49 -0
- data/doc/en/cairo-temp-file-error.html +47 -0
- data/doc/en/cairo-text-cluster-flag.html +35 -0
- data/doc/en/cairo-text-cluster.html +84 -0
- data/doc/en/cairo-text-extents.html +144 -0
- data/doc/en/cairo-toy-font-face.html +67 -0
- data/doc/en/cairo-user-font-error.html +47 -0
- data/doc/en/cairo-user-font-face-text-to-glyphs-data.html +94 -0
- data/doc/en/cairo-user-font-face.html +72 -0
- data/doc/en/cairo-user-font-immutable.html +47 -0
- data/doc/en/cairo-win32-printing-surface.html +57 -0
- data/doc/en/cairo-win32-surface.html +62 -0
- data/doc/en/cairo-write-error.html +47 -0
- data/doc/en/cairo.html +131 -0
- data/doc/en/index.html +1154 -0
- data/doc/index.html +18 -0
- data/doc/ja/cairo-antialias.html +57 -0
- data/doc/ja/cairo-clip-not-representable-error.html +56 -0
- data/doc/ja/cairo-color-base.html +75 -0
- data/doc/ja/cairo-color-cmyk.html +152 -0
- data/doc/ja/cairo-color-hsv.html +135 -0
- data/doc/ja/cairo-color-rgb.html +145 -0
- data/doc/ja/cairo-color-x11.html +183 -0
- data/doc/ja/cairo-color.html +317 -0
- data/doc/ja/cairo-content.html +51 -0
- data/doc/ja/cairo-context-blur.html +53 -0
- data/doc/ja/cairo-context-circle.html +54 -0
- data/doc/ja/cairo-context-color.html +52 -0
- data/doc/ja/cairo-context-path.html +77 -0
- data/doc/ja/cairo-context-rectangle.html +60 -0
- data/doc/ja/cairo-context-triangle.html +47 -0
- data/doc/ja/cairo-context.html +1542 -0
- data/doc/ja/cairo-error.html +56 -0
- data/doc/ja/cairo-extend.html +56 -0
- data/doc/ja/cairo-file-not-found.html +51 -0
- data/doc/ja/cairo-fill-rule.html +58 -0
- data/doc/ja/cairo-filter.html +43 -0
- data/doc/ja/cairo-font-extents.html +164 -0
- data/doc/ja/cairo-font-face.html +55 -0
- data/doc/ja/cairo-font-options.html +189 -0
- data/doc/ja/cairo-font-slant.html +50 -0
- data/doc/ja/cairo-font-type-mismatch.html +52 -0
- data/doc/ja/cairo-font-weight.html +47 -0
- data/doc/ja/cairo-format.html +81 -0
- data/doc/ja/cairo-glyph.html +115 -0
- data/doc/ja/cairo-gradient-pattern.html +119 -0
- data/doc/ja/cairo-hint-metrics.html +57 -0
- data/doc/ja/cairo-hint-style.html +64 -0
- data/doc/ja/cairo-image-surface.html +131 -0
- data/doc/ja/cairo-invalid-clusters.html +55 -0
- data/doc/ja/cairo-invalid-content-error.html +54 -0
- data/doc/ja/cairo-invalid-dash-error.html +54 -0
- data/doc/ja/cairo-invalid-dsc-comment-error.html +54 -0
- data/doc/ja/cairo-invalid-format-error.html +54 -0
- data/doc/ja/cairo-invalid-index-error.html +54 -0
- data/doc/ja/cairo-invalid-matrix-error.html +54 -0
- data/doc/ja/cairo-invalid-path-data-error.html +54 -0
- data/doc/ja/cairo-invalid-pop-group-error.html +54 -0
- data/doc/ja/cairo-invalid-restore-error.html +55 -0
- data/doc/ja/cairo-invalid-slant.html +57 -0
- data/doc/ja/cairo-invalid-status-error.html +55 -0
- data/doc/ja/cairo-invalid-stride-error.html +55 -0
- data/doc/ja/cairo-invalid-string-error.html +54 -0
- data/doc/ja/cairo-invalid-visual-error.html +57 -0
- data/doc/ja/cairo-invalid-weight.html +57 -0
- data/doc/ja/cairo-line-cap.html +50 -0
- data/doc/ja/cairo-line-join.html +53 -0
- data/doc/ja/cairo-linear-pattern.html +87 -0
- data/doc/ja/cairo-matrix.html +354 -0
- data/doc/ja/cairo-negative-count.html +52 -0
- data/doc/ja/cairo-no-current-point-error.html +54 -0
- data/doc/ja/cairo-null-pointer-error.html +54 -0
- data/doc/ja/cairo-operator.html +51 -0
- data/doc/ja/cairo-paper-parse-error.html +55 -0
- data/doc/ja/cairo-paper-unknown-paper-name.html +76 -0
- data/doc/ja/cairo-paper-unknown-unit.html +75 -0
- data/doc/ja/cairo-paper-unrecognized-paper-description.html +76 -0
- data/doc/ja/cairo-paper.html +357 -0
- data/doc/ja/cairo-path-close-path.html +57 -0
- data/doc/ja/cairo-path-curve-to.html +70 -0
- data/doc/ja/cairo-path-data-type.html +53 -0
- data/doc/ja/cairo-path-data.html +127 -0
- data/doc/ja/cairo-path-line-to.html +62 -0
- data/doc/ja/cairo-path-move-to.html +62 -0
- data/doc/ja/cairo-path.html +144 -0
- data/doc/ja/cairo-pattern-type-mismatch-error.html +56 -0
- data/doc/ja/cairo-pattern.html +128 -0
- data/doc/ja/cairo-pdf-surface.html +86 -0
- data/doc/ja/cairo-point.html +90 -0
- data/doc/ja/cairo-ps-level.html +62 -0
- data/doc/ja/cairo-ps-surface.html +214 -0
- data/doc/ja/cairo-quartz-image-surface.html +75 -0
- data/doc/ja/cairo-quartz-surface.html +93 -0
- data/doc/ja/cairo-radial-pattern.html +93 -0
- data/doc/ja/cairo-read-error.html +55 -0
- data/doc/ja/cairo-rectangle.html +109 -0
- data/doc/ja/cairo-scaled-font.html +180 -0
- data/doc/ja/cairo-solid-pattern.html +87 -0
- data/doc/ja/cairo-subpixel-order.html +57 -0
- data/doc/ja/cairo-surface-finished-error.html +54 -0
- data/doc/ja/cairo-surface-pattern.html +68 -0
- data/doc/ja/cairo-surface-type-mismatch-error.html +56 -0
- data/doc/ja/cairo-surface.html +213 -0
- data/doc/ja/cairo-svg-surface.html +114 -0
- data/doc/ja/cairo-svg-version.html +66 -0
- data/doc/ja/cairo-temp-file-error.html +50 -0
- data/doc/ja/cairo-text-cluster-flag.html +46 -0
- data/doc/ja/cairo-text-cluster.html +102 -0
- data/doc/ja/cairo-text-extents.html +163 -0
- data/doc/ja/cairo-toy-font-face.html +107 -0
- data/doc/ja/cairo-user-font-error.html +55 -0
- data/doc/ja/cairo-user-font-face-text-to-glyphs-data.html +156 -0
- data/doc/ja/cairo-user-font-face.html +268 -0
- data/doc/ja/cairo-user-font-immutable.html +54 -0
- data/doc/ja/cairo-win32-printing-surface.html +80 -0
- data/doc/ja/cairo-win32-surface.html +100 -0
- data/doc/ja/cairo-write-error.html +55 -0
- data/doc/ja/cairo.html +177 -0
- data/doc/ja/index.html +1156 -0
- data/ext/cairo/cairo.def +104 -0
- data/ext/cairo/extconf.rb +80 -0
- data/ext/cairo/rb_cairo.c +104 -0
- data/ext/cairo/rb_cairo.h +275 -0
- data/ext/cairo/rb_cairo_constants.c +478 -0
- data/ext/cairo/rb_cairo_context.c +1693 -0
- data/ext/cairo/rb_cairo_exception.c +354 -0
- data/ext/cairo/rb_cairo_font_extents.c +200 -0
- data/ext/cairo/rb_cairo_font_face.c +713 -0
- data/ext/cairo/rb_cairo_font_options.c +197 -0
- data/ext/cairo/rb_cairo_glyph.c +161 -0
- data/ext/cairo/rb_cairo_matrix.c +366 -0
- data/ext/cairo/rb_cairo_path.c +459 -0
- data/ext/cairo/rb_cairo_pattern.c +540 -0
- data/ext/cairo/rb_cairo_private.c +242 -0
- data/ext/cairo/rb_cairo_private.h +114 -0
- data/ext/cairo/rb_cairo_scaled_font.c +235 -0
- data/ext/cairo/rb_cairo_surface.c +1371 -0
- data/ext/cairo/rb_cairo_text_cluster.c +151 -0
- data/ext/cairo/rb_cairo_text_extents.c +221 -0
- data/extconf.rb +45 -0
- data/lib/1.8/cairo.so +0 -0
- data/lib/1.9/cairo.so +0 -0
- data/lib/cairo.rb +151 -0
- data/lib/cairo/color.rb +267 -0
- data/lib/cairo/colors.rb +656 -0
- data/lib/cairo/constants.rb +24 -0
- data/lib/cairo/context.rb +29 -0
- data/lib/cairo/context/blur.rb +45 -0
- data/lib/cairo/context/circle.rb +9 -0
- data/lib/cairo/context/color.rb +11 -0
- data/lib/cairo/context/path.rb +116 -0
- data/lib/cairo/context/rectangle.rb +33 -0
- data/lib/cairo/context/triangle.rb +12 -0
- data/lib/cairo/paper.rb +183 -0
- data/lib/cairo/papers.rb +41 -0
- data/lib/cairo/path.rb +15 -0
- data/lib/cairo/point.rb +7 -0
- data/misc/update-colors.rb +143 -0
- data/pkg-config.rb +313 -0
- data/samples/agg/README +4 -0
- data/samples/agg/aa_test.rb +304 -0
- data/samples/blur.rb +47 -0
- data/samples/pac.rb +99 -0
- data/samples/pac2.rb +171 -0
- data/samples/png.rb +45 -0
- data/samples/scalable.rb +56 -0
- data/samples/text-on-path.rb +60 -0
- data/samples/text2.rb +131 -0
- data/test-unit/Rakefile +30 -0
- data/test-unit/bin/testrb +5 -0
- data/test-unit/lib/test/unit.rb +280 -0
- data/test-unit/lib/test/unit/assertionfailederror.rb +14 -0
- data/test-unit/lib/test/unit/assertions.rb +722 -0
- data/test-unit/lib/test/unit/attribute.rb +125 -0
- data/test-unit/lib/test/unit/autorunner.rb +254 -0
- data/test-unit/lib/test/unit/collector.rb +43 -0
- data/test-unit/lib/test/unit/collector/descendant.rb +23 -0
- data/test-unit/lib/test/unit/collector/dir.rb +108 -0
- data/test-unit/lib/test/unit/collector/load.rb +135 -0
- data/test-unit/lib/test/unit/collector/objectspace.rb +34 -0
- data/test-unit/lib/test/unit/color.rb +61 -0
- data/test-unit/lib/test/unit/diff.rb +524 -0
- data/test-unit/lib/test/unit/error.rb +124 -0
- data/test-unit/lib/test/unit/exceptionhandler.rb +39 -0
- data/test-unit/lib/test/unit/failure.rb +110 -0
- data/test-unit/lib/test/unit/fixture.rb +185 -0
- data/test-unit/lib/test/unit/notification.rb +125 -0
- data/test-unit/lib/test/unit/omission.rb +143 -0
- data/test-unit/lib/test/unit/pending.rb +146 -0
- data/test-unit/lib/test/unit/priority.rb +146 -0
- data/test-unit/lib/test/unit/runner/console.rb +46 -0
- data/test-unit/lib/test/unit/runner/emacs.rb +8 -0
- data/test-unit/lib/test/unit/testcase.rb +281 -0
- data/test-unit/lib/test/unit/testresult.rb +89 -0
- data/test-unit/lib/test/unit/testsuite.rb +110 -0
- data/test-unit/lib/test/unit/ui/console/outputlevel.rb +14 -0
- data/test-unit/lib/test/unit/ui/console/testrunner.rb +195 -0
- data/test-unit/lib/test/unit/ui/emacs/testrunner.rb +49 -0
- data/test-unit/lib/test/unit/ui/testrunner.rb +20 -0
- data/test-unit/lib/test/unit/ui/testrunnermediator.rb +77 -0
- data/test-unit/lib/test/unit/ui/testrunnerutilities.rb +41 -0
- data/test-unit/lib/test/unit/util/backtracefilter.rb +41 -0
- data/test-unit/lib/test/unit/util/observable.rb +90 -0
- data/test-unit/lib/test/unit/util/procwrapper.rb +48 -0
- data/test-unit/lib/test/unit/version.rb +7 -0
- data/test-unit/sample/adder.rb +13 -0
- data/test-unit/sample/subtracter.rb +12 -0
- data/test-unit/sample/tc_adder.rb +18 -0
- data/test-unit/sample/tc_subtracter.rb +18 -0
- data/test-unit/sample/ts_examples.rb +7 -0
- data/test-unit/test/collector/test_descendant.rb +135 -0
- data/test-unit/test/collector/test_dir.rb +406 -0
- data/test-unit/test/collector/test_load.rb +333 -0
- data/test-unit/test/collector/test_objectspace.rb +98 -0
- data/test-unit/test/run-test.rb +13 -0
- data/test-unit/test/test_assertions.rb +693 -0
- data/test-unit/test/test_attribute.rb +86 -0
- data/test-unit/test/test_color.rb +37 -0
- data/test-unit/test/test_diff.rb +477 -0
- data/test-unit/test/test_emacs_runner.rb +60 -0
- data/test-unit/test/test_error.rb +26 -0
- data/test-unit/test/test_failure.rb +33 -0
- data/test-unit/test/test_fixture.rb +252 -0
- data/test-unit/test/test_notification.rb +33 -0
- data/test-unit/test/test_omission.rb +81 -0
- data/test-unit/test/test_pending.rb +70 -0
- data/test-unit/test/test_priority.rb +89 -0
- data/test-unit/test/test_testcase.rb +430 -0
- data/test-unit/test/test_testresult.rb +113 -0
- data/test-unit/test/test_testsuite.rb +129 -0
- data/test-unit/test/testunit_test_util.rb +14 -0
- data/test-unit/test/ui/test_testrunmediator.rb +20 -0
- data/test-unit/test/util/test_backtracefilter.rb +41 -0
- data/test-unit/test/util/test_observable.rb +102 -0
- data/test-unit/test/util/test_procwrapper.rb +36 -0
- data/test/cairo-test-utils.rb +18 -0
- data/test/run-test.rb +28 -0
- data/test/test_color.rb +17 -0
- data/test/test_constants.rb +16 -0
- data/test/test_context.rb +105 -0
- data/test/test_exception.rb +27 -0
- data/test/test_font_extents.rb +36 -0
- data/test/test_font_face.rb +244 -0
- data/test/test_font_options.rb +13 -0
- data/test/test_paper.rb +81 -0
- data/test/test_pkg_config.rb +123 -0
- data/test/test_scaled_font.rb +34 -0
- data/test/test_surface.rb +41 -0
- data/test/test_text_cluster.rb +32 -0
- data/test/test_text_extents.rb +40 -0
- data/test/test_text_to_glyphs_data.rb +51 -0
- data/tmp/x86-mingw32/cairo/1.8.7/fake.rb +6 -0
- data/tmp/x86-mingw32/cairo/1.8.7/mkmf.rb +1836 -0
- data/tmp/x86-mingw32/cairo/1.8.7/rbconfig.rb +183 -0
- data/tmp/x86-mingw32/cairo/1.9.2/fake.rb +6 -0
- data/tmp/x86-mingw32/cairo/1.9.2/mkmf.rb +2079 -0
- data/tmp/x86-mingw32/cairo/1.9.2/rbconfig.rb +226 -0
- metadata +437 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'cairo'
|
2
|
+
|
3
|
+
module CairoTestUtils
|
4
|
+
private
|
5
|
+
def only_cairo_version(major, minor, micro=nil)
|
6
|
+
unless Cairo.satisfied_version?(major, minor, micro)
|
7
|
+
omit("Require cairo >= #{major}.#{minor}.#{micro}")
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def only_win32
|
12
|
+
omit("Only for Win32 platform") unless win32
|
13
|
+
end
|
14
|
+
|
15
|
+
def win32?
|
16
|
+
/cygwin|mingw|mswin32|bccwin32/.match(RUBY_PLATFORM) ? true : false
|
17
|
+
end
|
18
|
+
end
|
data/test/run-test.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
base_dir = File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
4
|
+
test_unit_dir = File.join(base_dir, "test-unit", "lib")
|
5
|
+
ext_dir = File.join(base_dir, "ext", "cairo")
|
6
|
+
lib_dir = File.join(base_dir, "lib")
|
7
|
+
test_dir = File.join(base_dir, "test")
|
8
|
+
|
9
|
+
if system("which make > /dev/null")
|
10
|
+
system("cd #{base_dir.dump} && make > /dev/null") or exit(1)
|
11
|
+
end
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(test_unit_dir)
|
14
|
+
|
15
|
+
require 'test/unit'
|
16
|
+
|
17
|
+
$LOAD_PATH.unshift(base_dir)
|
18
|
+
$LOAD_PATH.unshift(ext_dir)
|
19
|
+
$LOAD_PATH.unshift(lib_dir)
|
20
|
+
|
21
|
+
$LOAD_PATH.unshift(test_dir)
|
22
|
+
require 'cairo-test-utils'
|
23
|
+
|
24
|
+
Dir.glob("test/**/test_*.rb") do |file|
|
25
|
+
require file.sub(/\.rb$/, '')
|
26
|
+
end
|
27
|
+
|
28
|
+
exit Test::Unit::AutoRunner.run(false)
|
data/test/test_color.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'cairo'
|
2
|
+
|
3
|
+
class ColorTest < Test::Unit::TestCase
|
4
|
+
def test_rgb_to_hsv
|
5
|
+
color = rgb(0.3, 0.5, 0.75)
|
6
|
+
assert_equal(color, color.to_hsv.to_rgb)
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
def rgb(r, g, b)
|
11
|
+
Cairo::Color::RGB.new(r, g, b)
|
12
|
+
end
|
13
|
+
|
14
|
+
def hsv(h, s, v)
|
15
|
+
Cairo::Color::HSV.new(h, s, v)
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'cairo'
|
2
|
+
|
3
|
+
class ConstantsTest < Test::Unit::TestCase
|
4
|
+
def test_text_cluster_flags
|
5
|
+
constant_name = "TextClusterFlag"
|
6
|
+
unless Cairo.satisfied_version?(1, 7, 6)
|
7
|
+
assert_false(Cairo.const_defined?(constant_name))
|
8
|
+
return
|
9
|
+
end
|
10
|
+
|
11
|
+
assert_true(Cairo.const_defined?(constant_name))
|
12
|
+
assert_equal((0..1).to_a,
|
13
|
+
[0,
|
14
|
+
Cairo::TextClusterFlag::BACKWARD])
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require 'cairo'
|
2
|
+
require 'stringio'
|
3
|
+
|
4
|
+
class ContextTest < Test::Unit::TestCase
|
5
|
+
include CairoTestUtils
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@output = StringIO.new
|
9
|
+
@surface = Cairo::PDFSurface.new(@output, 10, 10)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_new_and_destroy
|
13
|
+
context = Cairo::Context.new(@surface)
|
14
|
+
@surface.destroy
|
15
|
+
assert_no_match(/%%EOF\s*\z/m, @output.string)
|
16
|
+
context.destroy
|
17
|
+
assert_match(/%%EOF\s*\z/m, @output.string)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_new_with_block
|
21
|
+
Cairo::Context.new(@surface) do |context|
|
22
|
+
@surface.destroy
|
23
|
+
assert_no_match(/%%EOF\s*\z/m, @output.string)
|
24
|
+
end
|
25
|
+
assert_match(/%%EOF\s*\z/m, @output.string)
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_new_with_block_and_destroy
|
29
|
+
assert_nothing_raised do
|
30
|
+
Cairo::Context.new(@surface) do |context|
|
31
|
+
context.destroy
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_font_face
|
37
|
+
only_cairo_version(1, 7, 2)
|
38
|
+
|
39
|
+
context = Cairo::Context.new(@surface)
|
40
|
+
|
41
|
+
assert_kind_of(Cairo::FontFace, context.font_face)
|
42
|
+
|
43
|
+
face = Cairo::ToyFontFace.new("serif")
|
44
|
+
context.font_face = face
|
45
|
+
assert_equal("serif", context.font_face.family)
|
46
|
+
|
47
|
+
face = Cairo::ToyFontFace.new("sans")
|
48
|
+
context.font_face = face
|
49
|
+
assert_equal("sans", context.font_face.family)
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_text_to_glyphs
|
53
|
+
only_cairo_version(1, 7, 2)
|
54
|
+
|
55
|
+
surface = Cairo::PDFSurface.new(StringIO.new, 10, 10)
|
56
|
+
context = Cairo::Context.new(surface)
|
57
|
+
scaled_font = Cairo::ScaledFont.new(context.font_face,
|
58
|
+
Cairo::Matrix.identity,
|
59
|
+
Cairo::Matrix.identity,
|
60
|
+
Cairo::FontOptions.new)
|
61
|
+
|
62
|
+
utf8 = "text"
|
63
|
+
glyphs, clusters, backward = scaled_font.text_to_glyphs(0, 0, utf8)
|
64
|
+
assert_nothing_raised do
|
65
|
+
context.show_text_glyphs(utf8, glyphs, clusters, backward)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_select_font_face
|
70
|
+
only_cairo_version(1, 7, 2)
|
71
|
+
|
72
|
+
context = Cairo::Context.new(@surface)
|
73
|
+
|
74
|
+
face = context.font_face
|
75
|
+
default_font_family = ""
|
76
|
+
# default_font_family = "Helvetica" if quartz?
|
77
|
+
# default_font_family = "Arial" if win32?
|
78
|
+
assert_equal([default_font_family,
|
79
|
+
Cairo::FONT_SLANT_NORMAL,
|
80
|
+
Cairo::FONT_WEIGHT_NORMAL],
|
81
|
+
[face.family, face.slant, face.weight])
|
82
|
+
|
83
|
+
context.select_font_face
|
84
|
+
face = context.font_face
|
85
|
+
assert_equal([default_font_family,
|
86
|
+
Cairo::FONT_SLANT_NORMAL,
|
87
|
+
Cairo::FONT_WEIGHT_NORMAL],
|
88
|
+
[face.family, face.slant, face.weight])
|
89
|
+
|
90
|
+
context.select_font_face(:serif, :italic, :bold)
|
91
|
+
face = context.font_face
|
92
|
+
assert_equal(["serif", Cairo::FONT_SLANT_ITALIC, Cairo::FONT_WEIGHT_BOLD],
|
93
|
+
[face.family, face.slant, face.weight])
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_select_font_face_with_invalid_family_name
|
97
|
+
context = Cairo::Context.new(@surface)
|
98
|
+
|
99
|
+
exception = assert_raise(ArgumentError) do
|
100
|
+
context.select_font_face([999])
|
101
|
+
end
|
102
|
+
assert_equal("family name should be nil, String or Symbol: [999]",
|
103
|
+
exception.message)
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'cairo'
|
2
|
+
|
3
|
+
class ExceptionTest < Test::Unit::TestCase
|
4
|
+
def test_new_symbols_since_1_7_2
|
5
|
+
if Cairo.satisfied_version?(1, 7, 2)
|
6
|
+
assertion = :assert_defined
|
7
|
+
else
|
8
|
+
assertion = :assert_not_defined
|
9
|
+
end
|
10
|
+
send(assertion, "FontTypeMismatch")
|
11
|
+
send(assertion, "UserFontImmutable")
|
12
|
+
send(assertion, "UserFontError")
|
13
|
+
send(assertion, "NegativeCount")
|
14
|
+
send(assertion, "InvalidClusters")
|
15
|
+
send(assertion, "InvalidSlant")
|
16
|
+
send(assertion, "InvalidWeight")
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
def assert_defined(name)
|
21
|
+
assert_true(Cairo.const_defined?(name))
|
22
|
+
end
|
23
|
+
|
24
|
+
def assert_not_defined(name)
|
25
|
+
assert_false(Cairo.const_defined?(name))
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'cairo'
|
2
|
+
|
3
|
+
class FontExtentsTest < Test::Unit::TestCase
|
4
|
+
include CairoTestUtils
|
5
|
+
|
6
|
+
def test_new
|
7
|
+
extents = Cairo::FontExtents.new
|
8
|
+
assert_equal([1.0, 0.0, 1.0, 1.0, 0.0],
|
9
|
+
[extents.ascent, extents.descent, extents.height,
|
10
|
+
extents.max_x_advance, extents.max_y_advance])
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_accessor
|
14
|
+
extents = Cairo::FontExtents.new
|
15
|
+
extents.ascent = 0.1
|
16
|
+
extents.descent = 0.2
|
17
|
+
extents.height = 0.3
|
18
|
+
extents.max_x_advance = 0.4
|
19
|
+
extents.max_y_advance = 0.5
|
20
|
+
assert_equal([0.1, 0.2, 0.3, 0.4, 0.5],
|
21
|
+
[extents.ascent, extents.descent, extents.height,
|
22
|
+
extents.max_x_advance, extents.max_y_advance])
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_to_s
|
26
|
+
extents = Cairo::FontExtents.new
|
27
|
+
extents.ascent = 0.1
|
28
|
+
extents.descent = 0.2
|
29
|
+
extents.height = 0.3
|
30
|
+
extents.max_x_advance = 0.4
|
31
|
+
extents.max_y_advance = 0.5
|
32
|
+
assert_equal("#<Cairo::FontExtents: ascent=0.1, descent=0.2, " +
|
33
|
+
"height=0.3, max_x_advance=0.4, max_y_advance=0.5>",
|
34
|
+
extents.to_s)
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,244 @@
|
|
1
|
+
require 'cairo'
|
2
|
+
|
3
|
+
class FontFaceTest < Test::Unit::TestCase
|
4
|
+
include CairoTestUtils
|
5
|
+
|
6
|
+
def test_toy_font_face_new
|
7
|
+
only_cairo_version(1, 7, 2)
|
8
|
+
|
9
|
+
face = Cairo::ToyFontFace.new
|
10
|
+
default_font_family = ""
|
11
|
+
# default_font_family = "Helvetica" if quartz?
|
12
|
+
# default_font_family = "Arial" if win32?
|
13
|
+
assert_equal([default_font_family,
|
14
|
+
Cairo::FONT_SLANT_NORMAL,
|
15
|
+
Cairo::FONT_WEIGHT_NORMAL],
|
16
|
+
[face.family, face.slant, face.weight])
|
17
|
+
|
18
|
+
face = Cairo::ToyFontFace.new("serif")
|
19
|
+
assert_equal(["serif", Cairo::FONT_SLANT_NORMAL, Cairo::FONT_WEIGHT_NORMAL],
|
20
|
+
[face.family, face.slant, face.weight])
|
21
|
+
|
22
|
+
face = Cairo::ToyFontFace.new(:serif)
|
23
|
+
assert_equal(["serif", Cairo::FONT_SLANT_NORMAL, Cairo::FONT_WEIGHT_NORMAL],
|
24
|
+
[face.family, face.slant, face.weight])
|
25
|
+
|
26
|
+
face = Cairo::ToyFontFace.new("serif", :oblique)
|
27
|
+
assert_equal(["serif", Cairo::FONT_SLANT_OBLIQUE, Cairo::FONT_WEIGHT_NORMAL],
|
28
|
+
[face.family, face.slant, face.weight])
|
29
|
+
|
30
|
+
face = Cairo::ToyFontFace.new("serif", nil, :bold)
|
31
|
+
assert_equal(["serif", Cairo::FONT_SLANT_NORMAL, Cairo::FONT_WEIGHT_BOLD],
|
32
|
+
[face.family, face.slant, face.weight])
|
33
|
+
|
34
|
+
face = Cairo::ToyFontFace.new("serif", :italic, :bold)
|
35
|
+
assert_equal(["serif", Cairo::FONT_SLANT_ITALIC, Cairo::FONT_WEIGHT_BOLD],
|
36
|
+
[face.family, face.slant, face.weight])
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_toy_font_face_new_with_invalid_family_name
|
40
|
+
only_cairo_version(1, 7, 2)
|
41
|
+
|
42
|
+
exception = assert_raise(ArgumentError) do
|
43
|
+
Cairo::ToyFontFace.new(999)
|
44
|
+
end
|
45
|
+
assert_equal("family name should be nil, String or Symbol: 999",
|
46
|
+
exception.message)
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_user_font_face_empty
|
50
|
+
only_cairo_version(1, 7, 2)
|
51
|
+
|
52
|
+
face = Cairo::UserFontFace.new
|
53
|
+
scaled_font = Cairo::ScaledFont.new(face,
|
54
|
+
Cairo::Matrix.identity,
|
55
|
+
Cairo::Matrix.identity,
|
56
|
+
Cairo::FontOptions.new)
|
57
|
+
assert_equal([[], [], 0],
|
58
|
+
scaled_font.text_to_glyphs(0, 0, "text"))
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_user_font_face_callback
|
62
|
+
only_cairo_version(1, 7, 2)
|
63
|
+
|
64
|
+
face = Cairo::UserFontFace.new
|
65
|
+
|
66
|
+
init_args = []
|
67
|
+
face.on_init do |*args|
|
68
|
+
init_args << args
|
69
|
+
end
|
70
|
+
|
71
|
+
render_glyph_args = []
|
72
|
+
face.on_render_glyph do |*args|
|
73
|
+
render_glyph_args << args
|
74
|
+
end
|
75
|
+
|
76
|
+
text_to_glyphs_args = []
|
77
|
+
face.on_text_to_glyphs do |*args|
|
78
|
+
text_to_glyphs_args << args
|
79
|
+
scaled_font, utf8, data = args
|
80
|
+
data.cluster_flags = :backward
|
81
|
+
end
|
82
|
+
|
83
|
+
unicode_to_glyph_args = []
|
84
|
+
face.on_unicode_to_glyph do |*args|
|
85
|
+
unicode_to_glyph_args << args
|
86
|
+
scaled_font, unicode = args
|
87
|
+
unicode
|
88
|
+
end
|
89
|
+
|
90
|
+
scaled_font = Cairo::ScaledFont.new(face,
|
91
|
+
Cairo::Matrix.identity,
|
92
|
+
Cairo::Matrix.identity,
|
93
|
+
Cairo::FontOptions.new)
|
94
|
+
result = scaled_font.text_to_glyphs(0, 0, "text")
|
95
|
+
assert_equal([[[Cairo::ScaledFont, Cairo::Context, Cairo::FontExtents]],
|
96
|
+
[[Cairo::ScaledFont, ?t, Cairo::Context, Cairo::TextExtents],
|
97
|
+
[Cairo::ScaledFont, ?e, Cairo::Context, Cairo::TextExtents],
|
98
|
+
[Cairo::ScaledFont, ?x, Cairo::Context, Cairo::TextExtents]],
|
99
|
+
[[Cairo::ScaledFont, "text",
|
100
|
+
Cairo::UserFontFace::TextToGlyphsData]],
|
101
|
+
[[Cairo::ScaledFont, ?t],
|
102
|
+
[Cairo::ScaledFont, ?e],
|
103
|
+
[Cairo::ScaledFont, ?x],
|
104
|
+
[Cairo::ScaledFont, ?t]],
|
105
|
+
[[], [], Cairo::TextClusterFlag::BACKWARD]],
|
106
|
+
[classify_cairo_object(init_args),
|
107
|
+
classify_cairo_object(render_glyph_args),
|
108
|
+
classify_cairo_object(text_to_glyphs_args),
|
109
|
+
classify_cairo_object(unicode_to_glyph_args),
|
110
|
+
result])
|
111
|
+
end
|
112
|
+
|
113
|
+
if Cairo.satisfied_version?(1, 7, 2)
|
114
|
+
class CustomUserFontFace < Cairo::UserFontFace
|
115
|
+
attr_reader :init_args, :render_glyph_args
|
116
|
+
attr_reader :text_to_glyphs_args, :unicode_to_glyph_args
|
117
|
+
def initialize
|
118
|
+
super
|
119
|
+
@init_args = []
|
120
|
+
@render_glyph_args = []
|
121
|
+
@text_to_glyphs_args = []
|
122
|
+
@unicode_to_glyph_args = []
|
123
|
+
end
|
124
|
+
|
125
|
+
def init(*args)
|
126
|
+
@init_args << args
|
127
|
+
end
|
128
|
+
|
129
|
+
def render_glyph(*args)
|
130
|
+
@render_glyph_args << args
|
131
|
+
end
|
132
|
+
|
133
|
+
def text_to_glyphs(*args)
|
134
|
+
@text_to_glyphs_args << args
|
135
|
+
scaled_font, utf8, data = args
|
136
|
+
data.cluster_flags = :backward
|
137
|
+
end
|
138
|
+
|
139
|
+
def unicode_to_glyph(*args)
|
140
|
+
@unicode_to_glyph_args << args
|
141
|
+
scaled_font, unicode = args
|
142
|
+
unicode
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
def test_user_font_face_class
|
148
|
+
only_cairo_version(1, 7, 2)
|
149
|
+
|
150
|
+
face = CustomUserFontFace.new
|
151
|
+
|
152
|
+
scaled_font = Cairo::ScaledFont.new(face,
|
153
|
+
Cairo::Matrix.identity,
|
154
|
+
Cairo::Matrix.identity,
|
155
|
+
Cairo::FontOptions.new)
|
156
|
+
result = scaled_font.text_to_glyphs(0, 0, "text")
|
157
|
+
assert_equal([[[Cairo::ScaledFont, Cairo::Context, Cairo::FontExtents]],
|
158
|
+
[[Cairo::ScaledFont, ?t, Cairo::Context, Cairo::TextExtents],
|
159
|
+
[Cairo::ScaledFont, ?e, Cairo::Context, Cairo::TextExtents],
|
160
|
+
[Cairo::ScaledFont, ?x, Cairo::Context, Cairo::TextExtents]],
|
161
|
+
[[Cairo::ScaledFont, "text",
|
162
|
+
Cairo::UserFontFace::TextToGlyphsData]],
|
163
|
+
[[Cairo::ScaledFont, ?t],
|
164
|
+
[Cairo::ScaledFont, ?e],
|
165
|
+
[Cairo::ScaledFont, ?x],
|
166
|
+
[Cairo::ScaledFont, ?t]],
|
167
|
+
[[], [], Cairo::TextClusterFlag::BACKWARD]],
|
168
|
+
[classify_cairo_object(face.init_args),
|
169
|
+
classify_cairo_object(face.render_glyph_args),
|
170
|
+
classify_cairo_object(face.text_to_glyphs_args),
|
171
|
+
classify_cairo_object(face.unicode_to_glyph_args),
|
172
|
+
result])
|
173
|
+
end
|
174
|
+
|
175
|
+
def test_user_font_face_class_and_callback
|
176
|
+
only_cairo_version(1, 7, 2)
|
177
|
+
|
178
|
+
face = CustomUserFontFace.new
|
179
|
+
|
180
|
+
init_args = []
|
181
|
+
face.on_init do |*args|
|
182
|
+
init_args << args
|
183
|
+
end
|
184
|
+
|
185
|
+
render_glyph_args = []
|
186
|
+
face.on_render_glyph do |*args|
|
187
|
+
render_glyph_args << args
|
188
|
+
end
|
189
|
+
|
190
|
+
text_to_glyphs_args = []
|
191
|
+
face.on_text_to_glyphs do |*args|
|
192
|
+
text_to_glyphs_args << args
|
193
|
+
scaled_font, utf8, data = args
|
194
|
+
data.cluster_flags = :backward
|
195
|
+
end
|
196
|
+
|
197
|
+
unicode_to_glyph_args = []
|
198
|
+
face.on_unicode_to_glyph do |*args|
|
199
|
+
unicode_to_glyph_args << args
|
200
|
+
scaled_font, unicode = args
|
201
|
+
unicode
|
202
|
+
end
|
203
|
+
|
204
|
+
scaled_font = Cairo::ScaledFont.new(face,
|
205
|
+
Cairo::Matrix.identity,
|
206
|
+
Cairo::Matrix.identity,
|
207
|
+
Cairo::FontOptions.new)
|
208
|
+
result = scaled_font.text_to_glyphs(0, 0, "text")
|
209
|
+
assert_equal([[[Cairo::ScaledFont, Cairo::Context, Cairo::FontExtents]],
|
210
|
+
[[Cairo::ScaledFont, ?t, Cairo::Context, Cairo::TextExtents],
|
211
|
+
[Cairo::ScaledFont, ?e, Cairo::Context, Cairo::TextExtents],
|
212
|
+
[Cairo::ScaledFont, ?x, Cairo::Context, Cairo::TextExtents]],
|
213
|
+
[[Cairo::ScaledFont, "text",
|
214
|
+
Cairo::UserFontFace::TextToGlyphsData]],
|
215
|
+
[[Cairo::ScaledFont, ?t],
|
216
|
+
[Cairo::ScaledFont, ?e],
|
217
|
+
[Cairo::ScaledFont, ?x],
|
218
|
+
[Cairo::ScaledFont, ?t]],
|
219
|
+
[],
|
220
|
+
[],
|
221
|
+
[],
|
222
|
+
[],
|
223
|
+
[[], [], Cairo::TextClusterFlag::BACKWARD]],
|
224
|
+
[classify_cairo_object(init_args),
|
225
|
+
classify_cairo_object(render_glyph_args),
|
226
|
+
classify_cairo_object(text_to_glyphs_args),
|
227
|
+
classify_cairo_object(unicode_to_glyph_args),
|
228
|
+
classify_cairo_object(face.init_args),
|
229
|
+
classify_cairo_object(face.render_glyph_args),
|
230
|
+
classify_cairo_object(face.text_to_glyphs_args),
|
231
|
+
classify_cairo_object(face.unicode_to_glyph_args),
|
232
|
+
result])
|
233
|
+
end
|
234
|
+
|
235
|
+
def classify_cairo_object(object)
|
236
|
+
if object.is_a?(Array)
|
237
|
+
object.collect {|obj| classify_cairo_object(obj)}
|
238
|
+
elsif /\ACairo::/ =~ object.class.name
|
239
|
+
object.class
|
240
|
+
else
|
241
|
+
object
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|