dragonfly_fonts 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e8295884fc4ed5f5a1211ca7451663442b95c58b
4
- data.tar.gz: 363818977f8bb82904d0a78e585ace9514cc9984
3
+ metadata.gz: 6bdafca40ba1e9ece52bea6a2a215954a7bdba44
4
+ data.tar.gz: b81b143b37597fe750b47b4834a506395f1a9689
5
5
  SHA512:
6
- metadata.gz: cdee62f76a8b86bd25611308185c272ee092d46c1127e7f6fe33671d5f49a06f3c9e5ae3dc171f7eb7a33c298df968816ef1591c5b0e0a3ed9d596a8852802af
7
- data.tar.gz: 9f268f9eb280eff1b46b2da18d9b8c498030bbd24e913cf503c922a20bfca0547d76221f3fb43fb15c968e6915e0162669c1c651a5f53211c2a8ed13b3ffead5
6
+ metadata.gz: 3e8f02ec97b1e571d9dd5ac9c8b1218764ba27416a2da4e0eec2f7ad760b5365689e99f09c8b99620f28166d1fa16b9851765b5b9311f45c19ec4b5f20a23adf
7
+ data.tar.gz: 65b599971680552ede3c429e8540e0ef6d3c8ac5eabc789520fe0143de9dcc1cda9f61a936e61707a390394b5640dd5d57070d2be0ccc1ca9333c569a4f33747
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Dragonfly Fonts
2
2
 
3
- [![Circle CI](https://circleci.com/gh/tomasc/dragonfly_fonts.svg?style=svg&circle-token=3b836116bd1aaa6b76103b45ab0caef112b3df94)](https://circleci.com/gh/tomasc/dragonfly_fonts)
3
+ [![Circle CI](https://circleci.com/gh/tomasc/dragonfly_fonts.svg?style=svg&circle-token=3b836116bd1aaa6b76103b45ab0caef112b3df94)](https://circleci.com/gh/tomasc/dragonfly_fonts) [![Gem Version](https://badge.fury.io/rb/dragonfly_fonts.svg)](http://badge.fury.io/rb/dragonfly_fonts) [![Coverage Status](https://img.shields.io/coveralls/tomasc/dragonfly_fonts.svg)](https://coveralls.io/r/tomasc/dragonfly_fonts)
4
4
 
5
5
  Wraps common font-related tasks into [Dragonfly](http://markevans.github.io/dragonfly) analysers and processors.
6
6
 
@@ -32,6 +32,10 @@ Using debian/ubuntu packages:
32
32
 
33
33
  $ sudo apt-get install fontforge python-fontforge
34
34
 
35
+ ### ot-sanitise
36
+
37
+ See [ot-sanitise](https://github.com/khaledhosny/ots)
38
+
35
39
  ### ttf2eot
36
40
 
37
41
  See [ttf2eot](http://code.google.com/p/ttf2eot).
@@ -88,6 +92,15 @@ Returns `Array` of gsub tables in the font.
88
92
  font.gsub_tables
89
93
  ```
90
94
 
95
+ ### OT Sanitise
96
+
97
+ Displays output of the `ot-sanitise` command.
98
+
99
+ ```ruby
100
+ font.ot_sanitise
101
+
102
+ ```
103
+
91
104
  ## Processors
92
105
 
93
106
  ### Correct Metrics
@@ -126,6 +139,14 @@ Fix for rejected EOT's in IE8.
126
139
  font.normalize_names
127
140
  ```
128
141
 
142
+ ### OTS
143
+
144
+ Sanitise OTF/TTF & WOFF/2 font files.
145
+
146
+ ```ruby
147
+ font.ot_sanitise!
148
+ ```
149
+
129
150
  ### Set Dimensions
130
151
 
131
152
  Adjust ascent & descent by an increment of.
data/Rakefile CHANGED
@@ -1,9 +1,10 @@
1
1
  require 'bundler/gem_tasks'
2
2
  require 'rake/testtask'
3
-
4
- Rake::TestTask.new do |t|
5
- t.libs << 'test'
6
- t.pattern = 'test/**/*_test.rb'
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*_test.rb']
7
8
  end
8
9
 
9
- task :default => :test
10
+ task :default => :test
@@ -4,25 +4,25 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'dragonfly_fonts/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "dragonfly_fonts"
7
+ spec.name = 'dragonfly_fonts'
8
8
  spec.version = DragonflyFonts::VERSION
9
- spec.authors = ["Tomas Celizna"]
10
- spec.email = ["tomas.celizna@gmail.com"]
11
- spec.summary = %q{Wraps common font-related tasks into Dragonfly analysers and processors.}
12
- spec.homepage = "https://github.com/tomasc/dragonfly_fonts"
13
- spec.license = "MIT"
9
+ spec.authors = ['Tomas Celizna']
10
+ spec.email = ['tomas.celizna@gmail.com']
11
+ spec.summary = 'Wraps common font-related tasks into Dragonfly analysers and processors.'
12
+ spec.homepage = 'https://github.com/tomasc/dragonfly_fonts'
13
+ spec.license = 'MIT'
14
14
 
15
- spec.files = `git ls-files -z`.split("\x0")
16
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
- spec.require_paths = ["lib"]
19
-
20
- spec.add_dependency "dragonfly", "~> 1.0"
15
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ spec.bindir = 'exe'
17
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ spec.require_paths = ['lib']
21
19
 
22
- spec.add_development_dependency "bundler", "~> 1.6"
23
- spec.add_development_dependency "rake"
24
- spec.add_development_dependency "nokogiri"
25
- spec.add_development_dependency "guard"
26
- spec.add_development_dependency "guard-minitest"
27
- spec.add_development_dependency "minitest"
20
+ spec.add_dependency 'dragonfly', '~> 1.0'
21
+
22
+ spec.add_development_dependency 'bundler', '~> 1.12'
23
+ spec.add_development_dependency 'guard'
24
+ spec.add_development_dependency 'guard-minitest'
25
+ spec.add_development_dependency 'minitest', '~> 5.0'
26
+ spec.add_development_dependency 'nokogiri'
27
+ spec.add_development_dependency 'rake', '~> 10.0'
28
28
  end
@@ -0,0 +1,17 @@
1
+ require 'open3'
2
+
3
+ module DragonflyFonts
4
+ module Analysers
5
+ class OtSanitise
6
+ def call(font)
7
+ `#{ot_sanitise_command} #{font.path} 2>&1`
8
+ end
9
+
10
+ private
11
+
12
+ def ot_sanitise_command
13
+ 'ot-sanitise'
14
+ end
15
+ end
16
+ end
17
+ end
@@ -2,11 +2,13 @@ require 'dragonfly_fonts/analysers/bbox'
2
2
  require 'dragonfly_fonts/analysers/font_info'
3
3
  require 'dragonfly_fonts/analysers/glyphs'
4
4
  require 'dragonfly_fonts/analysers/gsub_tables'
5
+ require 'dragonfly_fonts/analysers/ot_sanitise'
5
6
 
6
7
  require 'dragonfly_fonts/processors/correct_metrics'
7
8
  require 'dragonfly_fonts/processors/encode'
8
9
  require 'dragonfly_fonts/processors/extract_glyph'
9
10
  require 'dragonfly_fonts/processors/normalize_names'
11
+ require 'dragonfly_fonts/processors/ot_sanitise'
10
12
  require 'dragonfly_fonts/processors/set_dimensions'
11
13
  require 'dragonfly_fonts/processors/set_ttf_names'
12
14
  require 'dragonfly_fonts/processors/set_underline'
@@ -22,6 +24,7 @@ module DragonflyFonts
22
24
  app.add_analyser :font_info, Analysers::FontInfo.new
23
25
  app.add_analyser :glyphs, Analysers::Glyphs.new
24
26
  app.add_analyser :gsub_tables, Analysers::GsubTables.new
27
+ app.add_analyser :ot_sanitise, Analysers::OtSanitise.new
25
28
 
26
29
  # ---------------------------------------------------------------------
27
30
 
@@ -29,6 +32,7 @@ module DragonflyFonts
29
32
  app.add_processor :encode, Processors::Encode.new
30
33
  app.add_processor :extract_glyph, Processors::ExtractGlyph.new
31
34
  app.add_processor :normalize_names, Processors::NormalizeNames.new
35
+ app.add_processor :ot_sanitise!, Processors::OtSanitise.new
32
36
  app.add_processor :set_dimensions, Processors::SetDimensions.new
33
37
  app.add_processor :set_ttf_names, Processors::SetTtfNames.new
34
38
  app.add_processor :set_underline, Processors::SetUnderline.new
@@ -0,0 +1,22 @@
1
+ module DragonflyFonts
2
+ module Processors
3
+ # The OpenType Sanitiser (OTS) parses and serialises OpenType files (OTF, TTF) and WOFF and WOFF2 font files, validating them and sanitising them as it goes.
4
+ class OtSanitise
5
+ def call(content, _opts = {})
6
+ content.shell_update do |old_path, new_path|
7
+ "#{ot_sanitise_command} #{old_path} #{new_path}"
8
+ end
9
+ end
10
+
11
+ def update_url(attrs, *_args)
12
+ attrs.style = 'ot_sanitise'
13
+ end
14
+
15
+ private # =============================================================
16
+
17
+ def ot_sanitise_command
18
+ 'ot-sanitise'
19
+ end
20
+ end
21
+ end
22
+ end
@@ -1,3 +1,3 @@
1
1
  module DragonflyFonts
2
- VERSION = "0.0.3"
2
+ VERSION = '0.0.4'.freeze
3
3
  end
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dragonfly_fonts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Celizna
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-27 00:00:00.000000000 Z
11
+ date: 2016-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dragonfly
@@ -30,16 +30,16 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.6'
33
+ version: '1.12'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.6'
40
+ version: '1.12'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rake
42
+ name: guard
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: nokogiri
56
+ name: guard-minitest
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -67,21 +67,21 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: guard
70
+ name: minitest
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: '5.0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: '5.0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: guard-minitest
84
+ name: nokogiri
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
@@ -95,19 +95,19 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: minitest
98
+ name: rake
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '0'
103
+ version: '10.0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '0'
110
+ version: '10.0'
111
111
  description:
112
112
  email:
113
113
  - tomas.celizna@gmail.com
@@ -130,11 +130,13 @@ files:
130
130
  - lib/dragonfly_fonts/analysers/font_info.rb
131
131
  - lib/dragonfly_fonts/analysers/glyphs.rb
132
132
  - lib/dragonfly_fonts/analysers/gsub_tables.rb
133
+ - lib/dragonfly_fonts/analysers/ot_sanitise.rb
133
134
  - lib/dragonfly_fonts/plugin.rb
134
135
  - lib/dragonfly_fonts/processors/correct_metrics.rb
135
136
  - lib/dragonfly_fonts/processors/encode.rb
136
137
  - lib/dragonfly_fonts/processors/extract_glyph.rb
137
138
  - lib/dragonfly_fonts/processors/normalize_names.rb
139
+ - lib/dragonfly_fonts/processors/ot_sanitise.rb
138
140
  - lib/dragonfly_fonts/processors/set_dimensions.rb
139
141
  - lib/dragonfly_fonts/processors/set_ttf_names.rb
140
142
  - lib/dragonfly_fonts/processors/set_underline.rb
@@ -144,6 +146,7 @@ files:
144
146
  - lib/dragonfly_fonts/processors/web_friendly.rb
145
147
  - lib/dragonfly_fonts/unicode_ranges.rb
146
148
  - lib/dragonfly_fonts/version.rb
149
+ - samples/AppleGothic.ttf
147
150
  - samples/Arial.ttf
148
151
  - samples/Inconsolata.otf
149
152
  - script/dimensions.py
@@ -154,23 +157,6 @@ files:
154
157
  - script/underline.py
155
158
  - script/webfonts.pe
156
159
  - script/woff_meta.py
157
- - test/dragonfly_fonts/analysers/bbox_test.rb
158
- - test/dragonfly_fonts/analysers/font_info_test.rb
159
- - test/dragonfly_fonts/analysers/glyphs_test.rb
160
- - test/dragonfly_fonts/analysers/gsub_tables_test.rb
161
- - test/dragonfly_fonts/plugin_test.rb
162
- - test/dragonfly_fonts/processors/correct_metrics_test.rb
163
- - test/dragonfly_fonts/processors/encode_test.rb
164
- - test/dragonfly_fonts/processors/extract_glyph_test.rb
165
- - test/dragonfly_fonts/processors/normalize_names_test.rb
166
- - test/dragonfly_fonts/processors/set_dimensions_test.rb
167
- - test/dragonfly_fonts/processors/set_ttf_names_test.rb
168
- - test/dragonfly_fonts/processors/set_underline_test.rb
169
- - test/dragonfly_fonts/processors/set_width_test.rb
170
- - test/dragonfly_fonts/processors/set_woff_metadata_test.rb
171
- - test/dragonfly_fonts/processors/ttf_autohint_test.rb
172
- - test/dragonfly_fonts/processors/web_friendly_test.rb
173
- - test/test_helper.rb
174
160
  homepage: https://github.com/tomasc/dragonfly_fonts
175
161
  licenses:
176
162
  - MIT
@@ -191,25 +177,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
177
  version: '0'
192
178
  requirements: []
193
179
  rubyforge_project:
194
- rubygems_version: 2.4.8
180
+ rubygems_version: 2.4.5.1
195
181
  signing_key:
196
182
  specification_version: 4
197
183
  summary: Wraps common font-related tasks into Dragonfly analysers and processors.
198
- test_files:
199
- - test/dragonfly_fonts/analysers/bbox_test.rb
200
- - test/dragonfly_fonts/analysers/font_info_test.rb
201
- - test/dragonfly_fonts/analysers/glyphs_test.rb
202
- - test/dragonfly_fonts/analysers/gsub_tables_test.rb
203
- - test/dragonfly_fonts/plugin_test.rb
204
- - test/dragonfly_fonts/processors/correct_metrics_test.rb
205
- - test/dragonfly_fonts/processors/encode_test.rb
206
- - test/dragonfly_fonts/processors/extract_glyph_test.rb
207
- - test/dragonfly_fonts/processors/normalize_names_test.rb
208
- - test/dragonfly_fonts/processors/set_dimensions_test.rb
209
- - test/dragonfly_fonts/processors/set_ttf_names_test.rb
210
- - test/dragonfly_fonts/processors/set_underline_test.rb
211
- - test/dragonfly_fonts/processors/set_width_test.rb
212
- - test/dragonfly_fonts/processors/set_woff_metadata_test.rb
213
- - test/dragonfly_fonts/processors/ttf_autohint_test.rb
214
- - test/dragonfly_fonts/processors/web_friendly_test.rb
215
- - test/test_helper.rb
184
+ test_files: []
@@ -1,48 +0,0 @@
1
- require 'test_helper'
2
-
3
- module DragonflyFonts
4
- module Analysers
5
- describe Bbox do
6
- let(:app) { test_app.configure_with(:fonts) }
7
- let(:asset) { app.fetch_file SAMPLES_DIR.join('Inconsolata.otf') }
8
-
9
- let(:analyser) { DragonflyFonts::Analysers::Bbox.new }
10
-
11
- describe 'call' do
12
- let(:bbox) { analyser.call(asset, 'A') }
13
-
14
- it 'returns Hash' do
15
- bbox.must_be_kind_of Struct
16
- end
17
-
18
- it '#glyph' do
19
- bbox.glyph.must_equal 'A'
20
- end
21
-
22
- it '#min_x' do
23
- bbox.min_x.must_equal 14.6709
24
- end
25
-
26
- it '#min_y' do
27
- bbox.min_y.must_equal(-0.863281)
28
- end
29
-
30
- it '#max_x' do
31
- bbox.max_x.must_equal 483.28
32
- end
33
-
34
- it '#max_y' do
35
- bbox.max_y.must_equal 634.305
36
- end
37
-
38
- it '#width' do
39
- bbox.width.must_equal 468.60909999999996
40
- end
41
-
42
- it '#height' do
43
- bbox.height.must_equal 635.168281
44
- end
45
- end
46
- end
47
- end
48
- end
@@ -1,65 +0,0 @@
1
- require 'test_helper'
2
-
3
- module DragonflyFonts
4
- module Analysers
5
- describe FontInfo do
6
- let(:app) { test_app.configure_with(:fonts) }
7
- let(:analyser) { DragonflyFonts::Analysers::FontInfo.new }
8
- let(:font) { app.fetch_file(SAMPLES_DIR.join('Inconsolata.otf')) }
9
-
10
- describe 'call' do
11
- it 'returns Hash' do
12
- analyser.call(font).must_be_kind_of Hash
13
- end
14
-
15
- it 'includes keys' do
16
- %w(
17
- ascent
18
- cap_height
19
- comment
20
- copyright
21
- default_base_filename
22
- descent
23
- descriptor
24
- designer
25
- designer_url
26
- em
27
- embedding_restrictions
28
- encoding
29
- familyname
30
- fontlog
31
- fontname
32
- fullname
33
- license
34
- license_url
35
- path
36
- sfnt_revision
37
- trademark
38
- upos
39
- uwidth
40
- vendor_url
41
- version
42
- weight
43
- woff_metadata
44
- woff_revision
45
- x_height
46
- ).each do |key|
47
- analyser.call(font).keys.must_include key
48
- end
49
- end
50
-
51
- it 'includes familyname' do
52
- analyser.call(font)['familyname'].must_equal 'Inconsolata'
53
- end
54
-
55
- it 'includes fullname' do
56
- analyser.call(font)['fullname'].must_equal 'Inconsolata'
57
- end
58
-
59
- it 'includes weight' do
60
- analyser.call(font)['weight'].must_equal 'Medium'
61
- end
62
- end
63
- end
64
- end
65
- end
@@ -1,27 +0,0 @@
1
- require 'test_helper'
2
-
3
- module DragonflyFonts
4
- module Analysers
5
- describe Glyphs do
6
- let(:app) { test_app.configure_with(:fonts) }
7
- let(:asset) { app.fetch_file SAMPLES_DIR.join('Inconsolata.otf') }
8
-
9
- let(:glyph_A) { asset.glyphs.find{ |g| g['glyphname'] == 'A' } }
10
-
11
- describe 'call' do
12
- it 'returns Array' do
13
- asset.glyphs.must_be_kind_of Array
14
- end
15
-
16
- it 'returns properties per each glyph' do
17
- glyph_A['glyphclass'].wont_be_nil
18
- glyph_A['glyphname'].wont_be_nil
19
- glyph_A['encoding'].wont_be_nil
20
- glyph_A['script'].wont_be_nil
21
- glyph_A['width'].wont_be_nil
22
- glyph_A['unicode'].wont_be_nil
23
- end
24
- end
25
- end
26
- end
27
- end
@@ -1,42 +0,0 @@
1
- require 'test_helper'
2
-
3
- module DragonflyFonts
4
- module Analysers
5
- describe GsubTables do
6
- let(:app) { test_app.configure_with(:fonts) }
7
- let(:analyser) { DragonflyFonts::Analysers::GsubTables.new }
8
- let(:font) { app.fetch_file(SAMPLES_DIR.join('Inconsolata.otf')) }
9
-
10
- describe 'call' do
11
- it 'returns Array' do
12
- analyser.call(font).must_be_kind_of Array
13
- end
14
-
15
- # it 'includes info, subtables, name' do
16
- # analyser.call(font).map(&:keys).uniq.flatten.must_equal %w(info subtables name)
17
- # end
18
-
19
- # describe 'info' do
20
- # it 'is an Array' do
21
- # analyser.call(font).shuffle.first['info'].must_be_kind_of Array
22
- # end
23
- # end
24
-
25
- # describe 'subtables' do
26
- # it 'is an Array' do
27
- # analyser.call(font).shuffle.first['subtables'].must_be_kind_of Array
28
- # end
29
- # it 'has glyphs and name keys' do
30
- # analyser.call(font).shuffle.first['subtables'].shuffle.first.keys.must_equal %w(glyphs name)
31
- # end
32
- # end
33
-
34
- # describe 'name' do
35
- # it 'is a String' do
36
- # analyser.call(font).shuffle.first['name'].must_be_kind_of String
37
- # end
38
- # end
39
- end
40
- end
41
- end
42
- end
@@ -1,76 +0,0 @@
1
- require 'test_helper'
2
-
3
- module DragonflyFonts
4
- describe Plugin do
5
- let(:app) { test_app.configure_with(:fonts) }
6
- let(:font) { app.fetch_file(SAMPLES_DIR.join('Inconsolata.otf')) }
7
-
8
- # ---------------------------------------------------------------------
9
-
10
- describe 'analysers' do
11
- it 'adds #bbox' do
12
- font.must_respond_to :bbox
13
- end
14
-
15
- it 'adds #font_info' do
16
- font.must_respond_to :font_info
17
- end
18
-
19
- it 'adds #glyphs' do
20
- font.must_respond_to :glyphs
21
- end
22
-
23
- it 'adds #gsub_tables' do
24
- font.must_respond_to :gsub_tables
25
- end
26
- end
27
-
28
- # ---------------------------------------------------------------------
29
-
30
- describe 'processors' do
31
- it 'adds #correct_metrics' do
32
- font.must_respond_to :correct_metrics
33
- end
34
-
35
- it 'adds #encode' do
36
- font.must_respond_to :encode
37
- end
38
-
39
- it 'adds #extract_glyph' do
40
- font.must_respond_to :extract_glyph
41
- end
42
-
43
- it 'adds #normalize_names' do
44
- font.must_respond_to :normalize_names
45
- end
46
-
47
- it 'adds #set_dimensions' do
48
- font.must_respond_to :set_dimensions
49
- end
50
-
51
- it 'adds #set_ttf_names' do
52
- font.must_respond_to :set_ttf_names
53
- end
54
-
55
- it 'adds #set_underline' do
56
- font.must_respond_to :set_underline
57
- end
58
-
59
- it 'adds #set_width' do
60
- font.must_respond_to :set_width
61
- end
62
-
63
- it 'adds #set_woff_metadata' do
64
- font.must_respond_to :set_woff_metadata
65
- end
66
-
67
- it 'adds #ttf_autohint' do
68
- font.must_respond_to :ttf_autohint
69
- end
70
-
71
- it 'adds #web_friendly' do
72
- font.must_respond_to :web_friendly
73
- end
74
- end
75
- end
76
- end
@@ -1,22 +0,0 @@
1
- require 'test_helper'
2
-
3
- module DragonflyFonts
4
- module Processors
5
- describe CorrectMetrics do
6
- let(:app) { test_app.configure_with(:fonts) }
7
- let(:asset) { app.fetch_file SAMPLES_DIR.join('Inconsolata.otf') }
8
-
9
- # =====================================================================
10
-
11
- it 'adjusts ascent value' do
12
- skip 'need to find font that is changed by this'
13
- asset.correct_metrics.font_info.must_equal '…'
14
- end
15
-
16
- it 'adjusts descent value' do
17
- skip 'need to find font that is changed by this'
18
- asset.correct_metrics.font_info.must_equal '…'
19
- end
20
- end
21
- end
22
- end
@@ -1,36 +0,0 @@
1
- require 'test_helper'
2
-
3
- module DragonflyFonts
4
- module Processors
5
- describe Encode do
6
- let(:app) { test_app.configure_with(:fonts) }
7
- let(:asset) { app.fetch_file SAMPLES_DIR.join('Inconsolata.otf') }
8
-
9
- # =====================================================================
10
-
11
- it 'allows to convert to :eot' do
12
- asset.encode(:eot).mime_type.must_equal 'application/vnd.ms-fontobject'
13
- end
14
-
15
- it 'allows to convert to :otf' do
16
- asset.encode(:otf).mime_type.must_equal 'application/vnd.oasis.opendocument.formula-template'
17
- end
18
-
19
- it 'allows to convert to :ttf' do
20
- asset.encode(:ttf).mime_type.must_equal 'application/octet-stream'
21
- end
22
-
23
- it 'allows to convert to :svg' do
24
- asset.encode(:svg).mime_type.must_equal 'image/svg+xml'
25
- end
26
-
27
- it 'allows to convert to :woff' do
28
- asset.encode(:woff).mime_type.must_equal 'application/font-woff'
29
- end
30
-
31
- it 'allows to convert to :woff2' do
32
- asset.encode(:woff2).data.must_match /\AwOF2OTTO/
33
- end
34
- end
35
- end
36
- end
@@ -1,22 +0,0 @@
1
- require 'test_helper'
2
-
3
- module DragonflyFonts
4
- module Processors
5
- describe ExtractGlyph do
6
- let(:app) { test_app.configure_with(:fonts) }
7
- let(:asset) { app.fetch_file SAMPLES_DIR.join('Inconsolata.otf') }
8
-
9
- let(:glyph) { 'A' }
10
-
11
- # =====================================================================
12
-
13
- it 'extracts specified glyph in SVG by default' do
14
- asset.extract_glyph(glyph).data.must_include '</svg>'
15
- end
16
-
17
- it 'allows to specify format' do
18
- asset.extract_glyph(glyph, format: :svg).data.must_include '</svg>'
19
- end
20
- end
21
- end
22
- end
@@ -1,18 +0,0 @@
1
- require 'test_helper'
2
-
3
- module DragonflyFonts
4
- module Processors
5
- describe NormalizeNames do
6
- let(:app) { test_app.configure_with(:fonts) }
7
- let(:asset) { app.fetch_file SAMPLES_DIR.join('Arial.ttf') }
8
-
9
- # =====================================================================
10
-
11
- # TODO: how to test this?
12
-
13
- it 'works' do
14
- asset.normalize_names.mime_type.must_equal 'application/octet-stream'
15
- end
16
- end
17
- end
18
- end
@@ -1,26 +0,0 @@
1
- require 'test_helper'
2
-
3
- module DragonflyFonts
4
- module Processors
5
- describe SetDimensions do
6
- let(:app) { test_app.configure_with(:fonts) }
7
- let(:asset) { app.fetch_file SAMPLES_DIR.join('Inconsolata.otf') }
8
-
9
- let(:ascent) { 200 }
10
- let(:descent) { -200 }
11
-
12
- let(:original_ascent) { asset.font_info['ascent'] }
13
- let(:original_descent) { asset.font_info['descent'] }
14
-
15
- # =====================================================================
16
-
17
- describe 'upos' do
18
- it 'sets the width to the value' do
19
- skip 'somehow the :font_info does not seem to report correct values'
20
- asset.set_dimensions(ascent: ascent).font_info['ascent'].must_equal (original_ascent + ascent)
21
- asset.set_dimensions(descent: descent).font_info['descent'].must_equal (original_descent + descent)
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,23 +0,0 @@
1
- require 'test_helper'
2
-
3
- module DragonflyFonts
4
- module Processors
5
- describe SetTtfNames do
6
- let(:app) { test_app.configure_with(:fonts) }
7
- let(:asset) { app.fetch_file SAMPLES_DIR.join('Inconsolata.otf') }
8
-
9
- let(:designer) { 'John Doe' }
10
- let(:license_url) { 'http://www.google.com' }
11
-
12
- # =====================================================================
13
-
14
- it 'sets designer' do
15
- asset.set_ttf_names(designer: designer).font_info['designer'].must_equal designer
16
- end
17
-
18
- it 'sets license_url' do
19
- asset.set_ttf_names(license_url: license_url).font_info['license_url'].must_equal license_url
20
- end
21
- end
22
- end
23
- end
@@ -1,22 +0,0 @@
1
- require 'test_helper'
2
-
3
- module DragonflyFonts
4
- module Processors
5
- describe SetUnderline do
6
- let(:app) { test_app.configure_with(:fonts) }
7
- let(:asset) { app.fetch_file SAMPLES_DIR.join('Inconsolata.otf') }
8
-
9
- let(:upos) { 1.0 }
10
- let(:uwidth) { 2.0 }
11
-
12
- # =====================================================================
13
-
14
- describe 'upos' do
15
- it 'sets the width to the value' do
16
- asset.set_underline(upos: upos).font_info['upos'].must_equal upos
17
- asset.set_underline(uwidth: uwidth).font_info['uwidth'].must_equal uwidth
18
- end
19
- end
20
- end
21
- end
22
- end
@@ -1,48 +0,0 @@
1
- require 'test_helper'
2
-
3
- module DragonflyFonts
4
- module Processors
5
- describe SetWidth do
6
- let(:app) { test_app.configure_with(:fonts) }
7
- let(:asset) { app.fetch_file SAMPLES_DIR.join('Inconsolata.otf') }
8
-
9
- let(:analyser) { DragonflyFonts::Analysers::Bbox.new }
10
-
11
- let(:glyph) { 'A' }
12
- let(:default_bbox) { analyser.call(asset, glyph) }
13
-
14
- let(:width) { 200 }
15
-
16
- let(:bbox) { analyser.call(asset.set_width(width, relative), glyph) }
17
-
18
- # =====================================================================
19
-
20
- describe 'relative=0' do
21
- let(:relative) { 0 }
22
-
23
- it 'sets the width to the value' do
24
- skip 'bbox does not reflect the changes'
25
- bbox.width.must_equal width.to_f
26
- end
27
- end
28
-
29
- describe 'relative=1' do
30
- let(:relative) { 1 }
31
-
32
- it 'increments the width by the value' do
33
- skip 'bbox does not reflect the changes'
34
- bbox.width.must_equal default_bbox.width + width.to_f
35
- end
36
- end
37
-
38
- describe 'relative=2' do
39
- let(:relative) { 2 }
40
-
41
- it 'scales width by the value/100' do
42
- skip 'bbox does not reflect the changes'
43
- bbox.width.must_equal default_bbox.width * width / 100.0
44
- end
45
- end
46
- end
47
- end
48
- end
@@ -1,28 +0,0 @@
1
- require 'test_helper'
2
- require 'nokogiri'
3
-
4
- module DragonflyFonts
5
- module Processors
6
- describe SetWoffMetadata do
7
- let(:app) { test_app.configure_with(:fonts) }
8
- let(:asset) { app.fetch_file SAMPLES_DIR.join('Inconsolata.otf') }
9
-
10
- let(:uniqueid) { 'UNIQUEID' }
11
- let(:licensee_name) { 'John Doe' }
12
-
13
- # =====================================================================
14
-
15
- describe 'values' do
16
- let(:woff_meta) { Nokogiri::XML(asset.set_woff_metadata(uniqueid, licensee_name).font_info['woff_metadata']) }
17
-
18
- it 'sets uniqueid' do
19
- woff_meta.xpath('//uniqueid').first.attribute('id').value.must_match(/\A#{uniqueid}/)
20
- end
21
-
22
- it 'sets licensee' do
23
- woff_meta.xpath('//licensee').first.attribute('name').value.must_equal licensee_name
24
- end
25
- end
26
- end
27
- end
28
- end
@@ -1,18 +0,0 @@
1
- require 'test_helper'
2
-
3
- module DragonflyFonts
4
- module Processors
5
- describe TtfAutohint do
6
- let(:app) { test_app.configure_with(:fonts) }
7
- let(:asset) { app.fetch_file SAMPLES_DIR.join('Arial.ttf') }
8
-
9
- # =====================================================================
10
-
11
- # TODO: how to test this better?
12
-
13
- it 'works' do
14
- asset.ttf_autohint.mime_type.must_equal 'application/octet-stream'
15
- end
16
- end
17
- end
18
- end
@@ -1,18 +0,0 @@
1
- require 'test_helper'
2
-
3
- module DragonflyFonts
4
- module Processors
5
- describe WebFriendly do
6
- let(:app) { test_app.configure_with(:fonts) }
7
- let(:asset) { app.fetch_file SAMPLES_DIR.join('Arial.ttf') }
8
-
9
- # =====================================================================
10
-
11
- # TODO: how to test this?
12
-
13
- it 'works' do
14
- asset.web_friendly.mime_type.must_equal 'application/octet-stream'
15
- end
16
- end
17
- end
18
- end
data/test/test_helper.rb DELETED
@@ -1,21 +0,0 @@
1
- require 'bundler/setup'
2
-
3
- require 'minitest'
4
- require 'minitest/autorun'
5
- require 'minitest/spec'
6
-
7
- require 'dragonfly'
8
- require 'dragonfly_fonts'
9
-
10
- # ---------------------------------------------------------------------
11
-
12
- SAMPLES_DIR = Pathname.new(File.expand_path('../../samples', __FILE__))
13
-
14
- # ---------------------------------------------------------------------
15
-
16
- def test_app(name = nil)
17
- app = Dragonfly::App.instance(name)
18
- app.datastore = Dragonfly::MemoryDataStore.new
19
- app.secret = 'test secret'
20
- app
21
- end