fontist 1.7.0 → 1.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/release.yml +38 -0
- data/.github/workflows/rspec.yml +58 -0
- data/README.md +123 -32
- data/{bin → exe}/fontist +0 -0
- data/fontist.gemspec +5 -2
- data/lib/fontist.rb +10 -3
- data/lib/fontist/cli.rb +62 -41
- data/lib/fontist/errors.rb +14 -12
- data/lib/fontist/font.rb +29 -31
- data/lib/fontist/font_installer.rb +114 -0
- data/lib/fontist/fontist_font.rb +3 -49
- data/lib/fontist/formula.rb +88 -66
- data/lib/fontist/formula_paths.rb +43 -0
- data/lib/fontist/helpers.rb +7 -0
- data/lib/fontist/import/create_formula.rb +3 -2
- data/lib/fontist/import/google/skiplist.yml +3 -0
- data/lib/fontist/import/google_check.rb +1 -1
- data/lib/fontist/import/google_import.rb +3 -4
- data/lib/fontist/import/otfinfo_generate.rb +1 -1
- data/lib/fontist/import/recursive_extraction.rb +6 -2
- data/lib/fontist/import/sil_import.rb +99 -0
- data/lib/fontist/index.rb +72 -0
- data/lib/fontist/index_formula.rb +30 -0
- data/lib/fontist/manifest/install.rb +4 -9
- data/lib/fontist/manifest/locations.rb +28 -20
- data/lib/fontist/system_font.rb +20 -60
- data/lib/fontist/system_index.rb +92 -0
- data/lib/fontist/utils/exe_extractor.rb +1 -1
- data/lib/fontist/utils/zip_extractor.rb +1 -1
- data/lib/fontist/version.rb +1 -1
- metadata +57 -20
- data/.github/workflows/macosx.yml +0 -33
- data/.github/workflows/ubuntu.yml +0 -30
- data/.github/workflows/windows.yml +0 -32
- data/bin/check_google +0 -8
- data/bin/console +0 -11
- data/bin/convert_formulas +0 -8
- data/bin/generate_otfinfo +0 -8
- data/bin/import_google +0 -8
- data/bin/rspec +0 -29
- data/bin/setup +0 -7
- data/lib/fontist/font_formula.rb +0 -158
- data/lib/fontist/formula_template.rb +0 -122
- data/lib/fontist/formulas.rb +0 -56
- data/lib/fontist/registry.rb +0 -43
@@ -0,0 +1,92 @@
|
|
1
|
+
require "ttfunk"
|
2
|
+
|
3
|
+
module Fontist
|
4
|
+
class SystemIndex
|
5
|
+
attr_reader :font_paths
|
6
|
+
|
7
|
+
def initialize(font_paths)
|
8
|
+
@font_paths = font_paths
|
9
|
+
end
|
10
|
+
|
11
|
+
def find(font, style)
|
12
|
+
fonts = system_index.select do |file|
|
13
|
+
file[:family_name].casecmp?(font) &&
|
14
|
+
(style.nil? || file[:type].casecmp?(style))
|
15
|
+
end
|
16
|
+
|
17
|
+
fonts.empty? ? nil : fonts
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def system_index
|
23
|
+
@system_index ||= build_system_index
|
24
|
+
end
|
25
|
+
|
26
|
+
def build_system_index
|
27
|
+
previous_index = load_system_index
|
28
|
+
updated_index = detect_paths(font_paths, previous_index)
|
29
|
+
updated_index.tap do |index|
|
30
|
+
save_index(index)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def load_system_index
|
35
|
+
index = File.exist?(Fontist.system_index_path) ? YAML.load_file(Fontist.system_index_path) : []
|
36
|
+
index.group_by { |x| x[:path] }
|
37
|
+
end
|
38
|
+
|
39
|
+
def detect_paths(paths, indexed)
|
40
|
+
paths.flat_map do |path|
|
41
|
+
next indexed[path] if indexed[path]
|
42
|
+
|
43
|
+
detect_fonts(path)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def detect_fonts(path)
|
48
|
+
case File.extname(path).gsub(/^\./, "").downcase
|
49
|
+
when "ttf", "otf"
|
50
|
+
detect_file_font(path)
|
51
|
+
when "ttc"
|
52
|
+
detect_collection_fonts(path)
|
53
|
+
else
|
54
|
+
raise Errors::UnknownFontTypeError.new(path)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def detect_file_font(path)
|
59
|
+
file = TTFunk::File.open(path)
|
60
|
+
parse_font(file, path)
|
61
|
+
end
|
62
|
+
|
63
|
+
def detect_collection_fonts(path)
|
64
|
+
TTFunk::Collection.open(path) do |collection|
|
65
|
+
collection.map do |file|
|
66
|
+
parse_font(file, path)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def parse_font(file, path)
|
72
|
+
x = file.name
|
73
|
+
|
74
|
+
{
|
75
|
+
path: path,
|
76
|
+
full_name: parse_text(x.font_name.first),
|
77
|
+
family_name: parse_text(x.preferred_family.first || x.font_family.first),
|
78
|
+
type: parse_text(x.preferred_subfamily.first || x.font_subfamily.first),
|
79
|
+
}
|
80
|
+
end
|
81
|
+
|
82
|
+
def parse_text(text)
|
83
|
+
text.gsub(/[^[:print:]]/, "").to_s
|
84
|
+
end
|
85
|
+
|
86
|
+
def save_index(index)
|
87
|
+
dir = File.dirname(Fontist.system_index_path)
|
88
|
+
FileUtils.mkdir_p(dir) unless File.exist?(dir)
|
89
|
+
File.write(Fontist.system_index_path, YAML.dump(index))
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -6,7 +6,7 @@ module Fontist
|
|
6
6
|
|
7
7
|
exe_file = download_file(exe_file).path if download
|
8
8
|
|
9
|
-
Fontist.ui.say(%(Installing font "#{key}".))
|
9
|
+
Fontist.ui.say(%(Installing font "#{formula.key}".))
|
10
10
|
cab_file = decompressor.search(exe_file)
|
11
11
|
cabbed_fonts = grep_fonts(cab_file.files) || []
|
12
12
|
fonts_paths = extract_cabbed_fonts_to_assets(cabbed_fonts)
|
@@ -8,7 +8,7 @@ module Fontist
|
|
8
8
|
zip_file = download_file(resource) if download
|
9
9
|
zip_file ||= resource.urls.first
|
10
10
|
|
11
|
-
Fontist.ui.say(%(Installing font "#{key}".))
|
11
|
+
Fontist.ui.say(%(Installing font "#{formula.key}".))
|
12
12
|
fonts_paths = unzip_fonts(zip_file, fonts_sub_dir)
|
13
13
|
block_given? ? yield(fonts_paths) : fonts_paths
|
14
14
|
end
|
data/lib/fontist/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fontist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
- Abu Nashir
|
9
|
-
autorequire:
|
10
|
-
bindir:
|
9
|
+
autorequire:
|
10
|
+
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-12-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: down
|
@@ -109,6 +109,20 @@ dependencies:
|
|
109
109
|
- - "~>"
|
110
110
|
- !ruby/object:Gem::Version
|
111
111
|
version: '1.0'
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: ttfunk
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - "~>"
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '1.0'
|
119
|
+
type: :runtime
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - "~>"
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '1.0'
|
112
126
|
- !ruby/object:Gem::Dependency
|
113
127
|
name: extract_ttc
|
114
128
|
requirement: !ruby/object:Gem::Requirement
|
@@ -151,6 +165,34 @@ dependencies:
|
|
151
165
|
- - "~>"
|
152
166
|
- !ruby/object:Gem::Version
|
153
167
|
version: '2.0'
|
168
|
+
- !ruby/object:Gem::Dependency
|
169
|
+
name: gem-release
|
170
|
+
requirement: !ruby/object:Gem::Requirement
|
171
|
+
requirements:
|
172
|
+
- - ">="
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: '0'
|
175
|
+
type: :development
|
176
|
+
prerelease: false
|
177
|
+
version_requirements: !ruby/object:Gem::Requirement
|
178
|
+
requirements:
|
179
|
+
- - ">="
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '0'
|
182
|
+
- !ruby/object:Gem::Dependency
|
183
|
+
name: nokogiri
|
184
|
+
requirement: !ruby/object:Gem::Requirement
|
185
|
+
requirements:
|
186
|
+
- - "~>"
|
187
|
+
- !ruby/object:Gem::Version
|
188
|
+
version: '1.0'
|
189
|
+
type: :development
|
190
|
+
prerelease: false
|
191
|
+
version_requirements: !ruby/object:Gem::Requirement
|
192
|
+
requirements:
|
193
|
+
- - "~>"
|
194
|
+
- !ruby/object:Gem::Version
|
195
|
+
version: '1.0'
|
154
196
|
- !ruby/object:Gem::Dependency
|
155
197
|
name: rake
|
156
198
|
requirement: !ruby/object:Gem::Requirement
|
@@ -245,9 +287,8 @@ extensions: []
|
|
245
287
|
extra_rdoc_files: []
|
246
288
|
files:
|
247
289
|
- ".github/workflows/check_google.yml"
|
248
|
-
- ".github/workflows/
|
249
|
-
- ".github/workflows/
|
250
|
-
- ".github/workflows/windows.yml"
|
290
|
+
- ".github/workflows/release.yml"
|
291
|
+
- ".github/workflows/rspec.yml"
|
251
292
|
- ".gitignore"
|
252
293
|
- ".hound.yml"
|
253
294
|
- ".rspec"
|
@@ -256,24 +297,17 @@ files:
|
|
256
297
|
- LICENSE.txt
|
257
298
|
- README.md
|
258
299
|
- Rakefile
|
259
|
-
-
|
260
|
-
- bin/console
|
261
|
-
- bin/convert_formulas
|
262
|
-
- bin/fontist
|
263
|
-
- bin/generate_otfinfo
|
264
|
-
- bin/import_google
|
265
|
-
- bin/rspec
|
266
|
-
- bin/setup
|
300
|
+
- exe/fontist
|
267
301
|
- fontist.gemspec
|
268
302
|
- lib/fontist.rb
|
269
303
|
- lib/fontist/cli.rb
|
270
304
|
- lib/fontist/errors.rb
|
271
305
|
- lib/fontist/font.rb
|
272
|
-
- lib/fontist/
|
306
|
+
- lib/fontist/font_installer.rb
|
273
307
|
- lib/fontist/fontist_font.rb
|
274
308
|
- lib/fontist/formula.rb
|
275
|
-
- lib/fontist/
|
276
|
-
- lib/fontist/
|
309
|
+
- lib/fontist/formula_paths.rb
|
310
|
+
- lib/fontist/helpers.rb
|
277
311
|
- lib/fontist/import.rb
|
278
312
|
- lib/fontist/import/convert_formulas.rb
|
279
313
|
- lib/fontist/import/create_formula.rb
|
@@ -305,14 +339,17 @@ files:
|
|
305
339
|
- lib/fontist/import/otfinfo/template.erb
|
306
340
|
- lib/fontist/import/otfinfo_generate.rb
|
307
341
|
- lib/fontist/import/recursive_extraction.rb
|
342
|
+
- lib/fontist/import/sil_import.rb
|
308
343
|
- lib/fontist/import/template_helper.rb
|
309
344
|
- lib/fontist/import/text_helper.rb
|
345
|
+
- lib/fontist/index.rb
|
346
|
+
- lib/fontist/index_formula.rb
|
310
347
|
- lib/fontist/manifest.rb
|
311
348
|
- lib/fontist/manifest/install.rb
|
312
349
|
- lib/fontist/manifest/locations.rb
|
313
|
-
- lib/fontist/registry.rb
|
314
350
|
- lib/fontist/system.yml
|
315
351
|
- lib/fontist/system_font.rb
|
352
|
+
- lib/fontist/system_index.rb
|
316
353
|
- lib/fontist/utils.rb
|
317
354
|
- lib/fontist/utils/cache.rb
|
318
355
|
- lib/fontist/utils/downloader.rb
|
@@ -349,7 +386,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
349
386
|
version: '0'
|
350
387
|
requirements: []
|
351
388
|
rubygems_version: 3.0.3
|
352
|
-
signing_key:
|
389
|
+
signing_key:
|
353
390
|
specification_version: 4
|
354
391
|
summary: A libarary find or download fonts
|
355
392
|
test_files: []
|
@@ -1,33 +0,0 @@
|
|
1
|
-
name: macos
|
2
|
-
|
3
|
-
on:
|
4
|
-
push:
|
5
|
-
branches:
|
6
|
-
- master
|
7
|
-
|
8
|
-
pull_request:
|
9
|
-
branches:
|
10
|
-
- master
|
11
|
-
|
12
|
-
jobs:
|
13
|
-
build:
|
14
|
-
runs-on: macos-latest
|
15
|
-
|
16
|
-
steps:
|
17
|
-
- uses: actions/checkout@v2
|
18
|
-
|
19
|
-
- uses: actions/setup-ruby@v1
|
20
|
-
with:
|
21
|
-
ruby-version: 2.6
|
22
|
-
|
23
|
-
- name: Install otfinfo
|
24
|
-
run: brew install lcdf-typetools
|
25
|
-
|
26
|
-
- name: Install bundler
|
27
|
-
run: gem install bundler
|
28
|
-
|
29
|
-
- name: Setup
|
30
|
-
run: bin/setup
|
31
|
-
|
32
|
-
- name: Run tests
|
33
|
-
run: TEST_ENV=CI bin/rspec
|
@@ -1,30 +0,0 @@
|
|
1
|
-
name: ubuntu
|
2
|
-
|
3
|
-
on:
|
4
|
-
push:
|
5
|
-
branches:
|
6
|
-
- master
|
7
|
-
|
8
|
-
pull_request:
|
9
|
-
branches:
|
10
|
-
- master
|
11
|
-
|
12
|
-
jobs:
|
13
|
-
build:
|
14
|
-
runs-on: ubuntu-latest
|
15
|
-
|
16
|
-
steps:
|
17
|
-
- uses: actions/checkout@v2
|
18
|
-
|
19
|
-
- uses: actions/setup-ruby@v1
|
20
|
-
with:
|
21
|
-
ruby-version: 2.6
|
22
|
-
|
23
|
-
- name: Install bundler
|
24
|
-
run: gem install bundler
|
25
|
-
|
26
|
-
- name: Setup
|
27
|
-
run: bin/setup
|
28
|
-
|
29
|
-
- name: Run tests
|
30
|
-
run: TEST_ENV=CI bin/rspec --tag ~dev
|
@@ -1,32 +0,0 @@
|
|
1
|
-
name: windows
|
2
|
-
|
3
|
-
on:
|
4
|
-
push:
|
5
|
-
branches:
|
6
|
-
- master
|
7
|
-
|
8
|
-
pull_request:
|
9
|
-
branches:
|
10
|
-
- master
|
11
|
-
|
12
|
-
jobs:
|
13
|
-
build:
|
14
|
-
runs-on: windows-latest
|
15
|
-
|
16
|
-
steps:
|
17
|
-
- uses: actions/checkout@v2
|
18
|
-
|
19
|
-
- uses: actions/setup-ruby@v1
|
20
|
-
with:
|
21
|
-
ruby-version: 2.6
|
22
|
-
architecture: "x64"
|
23
|
-
|
24
|
-
- name: Setup
|
25
|
-
shell: pwsh
|
26
|
-
run: |
|
27
|
-
gem install bundler
|
28
|
-
bundle config --local path vendor/bundle
|
29
|
-
bundle install --jobs 4 --retry 3
|
30
|
-
|
31
|
-
- name: Run tests
|
32
|
-
run: bundle exec rspec --tag ~skip_in_windows --tag ~dev
|
data/bin/check_google
DELETED
data/bin/console
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "fontist"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
require "pry"
|
11
|
-
Pry.start
|
data/bin/convert_formulas
DELETED
data/bin/generate_otfinfo
DELETED
data/bin/import_google
DELETED
data/bin/rspec
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
#
|
5
|
-
# This file was generated by Bundler.
|
6
|
-
#
|
7
|
-
# The application 'rspec' is installed as part of a gem, and
|
8
|
-
# this file is here to facilitate running it.
|
9
|
-
#
|
10
|
-
|
11
|
-
require "pathname"
|
12
|
-
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
-
Pathname.new(__FILE__).realpath)
|
14
|
-
|
15
|
-
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
-
|
17
|
-
if File.file?(bundle_binstub)
|
18
|
-
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
-
load(bundle_binstub)
|
20
|
-
else
|
21
|
-
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
-
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
require "rubygems"
|
27
|
-
require "bundler/setup"
|
28
|
-
|
29
|
-
load Gem.bin_path("rspec-core", "rspec")
|