cheapredwine 0.0.2

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.
@@ -0,0 +1,24 @@
1
+ require 'cheapredwine/image/params'
2
+
3
+ include CheapRedWine::Image
4
+
5
+ describe Params do
6
+ it "takes a bunch of options" do
7
+ font = double
8
+ features = ['kern', 'aalt', 'onum', 'liga']
9
+
10
+ params = Params.new(
11
+ font: font,
12
+ color: 'black',
13
+ features: features,
14
+ text: 'Lorem ipsum',
15
+ size: 26
16
+ )
17
+
18
+ params.font.should eq font
19
+ params.color.should eq 'black'
20
+ params.features.should eq features
21
+ params.text.should eq 'Lorem ipsum'
22
+ params.size.should eq 26
23
+ end
24
+ end
@@ -0,0 +1,22 @@
1
+ require 'cheapredwine/image/writer'
2
+ require 'cheapredwine/image/params'
3
+
4
+ include CheapRedWine::Image
5
+
6
+ describe Writer do
7
+ let(:font) { double("font", path: "spec/fixtures/lato-regular.ttf") }
8
+ let(:image) { Params.new(font: font, text: "Lorem ipsum") }
9
+
10
+ it "builds a command from a Params object" do
11
+ writer = Writer.new(image)
12
+ writer.args[0].should eq "--font-file=spec/fixtures/lato-regular.ttf"
13
+ end
14
+
15
+ it "generates a image of given text" do
16
+ file = File.new('spec/fixtures/test.png')
17
+
18
+ writer = Writer.new(image)
19
+ tempfile = writer.exec
20
+ FileUtils.compare_file(tempfile, file)
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ require 'cheapredwine/ttx/extractor'
2
+
3
+ include CheapRedWine::TTX
4
+
5
+ describe Extractor do
6
+ before do
7
+ font_file = File.new('spec/fixtures/extractor/hobo.otf')
8
+ @extractor = Extractor.new(font_file, 'spec/fixtures/extractor')
9
+ end
10
+
11
+ after do
12
+ File.delete('spec/fixtures/extractor/hobo.ttx')
13
+ end
14
+
15
+ it "converts font files to readable ttx file" do
16
+ File.exist?('spec/fixtures/extractor/hobo.ttx').should be true
17
+ end
18
+
19
+ it "has a reference to the ttx file" do
20
+ @extractor.ttx_file.path.should eq 'spec/fixtures/extractor/hobo.ttx'
21
+ end
22
+ end
@@ -0,0 +1,17 @@
1
+ require 'cheapredwine/ttx/parser'
2
+
3
+ include CheapRedWine::TTX
4
+
5
+ describe Parser do
6
+ let(:file) { File.open('spec/fixtures/parser/hobo.ttx') }
7
+ let(:ttx) { Parser.new(file) }
8
+
9
+ it "parses a list of opentype features from ttx files" do
10
+ ttx.features.should eq ["kern", "size", "aalt", "frac", "liga", "ordn", "sups"]
11
+ end
12
+
13
+ it "parses name font family and font name" do
14
+ ttx.family_name.should eq "Hobo Std"
15
+ ttx.font_name.should eq "Hobo Std Medium"
16
+ end
17
+ end
data/spec/ttx_spec.rb ADDED
@@ -0,0 +1,23 @@
1
+ require 'cheapredwine/ttx'
2
+
3
+ include CheapRedWine
4
+
5
+ describe TTX do
6
+ it "has configuration options" do
7
+ TTX.configure do |config|
8
+ config.output_folder = 'spec/fixtures/ttx'
9
+ end
10
+
11
+ TTX.configuration.output_folder.should eq 'spec/fixtures/ttx'
12
+ end
13
+
14
+ it "generates a ttx parser from a font file" do
15
+ font = File.new('spec/fixtures/ttx/hobo.otf')
16
+ TTX.configuration.output_folder = 'spec/fixtures/ttx'
17
+
18
+ parser = TTX.for_font(font)
19
+ parser.class.should eq TTX::Parser
20
+
21
+ parser.family_name.should eq "Hobo Std"
22
+ end
23
+ end
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cheapredwine
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Hugo Bastien
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-02-24 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: nokogiri
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: I needed a way to test fonts on the web. I based this library on myfonts.com.
47
+ CheapRedWine makes use to Harfbuzz' hb-view utility to generate images from fonts
48
+ with a slew of different parameters. It also uses fontTools' ttx utility for font
49
+ introspection.
50
+ email:
51
+ - hugo@hbastien.com
52
+ executables: []
53
+ extensions: []
54
+ extra_rdoc_files: []
55
+ files:
56
+ - .gitignore
57
+ - Gemfile
58
+ - LICENSE.txt
59
+ - README.md
60
+ - Rakefile
61
+ - cheapredwine.gemspec
62
+ - lib/cheapredwine.rb
63
+ - lib/cheapredwine/image.rb
64
+ - lib/cheapredwine/image/params.rb
65
+ - lib/cheapredwine/image/writer.rb
66
+ - lib/cheapredwine/ttx.rb
67
+ - lib/cheapredwine/ttx/extractor.rb
68
+ - lib/cheapredwine/ttx/parser.rb
69
+ - lib/cheapredwine/version.rb
70
+ - spec/cheapredwine_spec.rb
71
+ - spec/fixtures/extractor/hobo.otf
72
+ - spec/fixtures/hobo.otf
73
+ - spec/fixtures/hobo.ttx
74
+ - spec/fixtures/lato-regular.ttf
75
+ - spec/fixtures/parser/features.ttx
76
+ - spec/fixtures/parser/hobo.ttx
77
+ - spec/fixtures/parser/lato-regular.ttx
78
+ - spec/fixtures/test.png
79
+ - spec/fixtures/ttx/hobo.otf
80
+ - spec/fixtures/ttx/hobo.ttx
81
+ - spec/image/params_spec.rb
82
+ - spec/image/writer_spec.rb
83
+ - spec/ttx/extrator_spec.rb
84
+ - spec/ttx/parser_spec.rb
85
+ - spec/ttx_spec.rb
86
+ homepage: ''
87
+ licenses: []
88
+ post_install_message:
89
+ rdoc_options: []
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ none: false
94
+ requirements:
95
+ - - ! '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ! '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ requirements: []
105
+ rubyforge_project:
106
+ rubygems_version: 1.8.23
107
+ signing_key:
108
+ specification_version: 3
109
+ summary: I needed a way to test fonts on the web. I based this library on myfonts.com.
110
+ CheapRedWine makes use to Harfbuzz' hb-view utility to generate images from fonts
111
+ with a slew of different parameters. It also uses fontTools' ttx utility for font
112
+ introspection.
113
+ test_files:
114
+ - spec/cheapredwine_spec.rb
115
+ - spec/fixtures/extractor/hobo.otf
116
+ - spec/fixtures/hobo.otf
117
+ - spec/fixtures/hobo.ttx
118
+ - spec/fixtures/lato-regular.ttf
119
+ - spec/fixtures/parser/features.ttx
120
+ - spec/fixtures/parser/hobo.ttx
121
+ - spec/fixtures/parser/lato-regular.ttx
122
+ - spec/fixtures/test.png
123
+ - spec/fixtures/ttx/hobo.otf
124
+ - spec/fixtures/ttx/hobo.ttx
125
+ - spec/image/params_spec.rb
126
+ - spec/image/writer_spec.rb
127
+ - spec/ttx/extrator_spec.rb
128
+ - spec/ttx/parser_spec.rb
129
+ - spec/ttx_spec.rb