[DRE-commits] [ruby-cairo] 01/13: New upstream version 1.14.0
Daisuke Higuchi
dai at moszumanska.debian.org
Wed Oct 26 05:57:08 UTC 2016
This is an automated email from the git hooks/post-receive script.
dai pushed a commit to branch master
in repository ruby-cairo.
commit 81d45d3ba5665e60f4022ac25060aaebf89880ee
Author: HIGUCHI Daisuke (VDR dai) <dai at debian.org>
Date: Wed Oct 26 12:41:31 2016 +0900
New upstream version 1.14.0
---
.gitignore | 16 ++
.travis.yml | 8 +
.yardopts | 4 +
NEWS | 26 +++
README.rdoc | 14 +-
Rakefile | 77 +++++---
build/README.md | 11 ++
build/Vagrantfile | 30 ++++
build/build-win32.sh | 6 +
build/build-win64.sh | 9 +
build/build-windows.sh | 104 +++++++++++
cairo.gemspec | 43 +++++
checksums.yaml.gz | Bin 269 -> 0 bytes
dist.sh | 30 ++++
ext/cairo/extconf.rb | 6 +-
ext/cairo/rb_cairo.h | 6 +-
ext/cairo/rb_cairo_constants.c | 8 +
ext/cairo/rb_cairo_context.c | 64 ++++++-
ext/cairo/rb_cairo_exception.c | 17 ++
ext/cairo/rb_cairo_font_face.c | 13 ++
ext/cairo/rb_cairo_private.c | 15 +-
ext/cairo/rb_cairo_private.h | 13 +-
ext/cairo/rb_cairo_surface.c | 70 +++++---
extconf.rb | 47 +++++
lib/cairo/surface.rb | 4 +-
metadata.yml | 225 ------------------------
misc/update-colors.rb | 143 +++++++++++++++
patches/cairo-1.14-missing-exeext-float-m4.diff | 17 ++
patches/fontconfig-2.11.1-disable-mktemp-s.diff | 12 ++
patches/remove-empty-z_dir-ldflags.diff | 12 ++
samples/.cvsignore | 4 +
samples/agg/README | 4 +
test/.cvsignore | 1 +
test/cairo-test-utils.rb | 5 +
test/test_constants.rb | 11 ++
test/test_context.rb | 2 +-
test/test_exception.rb | 9 +
test/test_font_face.rb | 2 +-
test/test_quartz_image_surface.rb | 13 ++
test/test_surface.rb | 10 ++
40 files changed, 824 insertions(+), 287 deletions(-)
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..a740b24
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,16 @@
+/ext/cairo/Makefile
+/ext/cairo/libruby-cairo.a
+/ext/cairo/mkmf.log
+*.so
+*.o
+/doc/
+/rcairo-*.tar.gz*
+/test/.test-result/
+/tmp/
+/vendor/
+/pkg/
+/Makefile
+/Makefile.lib
+/Gemfile.lock
+/build/.vagrant/
+/build/pkg/
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..5c34277
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,8 @@
+notifications:
+ recipients:
+ - ruby-gnome2-cvs at lists.sourceforge.net
+rvm:
+ - 2.0.0
+ - 2.1
+ - 2.2
+ - ruby-head
diff --git a/.yardopts b/.yardopts
new file mode 100644
index 0000000..e3a6087
--- /dev/null
+++ b/.yardopts
@@ -0,0 +1,4 @@
+--output-dir doc/reference/en
+--use-cache .yardoc
+lib/**/*.rb
+ext/**/*.c
diff --git a/NEWS b/NEWS
index 1fb480d..004d6fd 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,29 @@
+Release 1.14.0 (2014-11-24) Kouhei Sutou <kou at cozmixng.org>
+===========================================================
+
+Improvements
+------------
+
+ * Supported integration with ffi gem.
+ [GitHub#20][Patch by Patrick Hanevold]
+ * Supported cairo 1.14.0.
+ [GitHub#24][GitHub#25][GitHub#28][GitHub#30][Patch by Hiroshi Hatake]
+ * Added libstdc++-6.dll into gem for Windows.
+
+Fixes
+-----
+
+ * Fixed an build error on Cygwin.
+ [GitHub#19][Reported by Patrick Hanevold][Patch by Masafumi Yokoyama]
+ [ruby-gnome2-devel-en][Reported by Detlef Reichl]
+
+Thanks
+------
+
+ * Patrick Hanevold
+ * Masafumi Yokoyama
+ * Hiroshi Hatake
+
Release 1.12.9 (2014-04-05) Kouhei Sutou <kou at cozmixng.org>
===========================================================
diff --git a/README.rdoc b/README.rdoc
index 165d964..5c22114 100644
--- a/README.rdoc
+++ b/README.rdoc
@@ -12,7 +12,7 @@ http://cairographics.org/
== Dependencies
-* ruby >= 1.9.3 (2.0.0 also supported!)
+* ruby >= 1.9.3 (2.2 also supported!)
* cairo >= 1.2.0 (1.12.0 also supported!)
== Install
@@ -38,11 +38,11 @@ Compiling:
% make # to compile
# make install # to install the cairo extension.
- # The samples in the samples folder should be able
- # to run before installation except text-on-path.rb
- # and text2.rb. They uses Ruby/Pango with rcairo
- # support. So you need to install rcairo and build
- # Ruby/Pango with it before you run them.
+ # The samples in the samples folder should be able
+ # to run before installation except text-on-path.rb
+ # and text2.rb. They uses Ruby/Pango with rcairo
+ # support. So you need to install rcairo and build
+ # Ruby/Pango with it before you run them.
Options to extconf.rb:
@@ -67,7 +67,7 @@ cairo-X.Y.Z-x86-mingw32.gem includes cairo related binaries.
== Documents
* Reference manual:
- http://cairo.rubyforge.org/doc/
+ http://rcairo.github.io/doc/
* Repository of the reference manual:
http://github.com/rcairo/doc
* An article for rcairo on Rubyst Magazine a.k.a. RubiMa (in Japanese):
diff --git a/Rakefile b/Rakefile
index eec7701..d325f18 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,21 +1,21 @@
# -*- coding: utf-8; mode: ruby -*-
-require 'English'
-
-require 'find'
-require 'fileutils'
-require 'open-uri'
-require 'rubygems'
-require 'rubygems/package_task'
-require 'yard'
-require 'bundler/gem_helper'
-require 'rake/extensiontask'
-require 'packnga'
+require "English"
+
+require "find"
+require "fileutils"
+require "open-uri"
+require "rubygems"
+require "rubygems/package_task"
+require "yard"
+require "bundler/gem_helper"
+require "rake/extensiontask"
+require "packnga"
base_dir = File.join(File.dirname(__FILE__))
-cairo_ext_dir = File.join(base_dir, 'ext', 'cairo')
-cairo_lib_dir = File.join(base_dir, 'lib')
+cairo_ext_dir = File.join(base_dir, "ext", "cairo")
+cairo_lib_dir = File.join(base_dir, "lib")
$LOAD_PATH.unshift(cairo_ext_dir)
$LOAD_PATH.unshift(cairo_lib_dir)
ENV["RUBYLIB"] = "#{cairo_lib_dir}:#{cairo_ext_dir}:#{ENV['RUBYLIB']}"
@@ -29,6 +29,8 @@ Gem::PackageTask.new(spec) do |pkg|
end
Packnga::DocumentTask.new(spec) do |task|
+ task.original_language = "en"
+ task.translate_languages = ["ja"]
end
Packnga::ReleaseTask.new(spec) do |task|
@@ -198,9 +200,21 @@ class WindowsTask
directory binary_path.to_s
desc "Bundle GCC related DLLs"
task :bundle => binary_path do
- dll_names = ["libgcc_s_sjlj-1.dll", "libwinpthread-1.dll"]
+ dll_names = [
+ "libstdc++-6.dll",
+ "libwinpthread-1.dll",
+ "libgcc_s_sjlj-1.dll",
+ "libgcc_s_seh-1.dll",
+ ]
dll_names.each do |dll_name|
- cp(absolete_gcc_dll_path(dll_name), binary_path)
+ destination_path = binary_path + dll_name
+ dll_path = absolete_gcc_dll_path(dll_name)
+ unless File.exist?(dll_path)
+ puts("#{dll_name} doesn't exist.")
+ next
+ end
+ cp(dll_path, destination_path)
+ chmod(0755, destination_path)
end
end
end
@@ -235,6 +249,7 @@ class WindowsTask
end
def download(package, archive_path)
+ rake_output_message "Downloading... #{package.archive_url}"
open(package.archive_url) do |downloaded_archive|
begin
archive_path.open("wb") do |archive_file|
@@ -435,8 +450,8 @@ windows_task = WindowsTask.new(spec) do |task|
},
{
:name => "libpng",
- :version => "1.6.10",
- :download_base_url => "http://sourceforge.net/projects/libpng/files/libpng16/1.6.10",
+ :version => "1.6.14",
+ :download_base_url => "http://sourceforge.net/projects/libpng/files/libpng16/1.6.14",
:windows => {
:built_file => "bin/libpng16-16.dll",
},
@@ -452,7 +467,7 @@ windows_task = WindowsTask.new(spec) do |task|
},
{
:name => "libxml2",
- :version => "2.9.1",
+ :version => "2.9.2",
:download_base_url => "ftp://xmlsoft.org/libxml2",
:compression_method => "gz",
:windows => {
@@ -460,6 +475,10 @@ windows_task = WindowsTask.new(spec) do |task|
:configure_args => [
"--without-python",
],
+ :patches => [
+ "remove-empty-z_dir-ldflags.diff",
+ ],
+ :need_autoreconf => true,
},
},
{
@@ -481,7 +500,7 @@ windows_task = WindowsTask.new(spec) do |task|
},
{
:name => "pixman",
- :version => "0.32.4",
+ :version => "0.32.6",
:download_site => :cairo,
:compression_method => "gz",
:windows => {
@@ -490,13 +509,17 @@ windows_task = WindowsTask.new(spec) do |task|
},
{
:name => "cairo",
- :version => "1.12.16",
+ :version => "1.14.0",
:download_site => :cairo,
:windows => {
:built_file => "bin/libcairo-2.dll",
:configure_args => [
"--enable-gobject",
],
+ :patches => [
+ "cairo-1.14-missing-exeext-float-m4.diff"
+ ],
+ :need_autoreconf => true,
},
},
]
@@ -581,3 +604,17 @@ langs.each do |lang,|
rm Dir[File.join(lang_doc_dir, "*.{rd,rdc,rbl}")]
end
end
+
+file "Makefile" => ["extconf.rb", "ext/cairo/extconf.rb"] do
+ ruby("extconf.rb")
+end
+
+desc "Configure"
+task :configure => "Makefile"
+
+desc "Run test"
+task :test => :configure do
+ ruby("test/run-test.rb")
+end
+
+task :default => :test
diff --git a/build/README.md b/build/README.md
new file mode 100644
index 0000000..25df728
--- /dev/null
+++ b/build/README.md
@@ -0,0 +1,11 @@
+= cairo gem build system for Windows gems
+
+== How to use
+
+ % git clone git at github.com:ruby-gnome2/ruby-gnome2.git
+ % git clone git at github.com:ruby-gnome2/pkg-config.git
+ % git clone git at github.com:rcairo/rcairo.git
+ % cd rcairo/build
+ % vagrant up
+
+You can find gems for Windows in rcairo/build/pkg/.
diff --git a/build/Vagrantfile b/build/Vagrantfile
new file mode 100644
index 0000000..6f8cfb8
--- /dev/null
+++ b/build/Vagrantfile
@@ -0,0 +1,30 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+
+# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
+VAGRANTFILE_API_VERSION = "2"
+
+Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
+ targets = [
+ "win32",
+ "win64",
+ ]
+
+ targets.each do |target|
+ config.vm.define(target) do |node|
+ node.vm.box = "ubuntu-14.10-x86_64"
+ node.vm.box_url = "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-14.10_chef-provisionerless.box"
+
+ node.vm.synced_folder("../", "/rcairo")
+ node.vm.synced_folder("../../pkg-config", "/pkg-config")
+ node.vm.synced_folder("../../ruby-gnome2", "/ruby-gnome2")
+
+ node.vm.provision(:shell,
+ :privileged => false,
+ :path => "build-#{target}.sh")
+ config.vm.provider("virtualbox") do |virtual_box|
+ virtual_box.cpus = (ENV["N_CPUS"] || 1).to_i
+ end
+ end
+ end
+end
diff --git a/build/build-win32.sh b/build/build-win32.sh
new file mode 100755
index 0000000..88be20b
--- /dev/null
+++ b/build/build-win32.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+export BUILD_HOST="i686-w64-mingw32"
+export DIRECTORY_SUFFIX="win32"
+
+/vagrant/build-windows.sh
diff --git a/build/build-win64.sh b/build/build-win64.sh
new file mode 100755
index 0000000..3a265f5
--- /dev/null
+++ b/build/build-win64.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+export BUILD_HOST="x86_64-w64-mingw32"
+export DIRECTORY_SUFFIX="win64"
+
+export RCAIRO_WINDOWS_64=yes
+export RUBY_GNOME2_BUILD_ARCHITECTURE=x64
+
+/vagrant/build-windows.sh
diff --git a/build/build-windows.sh b/build/build-windows.sh
new file mode 100755
index 0000000..4d0e257
--- /dev/null
+++ b/build/build-windows.sh
@@ -0,0 +1,104 @@
+#!/bin/sh
+
+export LANG=C
+export DEBIAN_FRONTEND=noninteractive
+
+ruby_versions="2.0.0-p598 2.1.5 2.2.0-preview1"
+export RUBY_CC_VERSION="2.0.0:2.1.5:2.2.0"
+
+N_CPUS=$(grep '^processor' /proc/cpuinfo | wc -l)
+export MAKE_N_JOBS=${N_CPUS}
+
+export RUBYLIB="$(pwd)/pkg-config/lib"
+
+run()
+{
+ "$@"
+ if [ $? -ne 0 ]; then
+ echo "Failed $@"
+ exit 1
+ fi
+}
+
+run sudo sed -i'' -e 's,http://us,http://jp,g' /etc/apt/sources.list
+run sudo apt-get update
+
+echo ttf-mscorefonts-installer \
+ msttcorefonts/accepted-mscorefonts-eula \
+ select true | \
+ run sudo debconf-set-selections
+
+run \
+ sudo apt-get install -y -V \
+ git \
+ ruby \
+ ruby-dev \
+ build-essential \
+ pkg-config \
+ autoconf \
+ libtool \
+ gettext \
+ intltool \
+ gtk-doc-tools \
+ libffi-dev \
+ libglib2.0-dev \
+ gobject-introspection \
+ flex \
+ bison \
+ python-dev \
+ wine1.6 \
+ mingw-w64
+
+run git clone file:///pkg-config/.git
+run git clone file:///rcairo/.git rcairo.${DIRECTORY_SUFFIX}
+run git clone file:///ruby-gnome2/.git ruby-gnome2.${DIRECTORY_SUFFIX}
+
+run sudo gem install --no-document \
+ rake \
+ bundler \
+ pkg-config \
+ rake-compiler \
+ mechanize \
+ packnga
+
+if [ ! -d ~/.wine/ ]; then
+ run wineboot
+ until [ -f ~/.wine/system.reg ]; do
+ sleep 1
+ done
+ wine_home="z:/home/vagrant"
+ wine_rcairo="${wine_home}/rcairo.${DIRECTORY_SUFFIX}"
+ wine_ruby_gnome2="${wine_home}/ruby-gnome2.${DIRECTORY_SUFFIX}"
+ bin_dir="vendor/local/bin"
+ path=$(
+ (
+ echo -n "${wine_rcairo}/${bin_dir};";
+ echo -n "${wine_ruby_gnome2}/glib2/${bin_dir};";
+ ) | \
+ sed -e 's,/,\\\\\\\\,g')
+ run sed -i'' -r \
+ -e "s,^(\"PATH\"=str\\(2\\):\"),\\1${path},g" \
+ ~/.wine/system.reg
+fi
+
+sudo chown -R "${USER}:${USER}" /var/lib/gems
+
+for ruby_version in ${ruby_versions}; do
+ run rake-compiler cross-ruby HOST="${BUILD_HOST}" VERSION="${ruby_version}"
+done
+
+run cd ~/rcairo.${DIRECTORY_SUFFIX}
+run rake windows:gcc:dll:bundle windows:zlib:build
+
+run cd ~/ruby-gnome2.${DIRECTORY_SUFFIX}/glib2
+run rake native:build windows:build
+
+run cd ~/ruby-gnome2.${DIRECTORY_SUFFIX}/gobject-introspection
+run rake native:build
+
+run cd ~/rcairo.${DIRECTORY_SUFFIX}
+run rake windows:build
+run rake cross compile native gem
+
+run mkdir -p /vagrant/pkg
+run cp */pkg/*.gem /vagrant/pkg/
diff --git a/cairo.gemspec b/cairo.gemspec
new file mode 100644
index 0000000..1638c70
--- /dev/null
+++ b/cairo.gemspec
@@ -0,0 +1,43 @@
+# -*- mode: ruby; coding: utf-8 -*-
+
+base_dir = File.dirname(__FILE__)
+cairo_ext_dir = File.join(base_dir, "ext", "cairo")
+
+guess_rcairo_version = lambda do |cairo_ext_dir|
+ version = {}
+ File.open(File.join(cairo_ext_dir, "rb_cairo.h"), "r:utf-8") do |rb_cairo_h|
+ rb_cairo_h.each_line do |line|
+ case line
+ when /\A#define RB_CAIRO_VERSION_([A-Z]+) (\d+)/
+ version[$1.downcase] = $2
+ end
+ end
+ end
+ [version["major"], version["minor"], version["micro"]].join(".")
+end
+
+Gem::Specification.new do |s|
+ s.name = "cairo"
+ s.version = guess_rcairo_version.call(cairo_ext_dir)
+ s.authors = ["Kouhei Sutou"]
+ s.email = ["kou at cozmixng.org"]
+ s.summary = "Ruby bindings for cairo"
+ s.description = "Ruby bindings for cairo"
+ s.homepage = "http://cairographics.org/rcairo"
+ s.licenses = ["Ruby's"]
+ s.require_paths = ["lib"]
+ s.extensions = ["ext/cairo/extconf.rb"]
+
+ s.files = ["AUTHORS", "COPYING", "GPL", "Gemfile", "NEWS", "README.rdoc"]
+ s.files += ["Rakefile"]
+ s.files += Dir.glob("{lib,samples}/**/*.rb")
+ s.files += Dir.glob("ext/**/{*.def,depend,*.rb,*.c,*.h}")
+ s.test_files = Dir.glob("test/**/*.rb")
+ s.extra_rdoc_files = ["README.rdoc"]
+
+ s.add_runtime_dependency("pkg-config", ">= 1.1.5")
+ s.add_development_dependency("bundler")
+ s.add_development_dependency("test-unit-notify")
+ s.add_development_dependency("rake-compiler")
+ s.add_development_dependency("packnga")
+end
diff --git a/checksums.yaml.gz b/checksums.yaml.gz
deleted file mode 100644
index 0fe5b45..0000000
Binary files a/checksums.yaml.gz and /dev/null differ
diff --git a/dist.sh b/dist.sh
new file mode 100755
index 0000000..f81fea0
--- /dev/null
+++ b/dist.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+if [ $# = 0 ]; then
+ echo "usage: $0 VERSION"
+ echo "e.g. $0 1.6.0"
+ exit
+fi
+
+VERSION=$1
+TAG="v$VERSION"
+
+dest=annarchy.freedesktop.org:/srv/cairo.freedesktop.org/www/releases/
+
+base=rcairo-$VERSION
+tgz=$base.tar.gz
+
+
+mkdir -p tmp
+git clone git at github.com:rcairo/rcairo.git tmp/$base
+cd tmp/$base
+git checkout $TAG
+rm -rf .git
+cd ../..
+cp -rp doc tmp/$base/
+tar cvfz $tgz -C tmp $base
+md5sum $tgz > $tgz.md5
+sha1sum $tgz > $tgz.sha1
+rm -rf tmp
+
+scp $tgz $tgz.md5 $tgz.sha1 $dest
diff --git a/ext/cairo/extconf.rb b/ext/cairo/extconf.rb
index 9fd26ea..b8a66d1 100755
--- a/ext/cairo/extconf.rb
+++ b/ext/cairo/extconf.rb
@@ -29,13 +29,13 @@ major, minor, micro = 1, 2, 0
base_dir = Pathname(__FILE__).dirname.parent.parent
checking_for(checking_message("Win32 OS")) do
case RUBY_PLATFORM
- when /cygwin|mingw|mswin32/
+ when /mingw|mswin32/
$defs << "-DRUBY_CAIRO_PLATFORM_WIN32"
import_library_name = "libruby-#{module_name}.a"
$DLDFLAGS << " -Wl,--out-implib=#{import_library_name}"
$cleanfiles << import_library_name
- if with_config('vendor-override', true)
- binary_base_dir = base_dir + "vendor" + "local"
+ binary_base_dir = base_dir + "vendor" + "local"
+ if with_config('vendor-override', binary_base_dir.exist?)
$CFLAGS += " -I#{binary_base_dir}/include"
pkg_config_dir = binary_base_dir + "lib" + "pkgconfig"
PKGConfig.add_path(pkg_config_dir.to_s)
diff --git a/ext/cairo/rb_cairo.h b/ext/cairo/rb_cairo.h
index 208aaba..a9e05a3 100644
--- a/ext/cairo/rb_cairo.h
+++ b/ext/cairo/rb_cairo.h
@@ -5,7 +5,7 @@
* $Author: kou $
* $Date: 2008-09-19 12:56:27 $
*
- * Copyright 2006-2008 Kouhei Sutou <kou at cozmixng.org>
+ * Copyright 2006-2014 Kouhei Sutou <kou at cozmixng.org>
* Copyright 2005 Øyvind Kolås <pippin at freedesktop.org>
* Copyright 2004-2005 MenTaLguY <mental at rydia.com>
*
@@ -72,8 +72,8 @@ RB_CAIRO_BEGIN_DECLS
#endif
#define RB_CAIRO_VERSION_MAJOR 1
-#define RB_CAIRO_VERSION_MINOR 12
-#define RB_CAIRO_VERSION_MICRO 9
+#define RB_CAIRO_VERSION_MINOR 14
+#define RB_CAIRO_VERSION_MICRO 0
RB_CAIRO_VAR VALUE rb_mCairo;
RB_CAIRO_VAR VALUE rb_cCairo_Context;
diff --git a/ext/cairo/rb_cairo_constants.c b/ext/cairo/rb_cairo_constants.c
index 67de3c1..e570c26 100644
--- a/ext/cairo/rb_cairo_constants.c
+++ b/ext/cairo/rb_cairo_constants.c
@@ -651,6 +651,14 @@ Init_cairo_constants (void)
rb_define_const (rb_mCairo_MimeType, "UNIQUE_ID",
rb_str_new2 (CAIRO_MIME_TYPE_UNIQUE_ID));
#endif
+#if CAIRO_CHECK_VERSION(1, 14, 0)
+ rb_define_const (rb_mCairo_MimeType, "JBIG2",
+ rb_str_new2 (CAIRO_MIME_TYPE_JBIG2));
+ rb_define_const (rb_mCairo_MimeType, "JBIG2_GLOBAL",
+ rb_str_new2 (CAIRO_MIME_TYPE_JBIG2_GLOBAL));
+ rb_define_const (rb_mCairo_MimeType, "JBIG2_GLOBAL_ID",
+ rb_str_new2 (CAIRO_MIME_TYPE_JBIG2_GLOBAL_ID));
+#endif
#if CAIRO_CHECK_VERSION(1, 10, 0)
rb_mCairo_RegionOverlap = rb_define_module_under (rb_mCairo, "RegionOverlap");
diff --git a/ext/cairo/rb_cairo_context.c b/ext/cairo/rb_cairo_context.c
index 90c567a..b4cf590 100644
--- a/ext/cairo/rb_cairo_context.c
+++ b/ext/cairo/rb_cairo_context.c
@@ -5,7 +5,7 @@
* $Author: kou $
* $Date: 2008-09-26 13:52:08 $
*
- * Copyright 2005-2010 Kouhei Sutou <kou at cozmixng.org>
+ * Copyright 2005-2014 Kouhei Sutou <kou at cozmixng.org>
* Copyright 2005 Øyvind Kolås <pippin at freedesktop.org>
* Copyright 2004-2005 MenTaLguY <mental at rydia.com>
*
@@ -130,6 +130,51 @@ cr_destroy_with_destroy_check (VALUE self)
}
static VALUE
+cr_s_wrap (VALUE self, VALUE pointer)
+{
+ VALUE result;
+ VALUE rb_cr;
+ cairo_t *cr;
+
+ if (NIL_P (rb_cairo__cFFIPointer))
+ {
+ rb_raise (rb_eNotImpError,
+ "%s: FFI::Pointer is required",
+ rb_id2name (rb_frame_this_func ()));
+ }
+
+ if (!RTEST (rb_obj_is_kind_of (pointer, rb_cairo__cFFIPointer)))
+ {
+ rb_raise (rb_eArgError,
+ "must be FFI::Pointer: %s",
+ rb_cairo__inspect (pointer));
+ }
+
+ {
+ VALUE rb_cr_address;
+ rb_cr_address = rb_funcall (pointer, rb_intern ("address"), 0);
+ cr = NUM2PTR (rb_cr_address);
+ cr_check_status (cr);
+ }
+
+ rb_cr = rb_obj_alloc (self);
+ cairo_reference (cr);
+ DATA_PTR (rb_cr) = cr;
+ rb_ivar_set (rb_cr, cr_id_surface, Qnil);
+
+ if (rb_block_given_p ())
+ {
+ result = rb_ensure (rb_yield, rb_cr, cr_destroy_with_destroy_check, rb_cr);
+ }
+ else
+ {
+ result = rb_cr;
+ }
+
+ return result;
+}
+
+static VALUE
cr_initialize (VALUE self, VALUE target)
{
cairo_t *cr;
@@ -138,6 +183,7 @@ cr_initialize (VALUE self, VALUE target)
cr = cairo_create (RVAL2CRSURFACE (target));
cr_check_status (cr);
rb_ivar_set (self, cr_id_surface, target);
+ rb_ivar_set (self, cr_id_source, Qnil);
if (rb_ivar_defined (target, rb_cairo__io_id_output))
cr_set_user_data (cr,
&cr_object_holder_key,
@@ -150,6 +196,17 @@ cr_initialize (VALUE self, VALUE target)
}
static VALUE
+cr_to_ptr (VALUE self)
+{
+ if (NIL_P (rb_cairo__cFFIPointer))
+ return Qnil;
+
+ return rb_funcall (rb_cairo__cFFIPointer, rb_intern ("new"),
+ 1, PTR2NUM (_SELF));
+}
+
+
+static VALUE
cr_restore (VALUE self)
{
cairo_restore (_SELF);
@@ -1526,6 +1583,9 @@ Init_cairo_context (void)
rb_cairo__initialize_gc_guard_holder_class (rb_cCairo_Context);
rb_set_end_proc(cr_destroy_all_guarded_contexts_at_end, Qnil);
+ /* For integrate other libraries such as a FFI based library. */
+ rb_define_singleton_method (rb_cCairo_Context, "wrap", cr_s_wrap, 1);
+
/* Functions for manipulating state objects */
rb_define_method (rb_cCairo_Context, "initialize", cr_initialize, 1);
rb_define_method (rb_cCairo_Context, "destroy", cr_destroy, 0);
@@ -1675,5 +1735,7 @@ Init_cairo_context (void)
rb_define_method (rb_cCairo_Context, "copy_path_flat", cr_copy_path_flat, 0);
rb_define_method (rb_cCairo_Context, "append_path", cr_copy_append_path, 1);
+ rb_define_method (rb_cCairo_Context, "to_ptr", cr_to_ptr, 0);
+
RB_CAIRO_DEF_SETTERS (rb_cCairo_Context);
}
diff --git a/ext/cairo/rb_cairo_exception.c b/ext/cairo/rb_cairo_exception.c
index 656bf9b..dd8886e 100644
--- a/ext/cairo/rb_cairo_exception.c
+++ b/ext/cairo/rb_cairo_exception.c
@@ -61,6 +61,9 @@ static VALUE rb_eCairo_DeviceError;
static VALUE rb_eCairo_InvalidMeshConstruction;
static VALUE rb_eCairo_DeviceFinished;
#endif
+#if CAIRO_CHECK_VERSION(1, 14, 0)
+static VALUE rb_eCairo_JBIG2GlobalMissing;
+#endif
void
rb_cairo_check_status (cairo_status_t status)
@@ -192,6 +195,11 @@ rb_cairo_check_status (cairo_status_t status)
rb_raise (rb_eCairo_DeviceFinished, "%s", string);
break;
#endif
+#if CAIRO_CHECK_VERSION(1, 14, 0)
+ case CAIRO_STATUS_JBIG2_GLOBAL_MISSING:
+ rb_raise (rb_eCairo_JBIG2GlobalMissing, "%s", string);
+ break;
+#endif
#if CAIRO_CHECK_VERSION(1, 10, 0)
case CAIRO_STATUS_LAST_STATUS:
#else
@@ -285,6 +293,10 @@ rb_cairo__exception_to_status (VALUE exception)
else if (rb_cairo__is_kind_of (exception, rb_eCairo_DeviceError))
return CAIRO_STATUS_DEVICE_ERROR;
#endif
+#if CAIRO_CHECK_VERSION(1, 14, 0)
+ else if (rb_cairo__is_kind_of (exception, rb_eCairo_JBIG2GlobalMissing))
+ return CAIRO_STATUS_JBIG2_GLOBAL_MISSING;
+#endif
return -1;
}
@@ -426,4 +438,9 @@ Init_cairo_exception ()
rb_define_class_under (rb_mCairo, "DeviceFinished",
rb_eCairo_Error);
#endif
+#if CAIRO_CHECK_VERSION(1, 14, 0)
+ rb_eCairo_JBIG2GlobalMissing =
+ rb_define_class_under (rb_mCairo, "JBIG2GlobalMissing",
+ rb_eCairo_Error);
+#endif
}
diff --git a/ext/cairo/rb_cairo_font_face.c b/ext/cairo/rb_cairo_font_face.c
index 89bd73a..c0fbecd 100644
--- a/ext/cairo/rb_cairo_font_face.c
+++ b/ext/cairo/rb_cairo_font_face.c
@@ -111,6 +111,16 @@ cr_font_face_allocate (VALUE klass)
return Data_Wrap_Struct (klass, NULL, cr_font_face_free, NULL);
}
+static VALUE
+cr_font_face_quartz_supported_p (VALUE klass)
+{
+#ifdef CAIRO_HAS_QUARTZ_FONT
+ return Qtrue;
+#else
+ return Qfalse;
+#endif
+}
+
#if CAIRO_CHECK_VERSION(1, 7, 6)
static VALUE
cr_toy_font_face_initialize (int argc, VALUE *argv, VALUE self)
@@ -652,6 +662,9 @@ Init_cairo_font (void)
rb_define_class_under (rb_mCairo, "FontFace", rb_cObject);
rb_define_alloc_func (rb_cCairo_FontFace, cr_font_face_allocate);
+ rb_define_singleton_method (rb_cCairo_FontFace, "quartz_supported?",
+ cr_font_face_quartz_supported_p, 0);
+
#if CAIRO_CHECK_VERSION(1, 7, 6)
rb_cCairo_ToyFontFace =
rb_define_class_under (rb_mCairo, "ToyFontFace", rb_cCairo_FontFace);
diff --git a/ext/cairo/rb_cairo_private.c b/ext/cairo/rb_cairo_private.c
index fbe416d..4ccaa7e 100644
--- a/ext/cairo/rb_cairo_private.c
+++ b/ext/cairo/rb_cairo_private.c
@@ -5,7 +5,7 @@
* $Author: kou $
* $Date: 2008-08-17 07:21:42 $
*
- * Copyright 2005-2008 Kouhei Sutou <kou at cozmixng.org>
+ * Copyright 2005-2014 Kouhei Sutou <kou at cozmixng.org>
*
* This file is made available under the same terms as Ruby
*
@@ -14,6 +14,8 @@
#include "rb_cairo.h"
#include "rb_cairo_private.h"
+VALUE rb_cairo__cFFIPointer;
+
static ID cr_id_normalize_const_name;
static ID cr_id_objects;
static ID cr_id_dup;
@@ -239,4 +241,15 @@ Init_cairo_private (void)
cr_id_dup = rb_intern ("dup");
cr_id_inspect = rb_intern ("inspect");
cr_id_exit_application = rb_intern ("exit_application");
+
+ if (rb_const_defined (rb_cObject, rb_intern ("FFI")))
+ {
+ rb_cairo__cFFIPointer =
+ rb_const_get (rb_const_get (rb_cObject, rb_intern ("FFI")),
+ rb_intern ("Pointer"));
+ }
+ else
+ {
+ rb_cairo__cFFIPointer = Qnil;
+ }
}
diff --git a/ext/cairo/rb_cairo_private.h b/ext/cairo/rb_cairo_private.h
index cb16894..14ad842 100644
--- a/ext/cairo/rb_cairo_private.h
+++ b/ext/cairo/rb_cairo_private.h
@@ -5,7 +5,7 @@
* $Author: kou $
* $Date: 2008-08-17 07:21:42 $
*
- * Copyright 2005-2008 Kouhei Sutou <kou at cozmixng.org>
+ * Copyright 2005-2014 Kouhei Sutou <kou at cozmixng.org>
*
* This file is made available under the same terms as Ruby
*
@@ -43,6 +43,15 @@
# define RB_ERRINFO (ruby_errinfo)
#endif
+/* from dl/dl.h (ruby 1.9) */
+#if SIZEOF_LONG == SIZEOF_VOIDP
+# define PTR2NUM(x) (ULONG2NUM((unsigned long)(x)))
+# define NUM2PTR(x) ((void *)(NUM2ULONG(x)))
+#else
+# define PTR2NUM(x) (ULL2NUM((unsigned long long)(x)))
+# define NUM2PTR(x) ((void *)(NUM2ULL(x)))
+#endif
+
extern void Init_cairo_private (void);
extern void Init_cairo_io (void);
extern void Init_cairo_constants (void);
@@ -115,4 +124,6 @@ cairo_status_t rb_cairo__exception_to_status (VALUE exception);
typedef VALUE (*cr_callback_func_t) (VALUE user_data);
VALUE rb_cairo__invoke_callback (cr_callback_func_t func, VALUE user_data);
+extern VALUE rb_cairo__cFFIPointer;
+
#endif
diff --git a/ext/cairo/rb_cairo_surface.c b/ext/cairo/rb_cairo_surface.c
index 28ccebf..66e846e 100644
--- a/ext/cairo/rb_cairo_surface.c
+++ b/ext/cairo/rb_cairo_surface.c
@@ -54,7 +54,8 @@ enum ruby_value_type {
# include <cairo-quartz.h>
# define T_DATA RUBY_T_DATA
# define RB_CAIRO_HAS_QUARTZ_SURFACE
-# ifdef RB_CAIRO_HAS_QUARTZ_IMAGE_SURFACE_TYPE
+# ifdef CAIRO_HAS_QUARTZ_IMAGE_SURFACE
+# include <cairo-quartz-image.h>
# define RB_CAIRO_HAS_QUARTZ_IMAGE_SURFACE
# endif
#endif
@@ -829,6 +830,27 @@ cr_surface_get_device_offset (VALUE self)
return rb_ary_new3 (2, rb_float_new (x_offset), rb_float_new (y_offset));
}
+#if CAIRO_CHECK_VERSION(1, 14, 0)
+static VALUE
+cr_surface_set_device_scale (VALUE self, VALUE x_scale, VALUE y_scale)
+{
+ cairo_surface_set_device_scale (_SELF,
+ NUM2DBL (x_scale),
+ NUM2DBL (y_scale));
+ cr_surface_check_status (_SELF);
+ return self;
+}
+
+static VALUE
+cr_surface_get_device_scale (VALUE self)
+{
+ double x_scale, y_scale;
+
+ cairo_surface_get_device_scale (_SELF, &x_scale, &y_scale);
+ return rb_ary_new3 (2, rb_float_new (x_scale), rb_float_new (y_scale));
+}
+#endif
+
static VALUE
cr_surface_set_fallback_resolution (VALUE self,
VALUE x_pixels_per_inch,
@@ -1199,8 +1221,10 @@ cr_ps_surface_set_eps (VALUE self, VALUE eps)
/* Quartz-surface functions */
#include <objc/objc-runtime.h>
+# ifdef HAVE_RUBY_COCOA
BOOL rbobj_to_nsobj (VALUE obj, id* nsobj);
VALUE ocid_to_rbobj (VALUE context_obj, id ocid);
+# endif
static VALUE
cr_quartz_surface_initialize (int argc, VALUE *argv, VALUE self)
@@ -1211,10 +1235,9 @@ cr_quartz_surface_initialize (int argc, VALUE *argv, VALUE self)
cairo_surface_t *surface = NULL;
cairo_format_t format = CAIRO_FORMAT_ARGB32;
VALUE arg1, arg2, arg3, rb_width, rb_height;
-#ifdef HAVE_RUBY_COCOA
+# ifdef HAVE_RUBY_COCOA
static VALUE rb_cOSXCGContextRef = Qnil;
-#endif
- static VALUE rb_cFFIPointer = Qnil;
+# endif
rb_scan_args (argc, argv, "21", &arg1, &arg2, &arg3);
@@ -1235,27 +1258,23 @@ cr_quartz_surface_initialize (int argc, VALUE *argv, VALUE self)
format = RVAL2CRFORMAT (arg1);
break;
default:
-#ifdef HAVE_RUBY_COCOA
+# ifdef HAVE_RUBY_COCOA
if (NIL_P (rb_cOSXCGContextRef))
rb_cOSXCGContextRef =
rb_const_get (rb_const_get (rb_cObject, rb_intern ("OSX")),
rb_intern ("CGContextRef"));
-#endif
-
- if (NIL_P (rb_cFFIPointer))
- rb_cFFIPointer =
- rb_const_get (rb_const_get (rb_cObject, rb_intern ("FFI")),
- rb_intern ("Pointer"));
+# endif
-#ifdef HAVE_RUBY_COCOA
+# ifdef HAVE_RUBY_COCOA
if (RTEST (rb_obj_is_kind_of (arg1, rb_cOSXCGContextRef)))
{
rbobj_to_nsobj (arg1, &objc_object);
}
else
-#endif
+# endif
{
- if (RTEST (rb_obj_is_kind_of (arg1, rb_cFFIPointer)))
+ if (!NIL_P (rb_cairo__cFFIPointer) &&
+ RTEST (rb_obj_is_kind_of (arg1, rb_cairo__cFFIPointer)))
{
VALUE rb_objc_pointer;
rb_objc_pointer = rb_funcall (arg1,
@@ -1305,27 +1324,25 @@ cr_quartz_surface_initialize (int argc, VALUE *argv, VALUE self)
static VALUE
cr_quartz_surface_get_cg_context (VALUE self)
{
+# ifdef HAVE_RUBY_COCOA
CGContextRef context;
id objc_object;
context = cairo_quartz_surface_get_cg_context (_SELF);
objc_object = (id)context;
return ocid_to_rbobj (Qnil, objc_object);
+# else
+ rb_raise (rb_eNotImpError,
+ "%s#cg_context requires RubyCocoa",
+ rb_obj_classname(self));
+ return Qnil;
+# endif
}
#endif
#ifdef CAIRO_HAS_WIN32_SURFACE
/* Win32 surface functions */
-/* from dl/dl.h (ruby 1.9) */
-# if SIZEOF_LONG == SIZEOF_VOIDP
-# define PTR2NUM(x) (ULONG2NUM((unsigned long)(x)))
-# define NUM2PTR(x) ((void *)(NUM2ULONG(x)))
-# else
-# define PTR2NUM(x) (ULL2NUM((unsigned long long)(x)))
-# define NUM2PTR(x) ((void *)(NUM2ULL(x)))
-# endif
-
static VALUE
cr_win32_surface_initialize (int argc, VALUE *argv, VALUE self)
{
@@ -1467,6 +1484,7 @@ cr_win32_printing_surface_initialize (VALUE self, VALUE hdc)
#endif
#ifdef RB_CAIRO_HAS_QUARTZ_IMAGE_SURFACE
+
/* Quartz image surface functions */
static VALUE
cr_quartz_image_surface_initialize (VALUE self, VALUE image_surface)
@@ -2005,6 +2023,12 @@ Init_cairo_surface (void)
cr_surface_set_device_offset, 2);
rb_define_method (rb_cCairo_Surface, "device_offset",
cr_surface_get_device_offset, 0);
+#if CAIRO_CHECK_VERSION(1, 14, 0)
+ rb_define_method (rb_cCairo_Surface, "set_device_scale",
+ cr_surface_set_device_scale, 2);
+ rb_define_method (rb_cCairo_Surface, "device_scale",
+ cr_surface_get_device_scale, 0);
+#endif
rb_define_method (rb_cCairo_Surface, "set_fallback_resolution",
cr_surface_set_fallback_resolution, 2);
#if CAIRO_CHECK_VERSION(1, 7, 2)
diff --git a/extconf.rb b/extconf.rb
new file mode 100755
index 0000000..c7721ab
--- /dev/null
+++ b/extconf.rb
@@ -0,0 +1,47 @@
+#!/usr/bin/env ruby
+
+require 'pathname'
+require 'mkmf'
+require 'rbconfig'
+require 'fileutils'
+
+base_dir = Pathname(__FILE__).dirname.expand_path
+ext_dir = base_dir + "ext" + "cairo"
+
+ruby = File.join(RbConfig::CONFIG['bindir'],
+ RbConfig::CONFIG['ruby_install_name'] +
+ RbConfig::CONFIG["EXEEXT"])
+
+build_ext_dir = Pathname(".") + "ext" + "cairo"
+FileUtils.mkdir_p(build_ext_dir.to_s)
+Dir.chdir(build_ext_dir.to_s) do
+ system(ruby, (ext_dir + "extconf.rb").to_s, *ARGV) || exit(false)
+end
+
+create_makefile("cairo")
+FileUtils.mv("Makefile", "Makefile.lib")
+
+File.open("Makefile", "w") do |makefile|
+ makefile.puts(<<-EOM)
+all:
+ (cd ext/cairo && $(MAKE))
+ $(MAKE) -f Makefile.lib
+
+install:
+ (cd ext/cairo && $(MAKE) install)
+ $(MAKE) -f Makefile.lib install
+
+site-install:
+ (cd ext/cairo && $(MAKE) site-install)
+ $(MAKE) -f Makefile.lib site-install
+
+clean:
+ (cd ext/cairo && $(MAKE) clean)
+ $(MAKE) -f Makefile.lib clean
+
+distclean:
+ (cd ext/cairo && $(MAKE) distclean)
+ $(MAKE) -f Makefile.lib distclean
+ @rm -f Makefile.lib
+EOM
+end
diff --git a/lib/cairo/surface.rb b/lib/cairo/surface.rb
index 5eccefc..d2fea5d 100644
--- a/lib/cairo/surface.rb
+++ b/lib/cairo/surface.rb
@@ -2,7 +2,9 @@ module Cairo
class Surface
class << self
def supported?(type)
- supported_predicate = "#{type.to_s.downcase}_supported?"
+ type_components = type.to_s.split(/([A-Z][a-z\d]+)/).reject(&:empty?)
+ snake_case_type_name = type_components.join("_").downcase
+ supported_predicate = "#{snake_case_type_name}_supported?"
return false unless respond_to?(supported_predicate)
send(supported_predicate)
end
diff --git a/metadata.yml b/metadata.yml
deleted file mode 100644
index 3ca67b7..0000000
--- a/metadata.yml
+++ /dev/null
@@ -1,225 +0,0 @@
---- !ruby/object:Gem::Specification
-name: cairo
-version: !ruby/object:Gem::Version
- version: 1.12.9
-platform: ruby
-authors:
-- Kouhei Sutou
-autorequire:
-bindir: bin
-cert_chain: []
-date: 2014-04-05 00:00:00.000000000 Z
-dependencies:
-- !ruby/object:Gem::Dependency
- name: pkg-config
- requirement: !ruby/object:Gem::Requirement
- requirements:
- - - '>='
- - !ruby/object:Gem::Version
- version: 1.1.5
- type: :runtime
- prerelease: false
- version_requirements: !ruby/object:Gem::Requirement
- requirements:
- - - '>='
- - !ruby/object:Gem::Version
- version: 1.1.5
-- !ruby/object:Gem::Dependency
- name: bundler
- requirement: !ruby/object:Gem::Requirement
- requirements:
- - - '>='
- - !ruby/object:Gem::Version
- version: '0'
- type: :development
- prerelease: false
- version_requirements: !ruby/object:Gem::Requirement
- requirements:
- - - '>='
- - !ruby/object:Gem::Version
- version: '0'
-- !ruby/object:Gem::Dependency
- name: test-unit-notify
- requirement: !ruby/object:Gem::Requirement
- requirements:
- - - '>='
- - !ruby/object:Gem::Version
- version: '0'
- type: :development
- prerelease: false
- version_requirements: !ruby/object:Gem::Requirement
- requirements:
- - - '>='
- - !ruby/object:Gem::Version
- version: '0'
-- !ruby/object:Gem::Dependency
- name: rake-compiler
- requirement: !ruby/object:Gem::Requirement
- requirements:
- - - '>='
- - !ruby/object:Gem::Version
- version: '0'
- type: :development
- prerelease: false
- version_requirements: !ruby/object:Gem::Requirement
- requirements:
- - - '>='
- - !ruby/object:Gem::Version
- version: '0'
-- !ruby/object:Gem::Dependency
- name: packnga
- requirement: !ruby/object:Gem::Requirement
- requirements:
- - - '>='
- - !ruby/object:Gem::Version
- version: '0'
- type: :development
- prerelease: false
- version_requirements: !ruby/object:Gem::Requirement
- requirements:
- - - '>='
- - !ruby/object:Gem::Version
- version: '0'
-description: Ruby bindings for cairo
-email:
-- kou at cozmixng.org
-executables: []
-extensions:
-- ext/cairo/extconf.rb
-extra_rdoc_files:
-- README.rdoc
-files:
-- AUTHORS
-- COPYING
-- GPL
-- Gemfile
-- NEWS
-- README.rdoc
-- ext/cairo/extconf.rb
-- Rakefile
-- lib/cairo.rb
-- lib/cairo/device.rb
-- lib/cairo/path.rb
-- lib/cairo/context/triangle.rb
-- lib/cairo/context/path.rb
-- lib/cairo/context/circle.rb
-- lib/cairo/context/color.rb
-- lib/cairo/context/blur.rb
-- lib/cairo/context/rectangle.rb
-- lib/cairo/context.rb
-- lib/cairo/paper.rb
-- lib/cairo/color.rb
-- lib/cairo/constants.rb
-- lib/cairo/surface.rb
-- lib/cairo/colors.rb
-- lib/cairo/point.rb
-- lib/cairo/pattern.rb
-- lib/cairo/papers.rb
-- samples/pac.rb
-- samples/png.rb
-- samples/pac-tee.rb
-- samples/scalable.rb
-- samples/pac-nomralize.rb
-- samples/text-on-path.rb
-- samples/blur.rb
-- samples/agg/aa_test.rb
-- samples/text2.rb
-- ext/cairo/cairo.def
-- ext/cairo/depend
-- ext/cairo/rb_cairo_surface.c
-- ext/cairo/rb_cairo_scaled_font.c
-- ext/cairo/rb_cairo_font_options.c
-- ext/cairo/rb_cairo_font_face.c
-- ext/cairo/rb_cairo_region.c
-- ext/cairo/rb_cairo_io.c
-- ext/cairo/rb_cairo_path.c
-- ext/cairo/rb_cairo_exception.c
-- ext/cairo/rb_cairo_font_extents.c
-- ext/cairo/rb_cairo_context.c
-- ext/cairo/rb_cairo.c
-- ext/cairo/rb_cairo_text_cluster.c
-- ext/cairo/rb_cairo_text_extents.c
-- ext/cairo/rb_cairo_pattern.c
-- ext/cairo/rb_cairo_private.c
-- ext/cairo/rb_cairo_matrix.c
-- ext/cairo/rb_cairo_glyph.c
-- ext/cairo/rb_cairo_rectangle.c
-- ext/cairo/rb_cairo_constants.c
-- ext/cairo/rb_cairo_device.c
-- ext/cairo/rb_cairo.h
-- ext/cairo/rb_cairo_io.h
-- ext/cairo/rb_cairo_private.h
-- test/test_text_extents.rb
-- test/test_font_face.rb
-- test/test_region.rb
-- test/test_exception.rb
-- test/test_font_extents.rb
-- test/test_scaled_font.rb
-- test/test_paper.rb
-- test/test_tee_surface.rb
-- test/test_text_to_glyphs_data.rb
-- test/test_constants.rb
-- test/test_script_surface.rb
-- test/run-test.rb
-- test/test_xml_device.rb
-- test/test_recording_surface.rb
-- test/test_color.rb
-- test/test_surface.rb
-- test/test_text_cluster.rb
-- test/cairo-test-utils.rb
-- test/test_font_options.rb
-- test/test_context.rb
-- test/test_script_device.rb
-- test/test_xml_surface.rb
-- test/test_raster_source_pattern.rb
-- test/test_image_surface.rb
-homepage: http://cairographics.org/rcairo
-licenses:
-- Ruby's
-metadata: {}
-post_install_message:
-rdoc_options: []
-require_paths:
-- lib
-required_ruby_version: !ruby/object:Gem::Requirement
- requirements:
- - - '>='
- - !ruby/object:Gem::Version
- version: '0'
-required_rubygems_version: !ruby/object:Gem::Requirement
- requirements:
- - - '>='
- - !ruby/object:Gem::Version
- version: '0'
-requirements: []
-rubyforge_project: cairo
-rubygems_version: 2.0.14
-signing_key:
-specification_version: 4
-summary: Ruby bindings for cairo
-test_files:
-- test/test_text_extents.rb
-- test/test_font_face.rb
-- test/test_region.rb
-- test/test_exception.rb
-- test/test_font_extents.rb
-- test/test_scaled_font.rb
-- test/test_paper.rb
-- test/test_tee_surface.rb
-- test/test_text_to_glyphs_data.rb
-- test/test_constants.rb
-- test/test_script_surface.rb
-- test/run-test.rb
-- test/test_xml_device.rb
-- test/test_recording_surface.rb
-- test/test_color.rb
-- test/test_surface.rb
-- test/test_text_cluster.rb
-- test/cairo-test-utils.rb
-- test/test_font_options.rb
-- test/test_context.rb
-- test/test_script_device.rb
-- test/test_xml_surface.rb
-- test/test_raster_source_pattern.rb
-- test/test_image_surface.rb
-has_rdoc:
diff --git a/misc/update-colors.rb b/misc/update-colors.rb
new file mode 100755
index 0000000..4f235de
--- /dev/null
+++ b/misc/update-colors.rb
@@ -0,0 +1,143 @@
+#!/usr/bin/env ruby
+
+begin
+ require 'scrapi'
+rescue LoadError
+ require 'rubygems'
+ require 'scrapi'
+end
+
+def collect_popular_colors(src=nil)
+ src ||= URI("http://en.wikipedia.org/wiki/List_of_colors")
+
+ row = Scraper.define do
+ process "th > a:first-child", :name => :text
+ process "td:nth-child(3)", :hex_triplet => :text
+ process "td:nth-child(4)", :red => :text
+ process "td:nth-child(5)", :green => :text
+ process "td:nth-child(6)", :blue => :text
+ result :name, :hex_triplet, :red, :green, :blue
+ end
+
+ scraper = Scraper.define do
+ process "table > tr", "rows[]" => row
+ result :rows
+ end
+
+ scraper.scrape(src)
+end
+
+def collect_x11_colors(src=nil)
+ src ||= URI("http://en.wikipedia.org/wiki/X11_color_names")
+
+ row = Scraper.define do
+ process "th", :name => :text
+ process "td:nth-child(2)", :hex_triplet => "@bgcolor"
+ process "td:nth-child(6)", :red => :text
+ process "td:nth-child(7)", :green => :text
+ process "td:nth-child(8)", :blue => :text
+ result :name, :hex_triplet, :red, :green, :blue
+ end
+
+ scraper = Scraper.define do
+ process "table > tr", "rows[]" => row
+ result :rows
+ end
+
+ x11_colors = scraper.scrape(src)
+ x11_colors.collect do |color|
+ if color.name
+ color.name = color.name.gsub(/([a-z]|[A-Z]+)([A-Z])/, "\\1 \\2")
+ end
+ color
+ end
+end
+
+def constanize_color_name(name)
+ names = name.gsub(/é/, "e").upcase.split(/(?:\s*\(|\)\s*)/)
+ names = names.collect {|name| name.gsub(/[ \-]/, "_")}
+ if names[1] and ["WEB", "COLOR_WHEEL", "X11"].include?(names[1])
+ real_names = [names.join("_")]
+ if names == ["ORANGE", "COLOR_WHEEL"]
+ real_names << names.first
+ end
+ names = real_names
+ end
+ names
+end
+
+colors = collect_popular_colors
+x11_colors = collect_x11_colors
+
+top_dir = File.expand_path(File.join(File.dirname(__FILE__), ".."))
+colors_rb = File.join(top_dir, "src", "lib", "cairo", "colors.rb")
+File.open(colors_rb, "w") do |rb|
+ rb.puts <<-HEADER
+require 'cairo/color'
+
+module Cairo
+ module Color
+HEADER
+
+ [
+ [colors, nil],
+ [x11_colors, "X11"]
+ ].each do |colors, mod|
+ indent = " " * 2
+ if mod
+ rb.puts("#{indent}module #{mod}")
+ indent << " "
+ end
+ colors.each do |color|
+ if color.name and color.hex_triplet and
+ color.red and color.green and color.blue
+ begin
+ names = constanize_color_name(color.name)
+
+ hexes = color.hex_triplet.scan(/[\da-f]{2,2}/i)
+ red_hex, green_hex, blue_hex = hexes.collect {|hex| hex.hex}
+
+ red = Integer(color.red)
+ green = Integer(color.green)
+ blue = Integer(color.blue)
+
+ if [red_hex, green_hex, blue_hex] != [red, green, blue]
+ warning_message = "Hex triplet(#{color.hex_triplet}) of "
+ warning_message << "#{color.name} is difference from RGB"
+ warning_message << "(#{red}, #{green}, #{blue}). "
+ if ["Alice Blue", "Old Rose"].include?(color.name)
+ warning_message << "Use hex triplet value."
+ red, green, blue = red_hex, green_hex, blue_hex
+ else
+ warning_message << "Use RGB value."
+ end
+ puts warning_message
+ end
+
+ r, g, b = [red, green, blue].collect {|v| v / 255.0}
+
+ rb.puts("#{indent}# #{color.name}: #{color.hex_triplet}")
+ name, *alias_names = names
+ rb.puts("#{indent}#{name} = RGB.new(#{r}, #{g}, #{b})")
+ alias_names.each do |alias_name|
+ rb.puts("#{indent}#{alias_name} = #{name}")
+ end
+ rescue ArgumentError
+ next
+ end
+ end
+ end
+
+ if mod
+ indent = indent[0..-3]
+ rb.puts("#{indent}end")
+ rb.puts("#{indent}include #{mod}")
+ rb.puts
+ end
+ end
+
+ rb.puts <<-FOOTER
+ end
+end
+FOOTER
+end
diff --git a/patches/cairo-1.14-missing-exeext-float-m4.diff b/patches/cairo-1.14-missing-exeext-float-m4.diff
new file mode 100644
index 0000000..cf373b3
--- /dev/null
+++ b/patches/cairo-1.14-missing-exeext-float-m4.diff
@@ -0,0 +1,17 @@
+diff --git a/build/aclocal.float.m4 b/build/aclocal.float.m4
+index bc0a91c..8f85f08 100644
+--- a/build/aclocal.float.m4
++++ b/build/aclocal.float.m4
+@@ -31,10 +31,10 @@ int main() { return 0; }
+
+ ]])], [
+
+-if strings - conftest | grep noonsees >/dev/null ; then
++if strings - conftest$ac_exeext | grep noonsees >/dev/null ; then
+ ax_cv_c_float_words_bigendian=yes
+ fi
+-if strings - conftest | grep seesnoon >/dev/null ; then
++if strings - conftest$ac_exeext | grep seesnoon >/dev/null ; then
+ if test "$ax_cv_c_float_words_bigendian" = unknown; then
+ ax_cv_c_float_words_bigendian=no
+ else
diff --git a/patches/fontconfig-2.11.1-disable-mktemp-s.diff b/patches/fontconfig-2.11.1-disable-mktemp-s.diff
new file mode 100644
index 0000000..df38ce8
--- /dev/null
+++ b/patches/fontconfig-2.11.1-disable-mktemp-s.diff
@@ -0,0 +1,12 @@
+diff -ur fontconfig-2.11.1.orig/configure.ac fontconfig-2.11.1/configure.ac
+--- fontconfig-2.11.1.orig/configure.ac 2014-03-24 15:03:12.000000000 +0900
++++ fontconfig-2.11.1/configure.ac 2014-04-05 14:45:30.701711217 +0900
+@@ -150,7 +150,7 @@
+ # Checks for library functions.
+ AC_FUNC_VPRINTF
+ AC_FUNC_MMAP
+-AC_CHECK_FUNCS([link mkstemp mkostemp _mktemp_s mkdtemp getopt getopt_long getprogname getexecname rand random lrand48 random_r rand_r readlink regcomp regerror regexec regfree fstatvfs fstatfs lstat])
++AC_CHECK_FUNCS([link mkstemp mkostemp mkdtemp getopt getopt_long getprogname getexecname rand random lrand48 random_r rand_r readlink regcomp regerror regexec regfree fstatvfs fstatfs lstat])
+
+ dnl AC_CHECK_FUNCS doesn't check for header files.
+ dnl posix_fadvise() may be not available in older libc.
diff --git a/patches/remove-empty-z_dir-ldflags.diff b/patches/remove-empty-z_dir-ldflags.diff
new file mode 100644
index 0000000..43a0d21
--- /dev/null
+++ b/patches/remove-empty-z_dir-ldflags.diff
@@ -0,0 +1,12 @@
+diff --git a/configure.ac b/configure.ac
+index 14ac0a8..8d3b173 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -392,7 +392,6 @@ if test "$with_zlib" = "no"; then
+ else
+ AC_CHECK_HEADERS(zlib.h,
+ [SAVE_LDFLAGS="${LDFLAGS}"
+- LDFLAGS="-L${Z_DIR}/lib"
+ AC_CHECK_LIB(z, gzread,[
+ AC_DEFINE([HAVE_LIBZ], [1], [Have compression library])
+ WITH_ZLIB=1
diff --git a/samples/.cvsignore b/samples/.cvsignore
new file mode 100644
index 0000000..0c8b2ac
--- /dev/null
+++ b/samples/.cvsignore
@@ -0,0 +1,4 @@
+*.pdf
+*.ps
+*.png
+
diff --git a/samples/agg/README b/samples/agg/README
new file mode 100644
index 0000000..a6257e5
--- /dev/null
+++ b/samples/agg/README
@@ -0,0 +1,4 @@
+There are many samples ported from Anti-Grain Geometry (AGG:
+http://www.antigrain.com/)
+
+They use Ruby/GTK+ for GUI.
diff --git a/test/.cvsignore b/test/.cvsignore
new file mode 100644
index 0000000..60a4de0
--- /dev/null
+++ b/test/.cvsignore
@@ -0,0 +1 @@
+.test-result
diff --git a/test/cairo-test-utils.rb b/test/cairo-test-utils.rb
index 894920c..bd7e9a7 100644
--- a/test/cairo-test-utils.rb
+++ b/test/cairo-test-utils.rb
@@ -1,5 +1,6 @@
require 'cairo'
require 'stringio'
+require 'test/unit/notify'
module CairoTestUtils
private
@@ -17,6 +18,10 @@ module CairoTestUtils
/cygwin|mingw|mswin32|bccwin32/.match(RUBY_PLATFORM) ? true : false
end
+ def quartz?
+ Cairo::FontFace.quartz_supported?
+ end
+
def only_device(name)
only_cairo_version(1, 10)
diff --git a/test/test_constants.rb b/test/test_constants.rb
index 424364c..159a18f 100644
--- a/test/test_constants.rb
+++ b/test/test_constants.rb
@@ -13,4 +13,15 @@ class ConstantsTest < Test::Unit::TestCase
[0,
Cairo::TextClusterFlag::BACKWARD])
end
+
+ def test_new_constants_since_1_14_0
+ if Cairo.satisfied_version?(1, 14, 0)
+ assertion = :assert_const_defined
+ else
+ assertion = :assert_not_const_defined
+ end
+ send(assertion, Cairo::MimeType, :JBIG2)
+ send(assertion, Cairo::MimeType, :JBIG2_GLOBAL)
+ send(assertion, Cairo::MimeType, :JBIG2_GLOBAL_ID)
+ end
end
diff --git a/test/test_context.rb b/test/test_context.rb
index d390e3f..813b8f6 100644
--- a/test/test_context.rb
+++ b/test/test_context.rb
@@ -73,7 +73,7 @@ class ContextTest < Test::Unit::TestCase
face = context.font_face
default_font_family = ""
- # default_font_family = "Helvetica" if quartz?
+ default_font_family = "Helvetica" if quartz?
default_font_family = "Arial" if win32?
assert_equal([default_font_family,
Cairo::FONT_SLANT_NORMAL,
diff --git a/test/test_exception.rb b/test/test_exception.rb
index 1782e86..bd1feb2 100644
--- a/test/test_exception.rb
+++ b/test/test_exception.rb
@@ -16,6 +16,15 @@ class ExceptionTest < Test::Unit::TestCase
send(assertion, "InvalidWeight")
end
+ def test_new_symbols_since_1_14_0
+ if Cairo.satisfied_version?(1, 14, 0)
+ assertion = :assert_defined
+ else
+ assertion = :assert_not_defined
+ end
+ send(assertion, "JBIG2GlobalMissing")
+ end
+
private
def assert_defined(name)
assert_true(Cairo.const_defined?(name))
diff --git a/test/test_font_face.rb b/test/test_font_face.rb
index a9a8b13..86882af 100644
--- a/test/test_font_face.rb
+++ b/test/test_font_face.rb
@@ -8,7 +8,7 @@ class FontFaceTest < Test::Unit::TestCase
face = Cairo::ToyFontFace.new
default_font_family = ""
- # default_font_family = "Helvetica" if quartz?
+ default_font_family = "Helvetica" if quartz?
default_font_family = "Arial" if win32?
assert_equal([default_font_family,
Cairo::FONT_SLANT_NORMAL,
diff --git a/test/test_quartz_image_surface.rb b/test/test_quartz_image_surface.rb
new file mode 100644
index 0000000..298d363
--- /dev/null
+++ b/test/test_quartz_image_surface.rb
@@ -0,0 +1,13 @@
+class QuartzImageSurfaceTest < Test::Unit::TestCase
+ include CairoTestUtils
+
+ def setup
+ only_surface("QuartzImage")
+ end
+
+ def test_quartz_image_surface
+ surface = Cairo::ImageSurface.new(100, 100)
+ quartz_surface = Cairo::QuartzImageSurface.new(surface)
+ assert_kind_of(Cairo::QuartzImageSurface, quartz_surface)
+ end
+end
diff --git a/test/test_surface.rb b/test/test_surface.rb
index ddb76db..6be327b 100644
--- a/test/test_surface.rb
+++ b/test/test_surface.rb
@@ -28,6 +28,16 @@ class SurfaceTest < Test::Unit::TestCase
end
end
+ def test_device_scale
+ only_cairo_version(1, 14, 0)
+ surface = Cairo::ImageSurface.new(100, 100)
+
+ assert_equal([1.0, 1.0], surface.device_scale)
+
+ surface.set_device_scale(3.0, 4.0)
+ assert_equal([3.0, 4.0], surface.device_scale)
+ end
+
def test_fallback_resolution
only_cairo_version(1, 7, 2)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-cairo.git
More information about the Pkg-ruby-extras-commits
mailing list