fontist 1.7.1 → 1.8.3
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.
- 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 +4 -2
- data/lib/fontist.rb +6 -3
- data/lib/fontist/cli.rb +66 -42
- data/lib/fontist/errors.rb +62 -12
- data/lib/fontist/font.rb +23 -37
- data/lib/fontist/font_installer.rb +114 -0
- data/lib/fontist/fontist_font.rb +3 -49
- data/lib/fontist/formula.rb +89 -63
- 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 +32 -91
- data/lib/fontist/system_index.rb +47 -5
- data/lib/fontist/utils.rb +1 -0
- data/lib/fontist/utils/cache.rb +11 -3
- data/lib/fontist/utils/exe_extractor.rb +1 -1
- data/lib/fontist/utils/locking.rb +17 -0
- data/lib/fontist/utils/zip_extractor.rb +1 -1
- data/lib/fontist/version.rb +1 -1
- metadata +43 -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
data/lib/fontist/system_index.rb
CHANGED
@@ -2,8 +2,18 @@ require "ttfunk"
|
|
2
2
|
|
3
3
|
module Fontist
|
4
4
|
class SystemIndex
|
5
|
+
include Utils::Locking
|
6
|
+
|
5
7
|
attr_reader :font_paths
|
6
8
|
|
9
|
+
def self.find(font, style)
|
10
|
+
new(SystemFont.font_paths).find(font, style)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.rebuild
|
14
|
+
new(SystemFont.font_paths).rebuild
|
15
|
+
end
|
16
|
+
|
7
17
|
def initialize(font_paths)
|
8
18
|
@font_paths = font_paths
|
9
19
|
end
|
@@ -17,6 +27,10 @@ module Fontist
|
|
17
27
|
fonts.empty? ? nil : fonts
|
18
28
|
end
|
19
29
|
|
30
|
+
def rebuild
|
31
|
+
build_system_index
|
32
|
+
end
|
33
|
+
|
20
34
|
private
|
21
35
|
|
22
36
|
def system_index
|
@@ -24,28 +38,56 @@ module Fontist
|
|
24
38
|
end
|
25
39
|
|
26
40
|
def build_system_index
|
41
|
+
lock(lock_path) do
|
42
|
+
do_build_system_index
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def lock_path
|
47
|
+
Fontist.system_index_path.to_s + ".lock"
|
48
|
+
end
|
49
|
+
|
50
|
+
def do_build_system_index
|
27
51
|
previous_index = load_system_index
|
28
52
|
updated_index = detect_paths(font_paths, previous_index)
|
29
53
|
updated_index.tap do |index|
|
30
|
-
save_index(index)
|
54
|
+
save_index(index) if changed?(updated_index, previous_index)
|
31
55
|
end
|
32
56
|
end
|
33
57
|
|
58
|
+
def changed?(this, other)
|
59
|
+
this.map { |x| x[:path] }.uniq.sort != other.map { |x| x[:path] }.uniq.sort
|
60
|
+
end
|
61
|
+
|
34
62
|
def load_system_index
|
35
63
|
index = File.exist?(Fontist.system_index_path) ? YAML.load_file(Fontist.system_index_path) : []
|
36
|
-
|
64
|
+
|
65
|
+
index.each do |item|
|
66
|
+
missing_keys = %i[path full_name family_name type] - item.keys
|
67
|
+
unless missing_keys.empty?
|
68
|
+
raise(Errors::FontIndexCorrupted, <<~MSG.chomp)
|
69
|
+
Font index is corrupted.
|
70
|
+
Item #{item.inspect} misses required attributes: #{missing_keys.join(', ')}.
|
71
|
+
You can remove the index file (#{Fontist.system_index_path}) and try again.
|
72
|
+
MSG
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
index
|
37
77
|
end
|
38
78
|
|
39
|
-
def detect_paths(paths,
|
79
|
+
def detect_paths(paths, index)
|
80
|
+
by_path = index.group_by { |x| x[:path] }
|
81
|
+
|
40
82
|
paths.flat_map do |path|
|
41
|
-
next
|
83
|
+
next by_path[path] if by_path[path]
|
42
84
|
|
43
85
|
detect_fonts(path)
|
44
86
|
end
|
45
87
|
end
|
46
88
|
|
47
89
|
def detect_fonts(path)
|
48
|
-
case File.extname(path).
|
90
|
+
case File.extname(path).gsub(/^\./, "").downcase
|
49
91
|
when "ttf", "otf"
|
50
92
|
detect_file_font(path)
|
51
93
|
when "ttc"
|
data/lib/fontist/utils.rb
CHANGED
data/lib/fontist/utils/cache.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
module Fontist
|
2
2
|
module Utils
|
3
3
|
class Cache
|
4
|
+
include Locking
|
5
|
+
|
4
6
|
def fetch(key, bar: nil)
|
5
7
|
map = load_cache
|
6
8
|
if cache_exist?(map[key])
|
@@ -48,13 +50,19 @@ module Fontist
|
|
48
50
|
def save_cache(generated_file, key)
|
49
51
|
path = move_to_downloads(generated_file)
|
50
52
|
|
51
|
-
|
52
|
-
|
53
|
-
|
53
|
+
lock(lock_path) do
|
54
|
+
map = load_cache
|
55
|
+
map[key] = path
|
56
|
+
File.write(cache_map_path, YAML.dump(map))
|
57
|
+
end
|
54
58
|
|
55
59
|
path
|
56
60
|
end
|
57
61
|
|
62
|
+
def lock_path
|
63
|
+
cache_map_path.to_s + ".lock"
|
64
|
+
end
|
65
|
+
|
58
66
|
def move_to_downloads(source)
|
59
67
|
create_downloads_directory
|
60
68
|
path = generate_file_path(source)
|
@@ -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)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Fontist
|
2
|
+
module Utils
|
3
|
+
module Locking
|
4
|
+
def lock(lock_path)
|
5
|
+
File.dirname(lock_path).tap do |dir|
|
6
|
+
FileUtils.mkdir_p(dir) unless File.exist?(dir)
|
7
|
+
end
|
8
|
+
|
9
|
+
f = File.open(lock_path, File::CREAT)
|
10
|
+
f.flock(File::LOCK_EX)
|
11
|
+
yield
|
12
|
+
ensure
|
13
|
+
f.flock(File::LOCK_UN)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -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.3
|
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:
|
12
|
+
date: 2021-01-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: down
|
@@ -165,6 +165,34 @@ dependencies:
|
|
165
165
|
- - "~>"
|
166
166
|
- !ruby/object:Gem::Version
|
167
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'
|
168
196
|
- !ruby/object:Gem::Dependency
|
169
197
|
name: rake
|
170
198
|
requirement: !ruby/object:Gem::Requirement
|
@@ -259,9 +287,8 @@ extensions: []
|
|
259
287
|
extra_rdoc_files: []
|
260
288
|
files:
|
261
289
|
- ".github/workflows/check_google.yml"
|
262
|
-
- ".github/workflows/
|
263
|
-
- ".github/workflows/
|
264
|
-
- ".github/workflows/windows.yml"
|
290
|
+
- ".github/workflows/release.yml"
|
291
|
+
- ".github/workflows/rspec.yml"
|
265
292
|
- ".gitignore"
|
266
293
|
- ".hound.yml"
|
267
294
|
- ".rspec"
|
@@ -270,24 +297,17 @@ files:
|
|
270
297
|
- LICENSE.txt
|
271
298
|
- README.md
|
272
299
|
- Rakefile
|
273
|
-
-
|
274
|
-
- bin/console
|
275
|
-
- bin/convert_formulas
|
276
|
-
- bin/fontist
|
277
|
-
- bin/generate_otfinfo
|
278
|
-
- bin/import_google
|
279
|
-
- bin/rspec
|
280
|
-
- bin/setup
|
300
|
+
- exe/fontist
|
281
301
|
- fontist.gemspec
|
282
302
|
- lib/fontist.rb
|
283
303
|
- lib/fontist/cli.rb
|
284
304
|
- lib/fontist/errors.rb
|
285
305
|
- lib/fontist/font.rb
|
286
|
-
- lib/fontist/
|
306
|
+
- lib/fontist/font_installer.rb
|
287
307
|
- lib/fontist/fontist_font.rb
|
288
308
|
- lib/fontist/formula.rb
|
289
|
-
- lib/fontist/
|
290
|
-
- lib/fontist/
|
309
|
+
- lib/fontist/formula_paths.rb
|
310
|
+
- lib/fontist/helpers.rb
|
291
311
|
- lib/fontist/import.rb
|
292
312
|
- lib/fontist/import/convert_formulas.rb
|
293
313
|
- lib/fontist/import/create_formula.rb
|
@@ -319,12 +339,14 @@ files:
|
|
319
339
|
- lib/fontist/import/otfinfo/template.erb
|
320
340
|
- lib/fontist/import/otfinfo_generate.rb
|
321
341
|
- lib/fontist/import/recursive_extraction.rb
|
342
|
+
- lib/fontist/import/sil_import.rb
|
322
343
|
- lib/fontist/import/template_helper.rb
|
323
344
|
- lib/fontist/import/text_helper.rb
|
345
|
+
- lib/fontist/index.rb
|
346
|
+
- lib/fontist/index_formula.rb
|
324
347
|
- lib/fontist/manifest.rb
|
325
348
|
- lib/fontist/manifest/install.rb
|
326
349
|
- lib/fontist/manifest/locations.rb
|
327
|
-
- lib/fontist/registry.rb
|
328
350
|
- lib/fontist/system.yml
|
329
351
|
- lib/fontist/system_font.rb
|
330
352
|
- lib/fontist/system_index.rb
|
@@ -335,6 +357,7 @@ files:
|
|
335
357
|
- lib/fontist/utils/dsl/collection_font.rb
|
336
358
|
- lib/fontist/utils/dsl/font.rb
|
337
359
|
- lib/fontist/utils/exe_extractor.rb
|
360
|
+
- lib/fontist/utils/locking.rb
|
338
361
|
- lib/fontist/utils/msi_extractor.rb
|
339
362
|
- lib/fontist/utils/seven_zip_extractor.rb
|
340
363
|
- lib/fontist/utils/system.rb
|
@@ -364,7 +387,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
364
387
|
version: '0'
|
365
388
|
requirements: []
|
366
389
|
rubygems_version: 3.0.3
|
367
|
-
signing_key:
|
390
|
+
signing_key:
|
368
391
|
specification_version: 4
|
369
392
|
summary: A libarary find or download fonts
|
370
393
|
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