gir_ffi-pango 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # GirFFI-Pango
2
+
3
+ GirFFI-based bindings for Pango
4
+
5
+ ## Usage
6
+
7
+ require 'gir_ffi-gtk3'
8
+ require 'gir_ffi-pango'
9
+
10
+ Gtk.init
11
+
12
+ ctx = Gdk.pango_context_get
13
+ fontmap = ctx.get_font_map
14
+ fd = Pango::FontDescription.new
15
+ fd.set_family "Sans"
16
+ fnt = fontmap.load_font ctx, fd
17
+ puts fnt.describe.to_string
18
+
19
+ lang = Pango::Language.from_string "en"
20
+ puts lang.get_stripts
21
+
22
+ ## Install
23
+
24
+ gem install gir_ffi-pango
25
+
26
+ ## License
27
+
28
+ Copyright 2012, [Matijs van Zuijlen](http://www.matijs.net/)
29
+
30
+ GirFFI-Pango is free software, distributed under the terms of the GNU Lesser
31
+ General Public License, version 2.1 or later. See the file COPYING.LIB for
32
+ more information.
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ require 'rake/testtask'
2
+
3
+ namespace :test do
4
+ Rake::TestTask.new(:unit) do |t|
5
+ t.libs = ['lib']
6
+ t.test_files = FileList['test/unit/*_test.rb']
7
+ t.warning = true
8
+ end
9
+
10
+ Rake::TestTask.new(:end_to_end) do |t|
11
+ t.libs = ['lib']
12
+ t.test_files = FileList['test/end_to_end/*_test.rb']
13
+ t.warning = true
14
+ end
15
+
16
+ task :all => [:unit, :end_to_end]
17
+ end
18
+
19
+ task :test => 'test:all'
20
+
21
+ task :default => 'test'
@@ -0,0 +1,14 @@
1
+ module Pango
2
+ load_class :Font
3
+
4
+ class Font
5
+ def get_coverage lang
6
+ ptr = Lib.pango_font_get_coverage(self, lang)
7
+ Pango::Coverage.wrap ptr
8
+ end
9
+ end
10
+
11
+ module Lib
12
+ attach_function :pango_font_get_coverage, [:pointer, :pointer], :pointer
13
+ end
14
+ end
@@ -0,0 +1,17 @@
1
+ module Pango
2
+ load_class :Language
3
+
4
+ class Language
5
+ _setup_instance_method "get_scripts"
6
+
7
+ def get_scripts_with_override
8
+ ptr, num = self.get_scripts_without_override
9
+ vals = GirFFI::ArgHelper.ptr_to_typed_array :gint32, ptr, num
10
+ vals.map {|val| Pango::Script[val]}
11
+ end
12
+
13
+ alias get_scripts_without_override get_scripts
14
+ alias get_scripts get_scripts_with_override
15
+ end
16
+ end
17
+
@@ -0,0 +1,6 @@
1
+ require 'gir_ffi'
2
+
3
+ GirFFI.setup :Pango
4
+
5
+ require 'gir_ffi-pango/font'
6
+ require 'gir_ffi-pango/language'
@@ -0,0 +1,21 @@
1
+ require File.expand_path('../test_helper.rb', File.dirname(__FILE__))
2
+
3
+ describe Pango::Font do
4
+ it "allows retrieval of coverage information" do
5
+ ctx = Gdk.pango_context_get
6
+
7
+ fontmap = ctx.get_font_map
8
+ fd = Pango::FontDescription.new
9
+ fnt = fontmap.load_font ctx, fd
10
+
11
+ lang = Pango::Language.from_string 'en'
12
+ cov = fnt.get_coverage lang
13
+
14
+ clist = "Hello Pango!".each_codepoint.map {|cp| cov.get cp}
15
+
16
+ clist.uniq.each do |cval|
17
+ [:none, :fallback, :approximate, :exact].must_include cval
18
+ end
19
+ end
20
+ end
21
+
@@ -0,0 +1,7 @@
1
+ require 'minitest/spec'
2
+ require 'minitest/autorun'
3
+
4
+ require 'gir_ffi-pango'
5
+
6
+ GirFFI.setup :Gdk
7
+ Gdk.init []
@@ -0,0 +1,25 @@
1
+ require File.expand_path('../test_helper.rb', File.dirname(__FILE__))
2
+
3
+ describe Pango::Font do
4
+ before do
5
+ ctx = Gdk.pango_context_get
6
+ fontmap = ctx.get_font_map
7
+ fd = Pango::FontDescription.new
8
+ @fnt = fontmap.load_font ctx, fd
9
+ end
10
+
11
+ describe "#get_coverage" do
12
+ before do
13
+ lang = Pango::Language.from_string 'en'
14
+ @cov = @fnt.get_coverage lang
15
+ end
16
+
17
+ it "returns an instance of Pango::Coverage" do
18
+ @cov.must_be_instance_of Pango::Coverage
19
+ end
20
+
21
+ it "returns valid coverage info" do
22
+ @cov.get(" ".ord).must_equal :exact
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,27 @@
1
+ require File.expand_path('../test_helper.rb', File.dirname(__FILE__))
2
+
3
+ describe Pango::Language do
4
+ it "creates an instance with .from_string" do
5
+ lang = Pango::Language.from_string 'en'
6
+ lang.wont_be_nil
7
+ lang.must_be_instance_of Pango::Language
8
+ end
9
+
10
+ describe "#get_scripts" do
11
+ it "returns an array of symbols representing scripts" do
12
+ lang = Pango::Language.from_string 'ja'
13
+ scripts = lang.get_scripts.sort
14
+ scripts.must_equal [:han, :hiragana, :katakana]
15
+ end
16
+
17
+ it "can safely be run twice" do
18
+ lang = Pango::Language.from_string 'en'
19
+
20
+ result = lang.get_scripts
21
+ result.must_equal [:latin]
22
+
23
+ result = lang.get_scripts
24
+ result.must_equal [:latin]
25
+ end
26
+ end
27
+ end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gir_ffi-pango
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Matijs van Zuijlen
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: gir_ffi
16
+ requirement: &17961360 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.3.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *17961360
25
+ - !ruby/object:Gem::Dependency
26
+ name: minitest
27
+ requirement: &17960860 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '2.11'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *17960860
36
+ - !ruby/object:Gem::Dependency
37
+ name: rake
38
+ requirement: &17960380 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 0.9.2
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *17960380
47
+ description: Bindings for Pango generated by GirFFI, with an eclectic set of overrides.
48
+ email:
49
+ - matijs@matijs.net
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - lib/gir_ffi-pango.rb
55
+ - lib/gir_ffi-pango/font.rb
56
+ - lib/gir_ffi-pango/language.rb
57
+ - test/test_helper.rb
58
+ - test/end_to_end/font_test.rb
59
+ - test/unit/font_test.rb
60
+ - test/unit/language_test.rb
61
+ - README.md
62
+ - Rakefile
63
+ homepage: http://www.github.com/mvz/gir_ffi-pango
64
+ licenses: []
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ! '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 1.8.11
84
+ signing_key:
85
+ specification_version: 3
86
+ summary: GirFFI-based bindings for Pango
87
+ test_files:
88
+ - test/test_helper.rb
89
+ - test/end_to_end/font_test.rb
90
+ - test/unit/font_test.rb
91
+ - test/unit/language_test.rb