fontist 1.20.0 → 1.21.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.
- checksums.yaml +4 -4
- data/.github/workflows/release.yml +21 -0
- data/.github/workflows/tebako-pack.yml +2 -2
- data/.github/workflows/test-and-release.yml +22 -16
- data/README.adoc +1 -1
- data/exe/fontist +1 -2
- data/fontist.gemspec +1 -1
- data/lib/fontist/cli/thor_ext.rb +79 -0
- data/lib/fontist/cli.rb +2 -0
- data/lib/fontist/config.rb +2 -1
- data/lib/fontist/font.rb +5 -0
- data/lib/fontist/font_installer.rb +22 -51
- data/lib/fontist/formula.rb +6 -0
- data/lib/fontist/helpers.rb +2 -0
- data/lib/fontist/import/create_formula.rb +77 -35
- data/lib/fontist/import/formula_builder.rb +63 -81
- data/lib/fontist/import/google/api.rb +25 -0
- data/lib/fontist/import/google/create_google_formula.rb +89 -0
- data/lib/fontist/import/google_import.rb +63 -32
- data/lib/fontist/import/recursive_extraction.rb +0 -16
- data/lib/fontist/manifest/locations.rb +2 -0
- data/lib/fontist/resources/archive_resource.rb +55 -0
- data/lib/fontist/resources/google_resource.rb +64 -0
- data/lib/fontist/style_version.rb +4 -0
- data/lib/fontist/utils/cache.rb +16 -0
- data/lib/fontist/utils/downloader.rb +9 -2
- data/lib/fontist/utils/ui.rb +10 -2
- data/lib/fontist/version.rb +1 -1
- data/lib/fontist.rb +5 -1
- metadata +15 -6
- data/lib/fontist/import/google/new_fonts_fetcher.rb +0 -146
- data/lib/fontist/import/google/skiplist.yml +0 -12
- data/lib/fontist/import/google_check.rb +0 -27
data/lib/fontist/utils/ui.rb
CHANGED
@@ -16,7 +16,15 @@ module Fontist
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def self.level
|
19
|
-
@level || default_level
|
19
|
+
@level ||= env_level || default_level
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.env_level
|
23
|
+
ENV["FONTIST_LOG"]&.to_sym
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.debug?
|
27
|
+
log_levels.include?(:debug)
|
20
28
|
end
|
21
29
|
|
22
30
|
def self.default_level
|
@@ -50,7 +58,7 @@ module Fontist
|
|
50
58
|
end
|
51
59
|
|
52
60
|
def self.debug(message)
|
53
|
-
new.say(message) if
|
61
|
+
new.say(message) if debug?
|
54
62
|
end
|
55
63
|
|
56
64
|
def self.log_levels
|
data/lib/fontist/version.rb
CHANGED
data/lib/fontist.rb
CHANGED
@@ -49,7 +49,7 @@ module Fontist
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def self.formulas_version
|
52
|
-
"
|
52
|
+
"v4"
|
53
53
|
end
|
54
54
|
|
55
55
|
def self.formulas_repo_url
|
@@ -159,4 +159,8 @@ module Fontist
|
|
159
159
|
def self.interactive=(bool)
|
160
160
|
@interactive = bool
|
161
161
|
end
|
162
|
+
|
163
|
+
def self.google_fonts_key
|
164
|
+
ENV["GOOGLE_FONTS_API_KEY"] || config[:google_fonts_key]
|
165
|
+
end
|
162
166
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fontist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.21.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: down
|
@@ -113,6 +113,9 @@ dependencies:
|
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '1.2'
|
118
|
+
- - ">="
|
116
119
|
- !ruby/object:Gem::Version
|
117
120
|
version: 1.2.1
|
118
121
|
type: :runtime
|
@@ -120,6 +123,9 @@ dependencies:
|
|
120
123
|
version_requirements: !ruby/object:Gem::Requirement
|
121
124
|
requirements:
|
122
125
|
- - "~>"
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '1.2'
|
128
|
+
- - ">="
|
123
129
|
- !ruby/object:Gem::Version
|
124
130
|
version: 1.2.1
|
125
131
|
- !ruby/object:Gem::Dependency
|
@@ -347,6 +353,7 @@ extensions: []
|
|
347
353
|
extra_rdoc_files: []
|
348
354
|
files:
|
349
355
|
- ".github/workflows/deploy-pages.yml"
|
356
|
+
- ".github/workflows/release.yml"
|
350
357
|
- ".github/workflows/tebako-pack.yml"
|
351
358
|
- ".github/workflows/test-and-release.yml"
|
352
359
|
- ".gitignore"
|
@@ -377,6 +384,7 @@ files:
|
|
377
384
|
- lib/fontist/cache_cli.rb
|
378
385
|
- lib/fontist/cli.rb
|
379
386
|
- lib/fontist/cli/class_options.rb
|
387
|
+
- lib/fontist/cli/thor_ext.rb
|
380
388
|
- lib/fontist/collection_file.rb
|
381
389
|
- lib/fontist/config.rb
|
382
390
|
- lib/fontist/config_cli.rb
|
@@ -401,9 +409,8 @@ files:
|
|
401
409
|
- lib/fontist/import/formula_builder.rb
|
402
410
|
- lib/fontist/import/formula_serializer.rb
|
403
411
|
- lib/fontist/import/google.rb
|
404
|
-
- lib/fontist/import/google/
|
405
|
-
- lib/fontist/import/google/
|
406
|
-
- lib/fontist/import/google_check.rb
|
412
|
+
- lib/fontist/import/google/api.rb
|
413
|
+
- lib/fontist/import/google/create_google_formula.rb
|
407
414
|
- lib/fontist/import/google_import.rb
|
408
415
|
- lib/fontist/import/helpers/hash_helper.rb
|
409
416
|
- lib/fontist/import/helpers/system_helper.rb
|
@@ -433,6 +440,8 @@ files:
|
|
433
440
|
- lib/fontist/manifest/locations.rb
|
434
441
|
- lib/fontist/repo.rb
|
435
442
|
- lib/fontist/repo_cli.rb
|
443
|
+
- lib/fontist/resources/archive_resource.rb
|
444
|
+
- lib/fontist/resources/google_resource.rb
|
436
445
|
- lib/fontist/style_version.rb
|
437
446
|
- lib/fontist/system.yml
|
438
447
|
- lib/fontist/system_font.rb
|
@@ -468,7 +477,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
468
477
|
- !ruby/object:Gem::Version
|
469
478
|
version: '0'
|
470
479
|
requirements: []
|
471
|
-
rubygems_version: 3.3.
|
480
|
+
rubygems_version: 3.3.27
|
472
481
|
signing_key:
|
473
482
|
specification_version: 4
|
474
483
|
summary: Install openly-licensed fonts on Windows, Linux and Mac!
|
@@ -1,146 +0,0 @@
|
|
1
|
-
require_relative "../google"
|
2
|
-
require_relative "../otf_parser"
|
3
|
-
|
4
|
-
module Fontist
|
5
|
-
module Import
|
6
|
-
module Google
|
7
|
-
class NewFontsFetcher
|
8
|
-
REPO_PATH = Fontist.fontist_path.join("google", "fonts")
|
9
|
-
REPO_URL = "https://github.com/google/fonts.git".freeze
|
10
|
-
SKIPLIST_PATH = File.expand_path("skiplist.yml", __dir__)
|
11
|
-
|
12
|
-
def initialize(logging: false, limit: nil)
|
13
|
-
@logging = logging
|
14
|
-
@limit = limit
|
15
|
-
end
|
16
|
-
|
17
|
-
def call
|
18
|
-
update_repo
|
19
|
-
fetch_new_paths
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
def update_repo
|
25
|
-
if Dir.exist?(REPO_PATH)
|
26
|
-
`cd #{REPO_PATH} && git pull`
|
27
|
-
else
|
28
|
-
FileUtils.mkdir_p(File.dirname(REPO_PATH))
|
29
|
-
`git clone --depth 1 #{REPO_URL} #{REPO_PATH}`
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def fetch_new_paths
|
34
|
-
new_paths = []
|
35
|
-
|
36
|
-
fetch_fonts_paths.each do |path|
|
37
|
-
new = log_font(path) do
|
38
|
-
new?(path)
|
39
|
-
end
|
40
|
-
|
41
|
-
next unless new
|
42
|
-
|
43
|
-
new_paths << path
|
44
|
-
return new_paths if @limit && new_paths.size >= @limit
|
45
|
-
end
|
46
|
-
|
47
|
-
new_paths
|
48
|
-
end
|
49
|
-
|
50
|
-
def fetch_fonts_paths
|
51
|
-
Dir[File.join(REPO_PATH, "apache", "*"),
|
52
|
-
File.join(REPO_PATH, "ofl", "*"),
|
53
|
-
File.join(REPO_PATH, "ufl", "*")].sort
|
54
|
-
end
|
55
|
-
|
56
|
-
def log_font(path)
|
57
|
-
return yield unless @logging
|
58
|
-
|
59
|
-
print "#{path}, "
|
60
|
-
new = yield
|
61
|
-
puts(new ? "new" : "skipped")
|
62
|
-
new
|
63
|
-
end
|
64
|
-
|
65
|
-
def new?(path)
|
66
|
-
metadata_name = Google.metadata_name(path)
|
67
|
-
return unless metadata_name
|
68
|
-
return if in_skiplist?(metadata_name)
|
69
|
-
return if up_to_date?(metadata_name, path)
|
70
|
-
return unless downloadable?(metadata_name)
|
71
|
-
|
72
|
-
true
|
73
|
-
end
|
74
|
-
|
75
|
-
def in_skiplist?(name)
|
76
|
-
@skiplist ||= YAML.safe_load(File.open(SKIPLIST_PATH))
|
77
|
-
@skiplist.include?(name)
|
78
|
-
end
|
79
|
-
|
80
|
-
def up_to_date?(metadata_name, path)
|
81
|
-
formula = formula(metadata_name)
|
82
|
-
return false unless formula
|
83
|
-
|
84
|
-
repo_digest_up_to_date?(formula, path) ||
|
85
|
-
fonts_up_to_date?(formula, path)
|
86
|
-
end
|
87
|
-
|
88
|
-
def repo_digest_up_to_date?(formula, path)
|
89
|
-
return unless formula.digest
|
90
|
-
|
91
|
-
formula.digest == Google.digest(path)
|
92
|
-
end
|
93
|
-
|
94
|
-
def fonts_up_to_date?(formula, path)
|
95
|
-
styles = formula_styles(formula)
|
96
|
-
repo_fonts(path).all? do |font|
|
97
|
-
style = styles.find { |s| s.font == repo_to_archive_name(font) }
|
98
|
-
return false unless style
|
99
|
-
|
100
|
-
otfinfo_version(font) == style.version
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
def formula_styles(formula)
|
105
|
-
formula.fonts.map(&:styles).flatten
|
106
|
-
end
|
107
|
-
|
108
|
-
def repo_fonts(path)
|
109
|
-
Dir.glob(File.join(path, "*.{ttf,otf}"))
|
110
|
-
end
|
111
|
-
|
112
|
-
def repo_to_archive_name(font_path)
|
113
|
-
File.basename(font_path)
|
114
|
-
.sub("[wght]", "-VariableFont_wght")
|
115
|
-
.sub("[opsz]", "-Regular-VariableFont_opsz")
|
116
|
-
end
|
117
|
-
|
118
|
-
def formula(font_name)
|
119
|
-
path = Fontist::Import::Google.formula_path(font_name)
|
120
|
-
Formula.new_from_file(path) if File.exist?(path)
|
121
|
-
end
|
122
|
-
|
123
|
-
def otfinfo_version(path)
|
124
|
-
info = OtfParser.new(path).call
|
125
|
-
Fontist::Import::Google.style_version(info["Version"])
|
126
|
-
end
|
127
|
-
|
128
|
-
def downloadable?(name)
|
129
|
-
retries ||= 0
|
130
|
-
retries += 1
|
131
|
-
Down.open("https://fonts.google.com/download?family=#{name}")
|
132
|
-
true
|
133
|
-
rescue Down::NotFound
|
134
|
-
false
|
135
|
-
rescue Down::ClientError => e
|
136
|
-
raise unless e.message == "403 Forbidden"
|
137
|
-
|
138
|
-
false
|
139
|
-
rescue Down::TimeoutError
|
140
|
-
retry unless retries >= 3
|
141
|
-
false
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
146
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require_relative "google/new_fonts_fetcher"
|
2
|
-
|
3
|
-
module Fontist
|
4
|
-
module Import
|
5
|
-
class GoogleCheck
|
6
|
-
def call
|
7
|
-
fonts = new_fonts
|
8
|
-
indicate(fonts)
|
9
|
-
end
|
10
|
-
|
11
|
-
private
|
12
|
-
|
13
|
-
def new_fonts
|
14
|
-
Fontist::Import::Google::NewFontsFetcher.new(logging: true).call
|
15
|
-
end
|
16
|
-
|
17
|
-
def indicate(new_paths)
|
18
|
-
return if new_paths.empty?
|
19
|
-
|
20
|
-
puts "New fonts are available in:"
|
21
|
-
new_paths.each do |path|
|
22
|
-
puts path
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|