fontist 1.2.1 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/check_google.yml +28 -0
- data/.github/workflows/macosx.yml +3 -0
- data/.github/workflows/ubuntu.yml +1 -1
- data/.github/workflows/windows.yml +1 -1
- data/.gitignore +6 -0
- data/.hound.yml +2 -0
- data/.rubocop.yml +22 -0
- data/README.md +224 -0
- data/bin/check_google +8 -0
- data/bin/convert_formulas +8 -0
- data/bin/fontist +7 -0
- data/bin/generate_otfinfo +8 -0
- data/bin/import_google +8 -0
- data/fontist.gemspec +16 -1
- data/lib/fontist.rb +23 -13
- data/lib/fontist/cli.rb +162 -0
- data/lib/fontist/errors.rb +5 -0
- data/lib/fontist/font.rb +181 -8
- data/lib/fontist/font_formula.rb +12 -5
- data/lib/fontist/fontist_font.rb +70 -0
- data/lib/fontist/formula.rb +27 -9
- data/lib/fontist/formula_template.rb +108 -0
- data/lib/fontist/formulas.rb +41 -0
- data/lib/fontist/import.rb +9 -0
- data/lib/fontist/import/convert_formulas.rb +65 -0
- data/lib/fontist/import/create_formula.rb +74 -0
- data/lib/fontist/import/extractors.rb +5 -0
- data/lib/fontist/import/extractors/cab_extractor.rb +37 -0
- data/lib/fontist/import/extractors/extractor.rb +19 -0
- data/lib/fontist/import/extractors/ole_extractor.rb +41 -0
- data/lib/fontist/import/extractors/seven_zip_extractor.rb +44 -0
- data/lib/fontist/import/extractors/zip_extractor.rb +31 -0
- data/lib/fontist/import/files/collection_file.rb +47 -0
- data/lib/fontist/import/formula_builder.rb +162 -0
- data/lib/fontist/import/formula_serializer.rb +133 -0
- data/lib/fontist/import/google.rb +16 -0
- data/lib/fontist/import/google/fonts_public.md +10 -0
- data/lib/fontist/import/google/fonts_public.pb.rb +71 -0
- data/lib/fontist/import/google/fonts_public.proto +46 -0
- data/lib/fontist/import/google/new_fonts_fetcher.rb +121 -0
- data/lib/fontist/import/google/skiplist.yml +8 -0
- data/lib/fontist/import/google_check.rb +34 -0
- data/lib/fontist/import/google_import.rb +180 -0
- data/lib/fontist/import/helpers/hash_helper.rb +13 -0
- data/lib/fontist/import/helpers/system_helper.rb +23 -0
- data/lib/fontist/import/otf/font_file.rb +91 -0
- data/lib/fontist/import/otf_parser.rb +25 -0
- data/lib/fontist/import/otf_style.rb +29 -0
- data/lib/fontist/import/otfinfo/otfinfo_requirement.rb +22 -0
- data/lib/fontist/import/otfinfo/template.erb +20 -0
- data/lib/fontist/import/otfinfo_generate.rb +45 -0
- data/lib/fontist/import/recursive_extraction.rb +128 -0
- data/lib/fontist/import/template_helper.rb +19 -0
- data/lib/fontist/import/text_helper.rb +30 -0
- data/lib/fontist/manifest.rb +2 -0
- data/lib/fontist/manifest/common.rb +60 -0
- data/lib/fontist/manifest/install.rb +36 -0
- data/lib/fontist/manifest/locations.rb +13 -0
- data/lib/fontist/registry.rb +1 -0
- data/lib/fontist/system_font.rb +53 -22
- data/lib/fontist/utils.rb +5 -0
- data/lib/fontist/utils/cache.rb +88 -0
- data/lib/fontist/utils/downloader.rb +69 -8
- data/lib/fontist/utils/dsl.rb +4 -0
- data/lib/fontist/utils/dsl/font.rb +37 -0
- data/lib/fontist/utils/exe_extractor.rb +20 -18
- data/lib/fontist/utils/msi_extractor.rb +31 -0
- data/lib/fontist/utils/seven_zip_extractor.rb +41 -0
- data/lib/fontist/utils/system.rb +23 -0
- data/lib/fontist/utils/ui.rb +27 -0
- data/lib/fontist/utils/zip_extractor.rb +10 -4
- data/lib/fontist/version.rb +1 -1
- metadata +185 -48
- data/lib/fontist/formulas/andale_font.rb +0 -80
- data/lib/fontist/formulas/arial_black_font.rb +0 -79
- data/lib/fontist/formulas/cleartype_fonts.rb +0 -227
- data/lib/fontist/formulas/comic_font.rb +0 -78
- data/lib/fontist/formulas/courier_font.rb +0 -81
- data/lib/fontist/formulas/euphemia_font.rb +0 -85
- data/lib/fontist/formulas/georgia_font.rb +0 -80
- data/lib/fontist/formulas/impact_font.rb +0 -78
- data/lib/fontist/formulas/montserrat_font.rb +0 -132
- data/lib/fontist/formulas/ms_truetype_fonts.rb +0 -125
- data/lib/fontist/formulas/open_sans_fonts.rb +0 -263
- data/lib/fontist/formulas/overpass_font.rb +0 -73
- data/lib/fontist/formulas/source_fonts.rb +0 -109
- data/lib/fontist/formulas/stix_fonts.rb +0 -108
- data/lib/fontist/formulas/tahoma_font.rb +0 -147
- data/lib/fontist/formulas/webding_font.rb +0 -78
- data/spec/fontist/font_formula_spec.rb +0 -67
- data/spec/fontist/font_spec.rb +0 -87
- data/spec/fontist/formula_spec.rb +0 -67
- data/spec/fontist/formulas/andale_font_spec.rb +0 -29
- data/spec/fontist/formulas/arial_black_font_spec.rb +0 -29
- data/spec/fontist/formulas/cleartype_fonts_spec.rb +0 -38
- data/spec/fontist/formulas/comic_font_spec.rb +0 -29
- data/spec/fontist/formulas/courier_font_spec.rb +0 -29
- data/spec/fontist/formulas/euphemia_font_spec.rb +0 -29
- data/spec/fontist/formulas/georgia_font_spec.rb +0 -29
- data/spec/fontist/formulas/impact_font_spec.rb +0 -29
- data/spec/fontist/formulas/montserrat_font_spec.rb +0 -29
- data/spec/fontist/formulas/ms_truetype_fonts_spec.rb +0 -29
- data/spec/fontist/formulas/open_sans_fonts_spec.rb +0 -29
- data/spec/fontist/formulas/overpass_font_spec.rb +0 -29
- data/spec/fontist/formulas/source_fonts_spec.rb +0 -31
- data/spec/fontist/formulas/stix_fonts_spec.rb +0 -29
- data/spec/fontist/formulas/tahoma_font_spec.rb +0 -29
- data/spec/fontist/formulas/webding_font_spec.rb +0 -29
- data/spec/fontist/registry_spec.rb +0 -47
- data/spec/fontist/system_font_spec.rb +0 -44
- data/spec/fontist/utils/downloader_spec.rb +0 -35
- data/spec/fontist_spec.rb +0 -5
- data/spec/spec_helper.rb +0 -22
- data/spec/support/fontist_helper.rb +0 -10
data/lib/fontist/cli.rb
ADDED
@@ -0,0 +1,162 @@
|
|
1
|
+
require "thor"
|
2
|
+
|
3
|
+
module Fontist
|
4
|
+
class CLI < Thor
|
5
|
+
STATUS_SUCCESS = 0
|
6
|
+
STATUS_ERROR = 1
|
7
|
+
|
8
|
+
def self.exit_on_failure?
|
9
|
+
false
|
10
|
+
end
|
11
|
+
|
12
|
+
desc "install FONT", "Install font by font or formula"
|
13
|
+
option :force, type: :boolean, aliases: :f,
|
14
|
+
desc: "Install even if it's already installed in system"
|
15
|
+
def install(font)
|
16
|
+
Fontist::Font.install(font, force: options[:force])
|
17
|
+
STATUS_SUCCESS
|
18
|
+
rescue Fontist::Errors::NonSupportedFontError
|
19
|
+
could_not_find_font(font)
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "uninstall/remove FONT", "Uninstall font by font or formula"
|
23
|
+
def uninstall(font)
|
24
|
+
fonts_paths = Fontist::Font.uninstall(font)
|
25
|
+
Fontist.ui.success("These fonts are removed:")
|
26
|
+
Fontist.ui.success(fonts_paths.join("\n"))
|
27
|
+
STATUS_SUCCESS
|
28
|
+
rescue Fontist::Errors::MissingFontError => e
|
29
|
+
Fontist.ui.error(e.message)
|
30
|
+
STATUS_ERROR
|
31
|
+
rescue Fontist::Errors::NonSupportedFontError
|
32
|
+
could_not_find_font(font)
|
33
|
+
end
|
34
|
+
map remove: :uninstall
|
35
|
+
|
36
|
+
desc "status [FONT]", "Show status of FONT or all fonts in fontist"
|
37
|
+
def status(font = nil)
|
38
|
+
formulas = Fontist::Font.status(font)
|
39
|
+
return error("No font is installed.") if formulas.empty?
|
40
|
+
|
41
|
+
print_formulas(formulas)
|
42
|
+
success
|
43
|
+
rescue Fontist::Errors::MissingFontError => e
|
44
|
+
error(e.message)
|
45
|
+
rescue Fontist::Errors::NonSupportedFontError
|
46
|
+
could_not_find_font(font)
|
47
|
+
end
|
48
|
+
|
49
|
+
desc "list [FONT]", "List installation status of FONT or fonts in fontist"
|
50
|
+
def list(font = nil)
|
51
|
+
formulas = Fontist::Font.list(font)
|
52
|
+
print_list(formulas)
|
53
|
+
success
|
54
|
+
rescue Fontist::Errors::NonSupportedFontError
|
55
|
+
could_not_find_font(font)
|
56
|
+
end
|
57
|
+
|
58
|
+
desc "update", "Update formulas"
|
59
|
+
def update
|
60
|
+
Formulas.fetch_formulas
|
61
|
+
Fontist.ui.say("Formulas have been successfully updated")
|
62
|
+
STATUS_SUCCESS
|
63
|
+
end
|
64
|
+
|
65
|
+
desc "manifest-locations MANIFEST",
|
66
|
+
"Get locations of fonts from MANIFEST (yaml)"
|
67
|
+
def manifest_locations(manifest)
|
68
|
+
paths = Fontist::Manifest::Locations.call(manifest)
|
69
|
+
print_yaml(paths)
|
70
|
+
success
|
71
|
+
rescue Fontist::Errors::ManifestCouldNotBeFoundError
|
72
|
+
error("Manifest could not be found.")
|
73
|
+
rescue Fontist::Errors::ManifestCouldNotBeReadError
|
74
|
+
error("Manifest could not be read.")
|
75
|
+
end
|
76
|
+
|
77
|
+
desc "manifest-install MANIFEST", "Install fonts from MANIFEST (yaml)"
|
78
|
+
option :confirm_license, type: :boolean, desc: "Confirm license agreement"
|
79
|
+
def manifest_install(manifest)
|
80
|
+
paths = Fontist::Manifest::Install.call(
|
81
|
+
manifest,
|
82
|
+
confirmation: options[:confirm_license] ? "yes" : "no"
|
83
|
+
)
|
84
|
+
|
85
|
+
print_yaml(paths)
|
86
|
+
success
|
87
|
+
rescue Fontist::Errors::ManifestCouldNotBeFoundError
|
88
|
+
error("Manifest could not be found.")
|
89
|
+
rescue Fontist::Errors::ManifestCouldNotBeReadError
|
90
|
+
error("Manifest could not be read.")
|
91
|
+
end
|
92
|
+
|
93
|
+
desc "create-formula URL", "Create a new formula with fonts from URL"
|
94
|
+
option :name, desc: "Example: Times New Roman"
|
95
|
+
option :mirror, repeatable: true
|
96
|
+
option :subarchive, desc: "Subarchive to choose when there are several ones"
|
97
|
+
def create_formula(url)
|
98
|
+
require "fontist/import/create_formula"
|
99
|
+
name = Fontist::Import::CreateFormula.new(url, options).call
|
100
|
+
Fontist.ui.say("#{name} formula has been successfully created")
|
101
|
+
STATUS_SUCCESS
|
102
|
+
end
|
103
|
+
|
104
|
+
private
|
105
|
+
|
106
|
+
def success
|
107
|
+
STATUS_SUCCESS
|
108
|
+
end
|
109
|
+
|
110
|
+
def could_not_find_font(font)
|
111
|
+
error("Font '#{font}' not found locally nor available in the Fontist " \
|
112
|
+
"formula repository.\n" \
|
113
|
+
"Perhaps it is available at the latest Fontist formula " \
|
114
|
+
"repository.\n" \
|
115
|
+
"You can update the formula repository using the command " \
|
116
|
+
"`fontist update` and try again.")
|
117
|
+
end
|
118
|
+
|
119
|
+
def error(message)
|
120
|
+
Fontist.ui.error(message)
|
121
|
+
STATUS_ERROR
|
122
|
+
end
|
123
|
+
|
124
|
+
def print_yaml(object)
|
125
|
+
Fontist.ui.say(YAML.dump(object))
|
126
|
+
end
|
127
|
+
|
128
|
+
def print_formulas(formulas)
|
129
|
+
formulas.each do |formula, fonts|
|
130
|
+
Fontist.ui.success(formula.installer)
|
131
|
+
|
132
|
+
fonts.each do |font, styles|
|
133
|
+
Fontist.ui.success(" #{font.name}")
|
134
|
+
|
135
|
+
styles.each do |style, path|
|
136
|
+
Fontist.ui.success(" #{style.type} (#{path})")
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
143
|
+
def print_list(formulas)
|
144
|
+
formulas.each do |formula, fonts|
|
145
|
+
Fontist.ui.say(formula.installer)
|
146
|
+
|
147
|
+
fonts.each do |font, styles|
|
148
|
+
Fontist.ui.say(" #{font.name}")
|
149
|
+
|
150
|
+
styles.each do |style, installed|
|
151
|
+
if installed
|
152
|
+
Fontist.ui.success(" #{style.type} (installed)")
|
153
|
+
else
|
154
|
+
Fontist.ui.error(" #{style.type} (uninstalled)")
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
161
|
+
end
|
162
|
+
end
|
data/lib/fontist/errors.rb
CHANGED
@@ -6,5 +6,10 @@ module Fontist
|
|
6
6
|
class TamperedFileError < StandardError; end
|
7
7
|
class InvalidResourceError < StandardError; end
|
8
8
|
class TimeoutError < StandardError; end
|
9
|
+
class MissingAttributeError < StandardError; end
|
10
|
+
class FontNotFoundError < StandardError; end
|
11
|
+
class BinaryCallError < StandardError; end
|
12
|
+
class ManifestCouldNotBeReadError < StandardError; end
|
13
|
+
class ManifestCouldNotBeFoundError < StandardError; end
|
9
14
|
end
|
10
15
|
end
|
data/lib/fontist/font.rb
CHANGED
@@ -3,6 +3,7 @@ module Fontist
|
|
3
3
|
def initialize(options = {})
|
4
4
|
@name = options.fetch(:name, nil)
|
5
5
|
@confirmation = options.fetch(:confirmation, "no")
|
6
|
+
@force = options.fetch(:force, false)
|
6
7
|
|
7
8
|
check_or_create_fontist_path!
|
8
9
|
end
|
@@ -15,8 +16,24 @@ module Fontist
|
|
15
16
|
new(name: name).find
|
16
17
|
end
|
17
18
|
|
18
|
-
def self.install(name, confirmation: "no")
|
19
|
-
new(name: name, confirmation: confirmation).install
|
19
|
+
def self.install(name, confirmation: "no", force: false)
|
20
|
+
new(name: name, confirmation: confirmation, force: force).install
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.try_install(name, confirmation: "no")
|
24
|
+
new(name: name, confirmation: confirmation).try_install
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.uninstall(name)
|
28
|
+
new(name: name).uninstall
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.status(name)
|
32
|
+
new(name: name).status
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.list(name)
|
36
|
+
new(name: name).list
|
20
37
|
end
|
21
38
|
|
22
39
|
def find
|
@@ -26,11 +43,35 @@ module Fontist
|
|
26
43
|
end
|
27
44
|
|
28
45
|
def install
|
29
|
-
find_system_font || download_font || raise(
|
46
|
+
(find_system_font unless @force) || download_font || raise(
|
47
|
+
Fontist::Errors::NonSupportedFontError
|
48
|
+
)
|
49
|
+
end
|
50
|
+
|
51
|
+
def try_install
|
52
|
+
download_font
|
53
|
+
end
|
54
|
+
|
55
|
+
def uninstall
|
56
|
+
uninstall_font || downloadable_font || raise(
|
57
|
+
Fontist::Errors::NonSupportedFontError
|
58
|
+
)
|
59
|
+
end
|
60
|
+
|
61
|
+
def status
|
62
|
+
return installed_statuses unless @name
|
63
|
+
|
64
|
+
font_status || downloadable_font || raise(
|
30
65
|
Fontist::Errors::NonSupportedFontError
|
31
66
|
)
|
32
67
|
end
|
33
68
|
|
69
|
+
def list
|
70
|
+
return all_list unless @name
|
71
|
+
|
72
|
+
font_list || raise(Fontist::Errors::NonSupportedFontError)
|
73
|
+
end
|
74
|
+
|
34
75
|
def all
|
35
76
|
Fontist::Formula.all.to_h.map { |_name, formula| formula.fonts }.flatten
|
36
77
|
end
|
@@ -40,7 +81,16 @@ module Fontist
|
|
40
81
|
attr_reader :name, :confirmation
|
41
82
|
|
42
83
|
def find_system_font
|
43
|
-
Fontist::SystemFont.find(name)
|
84
|
+
paths = Fontist::SystemFont.find(name)
|
85
|
+
unless paths
|
86
|
+
Fontist.ui.say(%(Font "#{name}" not found locally.))
|
87
|
+
return
|
88
|
+
end
|
89
|
+
|
90
|
+
Fontist.ui.say("Fonts found at:")
|
91
|
+
paths.each do |path|
|
92
|
+
Fontist.ui.say("- #{path}")
|
93
|
+
end
|
44
94
|
end
|
45
95
|
|
46
96
|
def check_or_create_fontist_path!
|
@@ -62,17 +112,140 @@ module Fontist
|
|
62
112
|
if formula
|
63
113
|
raise(
|
64
114
|
Fontist::Errors::MissingFontError,
|
65
|
-
"
|
66
|
-
"
|
67
|
-
"download the font"
|
115
|
+
"#{name} fonts are missing, please run " \
|
116
|
+
"`fontist install '#{name}'` to " \
|
117
|
+
"download the font."
|
68
118
|
)
|
69
119
|
end
|
70
120
|
end
|
71
121
|
|
72
122
|
def download_font
|
73
123
|
if formula
|
74
|
-
|
124
|
+
check_and_confirm_required_license(formula)
|
125
|
+
paths = font_installer(formula).fetch_font(name,
|
126
|
+
confirmation: confirmation)
|
127
|
+
|
128
|
+
Fontist.ui.say("Fonts installed at:")
|
129
|
+
paths.each do |path|
|
130
|
+
Fontist.ui.say("- #{path}")
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def check_and_confirm_required_license(formula)
|
136
|
+
if formula.license_required && !confirmation.casecmp("yes").zero?
|
137
|
+
@confirmation = show_license_and_ask_for_input(formula.license)
|
138
|
+
|
139
|
+
if !confirmation.casecmp("yes").zero?
|
140
|
+
raise Fontist::Errors::LicensingError.new(
|
141
|
+
"Fontist will not download these fonts unless you accept the terms."
|
142
|
+
)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
def show_license_and_ask_for_input(license)
|
148
|
+
Fontist.ui.say(license_agrement_message(license))
|
149
|
+
Fontist.ui.ask(
|
150
|
+
"\nDo you accept all presented font licenses, and want Fontist " \
|
151
|
+
"to download these fonts for you? => TYPE 'Yes' or 'No':"
|
152
|
+
)
|
153
|
+
end
|
154
|
+
|
155
|
+
def license_agrement_message(license)
|
156
|
+
<<~MSG
|
157
|
+
FONT LICENSE ACCEPTANCE REQUIRED FOR "#{name}":
|
158
|
+
|
159
|
+
Fontist can install this font if you accept its licensing conditions.
|
160
|
+
|
161
|
+
FONT LICENSE BEGIN ("#{name}")
|
162
|
+
-----------------------------------------------------------------------
|
163
|
+
#{license}
|
164
|
+
-----------------------------------------------------------------------
|
165
|
+
FONT LICENSE END ("#{name}")
|
166
|
+
MSG
|
167
|
+
end
|
168
|
+
|
169
|
+
def uninstall_font
|
170
|
+
paths = find_fontist_font
|
171
|
+
return unless paths
|
172
|
+
|
173
|
+
paths.each do |path|
|
174
|
+
File.delete(path)
|
175
|
+
end
|
176
|
+
|
177
|
+
paths
|
178
|
+
end
|
179
|
+
|
180
|
+
def find_fontist_font
|
181
|
+
Fontist::FontistFont.find(name)
|
182
|
+
end
|
183
|
+
|
184
|
+
def installed_statuses
|
185
|
+
installed_styles(all_formulas)
|
186
|
+
end
|
187
|
+
|
188
|
+
def all_formulas
|
189
|
+
Fontist::Formula.all.to_h.values
|
190
|
+
end
|
191
|
+
|
192
|
+
def font_status
|
193
|
+
return unless formula
|
194
|
+
|
195
|
+
statuses = installed_styles([formula])
|
196
|
+
statuses.empty? ? nil : statuses
|
197
|
+
end
|
198
|
+
|
199
|
+
def installed_styles(formulas)
|
200
|
+
filter_blank(formulas) do |formula|
|
201
|
+
filter_blank(formula.fonts) do |font|
|
202
|
+
filter_blank(font.styles) do |style|
|
203
|
+
path(style)
|
204
|
+
end
|
205
|
+
end
|
75
206
|
end
|
76
207
|
end
|
208
|
+
|
209
|
+
def filter_blank(elements)
|
210
|
+
elements.map { |e| [e, yield(e)] }
|
211
|
+
.to_h
|
212
|
+
.reject { |_k, v| v.nil? || v.empty? }
|
213
|
+
end
|
214
|
+
|
215
|
+
def path(style)
|
216
|
+
font_paths.grep(/#{style.font}/i).first
|
217
|
+
end
|
218
|
+
|
219
|
+
def font_paths
|
220
|
+
@font_paths ||= Dir.glob(Fontist.fonts_path.join("**"))
|
221
|
+
end
|
222
|
+
|
223
|
+
def all_list
|
224
|
+
list_styles(all_formulas)
|
225
|
+
end
|
226
|
+
|
227
|
+
def font_list
|
228
|
+
return unless formula
|
229
|
+
|
230
|
+
list_styles([formula])
|
231
|
+
end
|
232
|
+
|
233
|
+
def list_styles(formulas)
|
234
|
+
map_to_hash(formulas) do |formula|
|
235
|
+
map_to_hash(formula.fonts) do |font|
|
236
|
+
map_to_hash(font.styles) do |style|
|
237
|
+
installed(style)
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
def map_to_hash(elements)
|
244
|
+
elements.map { |e| [e, yield(e)] }.to_h
|
245
|
+
end
|
246
|
+
|
247
|
+
def installed(style)
|
248
|
+
path(style) ? true : false
|
249
|
+
end
|
77
250
|
end
|
78
251
|
end
|
data/lib/fontist/font_formula.rb
CHANGED
@@ -4,8 +4,10 @@ module Fontist
|
|
4
4
|
extend Fontist::Utils::Dsl
|
5
5
|
include Fontist::Utils::ZipExtractor
|
6
6
|
include Fontist::Utils::ExeExtractor
|
7
|
+
include Fontist::Utils::MsiExtractor
|
8
|
+
include Fontist::Utils::SevenZipExtractor
|
7
9
|
|
8
|
-
attr_accessor :license, :license_url, :license_required
|
10
|
+
attr_accessor :license, :license_url, :license_required, :copyright
|
9
11
|
attr_accessor :key, :homepage, :description, :options, :temp_resource
|
10
12
|
|
11
13
|
def font_list
|
@@ -55,7 +57,7 @@ module Fontist
|
|
55
57
|
end
|
56
58
|
|
57
59
|
def fonts_path
|
58
|
-
@fonts_path
|
60
|
+
@fonts_path = Fontist.fonts_path
|
59
61
|
end
|
60
62
|
|
61
63
|
def default_font
|
@@ -75,7 +77,9 @@ module Fontist
|
|
75
77
|
styles = options.fetch(:match_styles_from_file, [])
|
76
78
|
|
77
79
|
unless styles.empty?
|
78
|
-
styles.map
|
80
|
+
styles.map do |attributes|
|
81
|
+
Fontist::Utils::Dsl::Font.new(attributes).attributes
|
82
|
+
end
|
79
83
|
end
|
80
84
|
end
|
81
85
|
|
@@ -105,8 +109,11 @@ module Fontist
|
|
105
109
|
end
|
106
110
|
|
107
111
|
def download_file(source)
|
112
|
+
url = source[:urls].first
|
113
|
+
Fontist.ui.say(%(Downloading font "#{key}" from #{url}))
|
114
|
+
|
108
115
|
downloaded_file = Fontist::Utils::Downloader.download(
|
109
|
-
|
116
|
+
url,
|
110
117
|
sha: source[:sha256],
|
111
118
|
file_size: source[:file_size],
|
112
119
|
progress_bar: is_progress_bar_enabled
|
@@ -117,7 +124,7 @@ module Fontist
|
|
117
124
|
end
|
118
125
|
|
119
126
|
def is_progress_bar_enabled
|
120
|
-
options.nil? ?
|
127
|
+
options.nil? ? true : options.fetch(:progress_bar, true)
|
121
128
|
end
|
122
129
|
end
|
123
130
|
end
|