cheapredwine 0.0.2 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +11 -3
- data/cheapredwine.gemspec +1 -1
- data/lib/cheapredwine/version.rb +1 -1
- data/lib/cheapredwine.rb +15 -10
- data/spec/cheapredwine_spec.rb +10 -5
- metadata +3 -3
data/README.md
CHANGED
@@ -18,7 +18,7 @@ It assumes the following is installed and in the case where it applies, accessib
|
|
18
18
|
|
19
19
|
* [cairo](http://www.cairographics.org/releases/)
|
20
20
|
* [harfbuzz](http://www.freedesktop.org/software/harfbuzz/release/)
|
21
|
-
* [ttx](
|
21
|
+
* [ttx](https://github.com/mcolyer/fonttools)
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
@@ -32,8 +32,7 @@ It assumes the following is installed and in the case where it applies, accessib
|
|
32
32
|
|
33
33
|
image = CheapRedWine.image(font, "some text", options)
|
34
34
|
|
35
|
-
`image` is an IO object that can then be use to write to disk
|
36
|
-
|
35
|
+
**Caveat: ** `image` is an IO object that can then be use to write to disk. `font` is any object that responds to `#features` and produces a list `["onum", "liga"]` as well as provide a font file object through `#file`. `file` need only know of it's full path to work properly.
|
37
36
|
|
38
37
|
##### Options
|
39
38
|
|
@@ -51,6 +50,10 @@ CheapRedWine needs to know where to put ttx files
|
|
51
50
|
CheapRedWine::TTX.configure do |config|
|
52
51
|
config.output_folder = '/path/to/folder'
|
53
52
|
end
|
53
|
+
|
54
|
+
You can also change the output_folder dynamically through
|
55
|
+
|
56
|
+
CheapRedWine.ttx_output_folder = "path/to/folder"
|
54
57
|
|
55
58
|
## Contributing
|
56
59
|
|
@@ -59,3 +62,8 @@ CheapRedWine needs to know where to put ttx files
|
|
59
62
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
60
63
|
4. Push to the branch (`git push origin my-new-feature`)
|
61
64
|
5. Create new Pull Request
|
65
|
+
|
66
|
+
## TODO
|
67
|
+
|
68
|
+
1. Create a new utility using fontTools to have more granularity regarding ttx file outputs
|
69
|
+
2. Replace hb-view by something more appropriate (C Extension).
|
data/cheapredwine.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |gem|
|
|
10
10
|
gem.email = ["hugo@hbastien.com"]
|
11
11
|
gem.description = %q{I needed a way to test fonts on the web. I based this library on myfonts.com. CheapRedWine makes use to Harfbuzz' hb-view utility to generate images from fonts with a slew of different parameters. It also uses fontTools' ttx utility for font introspection.}
|
12
12
|
gem.summary = %q{I needed a way to test fonts on the web. I based this library on myfonts.com. CheapRedWine makes use to Harfbuzz' hb-view utility to generate images from fonts with a slew of different parameters. It also uses fontTools' ttx utility for font introspection.}
|
13
|
-
gem.homepage = ""
|
13
|
+
gem.homepage = "https://github.com/hugobast/cheapredwine"
|
14
14
|
|
15
15
|
gem.files = `git ls-files`.split($/)
|
16
16
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
data/lib/cheapredwine/version.rb
CHANGED
data/lib/cheapredwine.rb
CHANGED
@@ -2,12 +2,9 @@ require "cheapredwine/version"
|
|
2
2
|
require "cheapredwine/ttx"
|
3
3
|
require "cheapredwine/image"
|
4
4
|
|
5
|
-
CheapRedWine::TTX.configure do |config|
|
6
|
-
config.output_folder = 'spec/fixtures'
|
7
|
-
end
|
8
5
|
|
9
6
|
module CheapRedWine
|
10
|
-
class
|
7
|
+
class Meta
|
11
8
|
attr_accessor :name, :family, :features, :path
|
12
9
|
|
13
10
|
def initialize
|
@@ -19,13 +16,13 @@ module CheapRedWine
|
|
19
16
|
end
|
20
17
|
end
|
21
18
|
|
22
|
-
def self.
|
19
|
+
def self.meta(file)
|
23
20
|
parser = TTX.for_font(file)
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
21
|
+
Meta.new do |meta|
|
22
|
+
meta.name = parser.font_name
|
23
|
+
meta.family = parser.family_name
|
24
|
+
meta.features = parser.features
|
25
|
+
meta.path = file
|
29
26
|
end
|
30
27
|
end
|
31
28
|
|
@@ -40,6 +37,14 @@ module CheapRedWine
|
|
40
37
|
Image::Writer.new(params).exec
|
41
38
|
end
|
42
39
|
|
40
|
+
def self.ttx_output_folder=(folder)
|
41
|
+
CheapRedWine::TTX.configuration.output_folder = folder
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.ttx_output_folder
|
45
|
+
CheapRedWine::TTX.configuration.output_folder
|
46
|
+
end
|
47
|
+
|
43
48
|
private
|
44
49
|
|
45
50
|
def self.merge_features(all_features, selected_features)
|
data/spec/cheapredwine_spec.rb
CHANGED
@@ -3,16 +3,21 @@ require 'tempfile'
|
|
3
3
|
|
4
4
|
describe CheapRedWine do
|
5
5
|
let(:file) { File.new('spec/fixtures/hobo.otf') }
|
6
|
-
let(:
|
6
|
+
let(:meta) { CheapRedWine.meta(file) }
|
7
7
|
|
8
|
-
it "
|
9
|
-
|
10
|
-
|
8
|
+
it "sets the output folder" do
|
9
|
+
CheapRedWine.ttx_output_folder = "spec/fixtures"
|
10
|
+
CheapRedWine.ttx_output_folder.should eq "spec/fixtures"
|
11
|
+
end
|
12
|
+
|
13
|
+
it "gets meta information from a font file" do
|
14
|
+
meta.name.should eq "Hobo Std Medium"
|
15
|
+
meta.file.path.should match file.path
|
11
16
|
end
|
12
17
|
|
13
18
|
it "can create images from text" do
|
14
19
|
options = { size: 26, features: ['liga', 'frac'] }
|
15
|
-
image = CheapRedWine.image(
|
20
|
+
image = CheapRedWine.image(meta, 'ffi 1/2', options)
|
16
21
|
tempfile = Tempfile.new('image')
|
17
22
|
tempfile.write(image.read)
|
18
23
|
tempfile.close
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cheapredwine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -83,7 +83,7 @@ files:
|
|
83
83
|
- spec/ttx/extrator_spec.rb
|
84
84
|
- spec/ttx/parser_spec.rb
|
85
85
|
- spec/ttx_spec.rb
|
86
|
-
homepage:
|
86
|
+
homepage: https://github.com/hugobast/cheapredwine
|
87
87
|
licenses: []
|
88
88
|
post_install_message:
|
89
89
|
rdoc_options: []
|