fontist 1.3.0 → 1.7.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 +15 -1
- data/lib/fontist.rb +19 -13
- data/lib/fontist/cli.rb +168 -0
- data/lib/fontist/errors.rb +6 -0
- data/lib/fontist/font.rb +145 -7
- data/lib/fontist/font_formula.rb +42 -7
- data/lib/fontist/fontist_font.rb +70 -0
- data/lib/fontist/formula.rb +31 -9
- data/lib/fontist/formula_template.rb +122 -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 +59 -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 +52 -0
- data/lib/fontist/import/files/file_requirement.rb +17 -0
- data/lib/fontist/import/files/font_detector.rb +48 -0
- data/lib/fontist/import/formula_builder.rb +166 -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 +105 -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 +185 -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/install.rb +32 -0
- data/lib/fontist/manifest/locations.rb +60 -0
- data/lib/fontist/system_font.rb +66 -22
- data/lib/fontist/utils.rb +5 -0
- data/lib/fontist/utils/cache.rb +88 -0
- data/lib/fontist/utils/downloader.rb +66 -9
- data/lib/fontist/utils/dsl.rb +8 -0
- data/lib/fontist/utils/dsl/collection_font.rb +36 -0
- data/lib/fontist/utils/dsl/font.rb +38 -0
- data/lib/fontist/utils/exe_extractor.rb +25 -22
- 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 +12 -0
- data/lib/fontist/utils/zip_extractor.rb +22 -8
- data/lib/fontist/version.rb +1 -1
- metadata +173 -49
- 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 -113
- 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
@@ -1,147 +0,0 @@
|
|
1
|
-
module Fontist
|
2
|
-
module Formulas
|
3
|
-
class TahomaFont < FontFormula
|
4
|
-
desc "Microsoft Tahoma Font"
|
5
|
-
homepage "https://www.microsoft.com"
|
6
|
-
|
7
|
-
resource "IELPKTH.CAB" do
|
8
|
-
urls [
|
9
|
-
"https://gitlab.com/fontmirror/archive/-/raw/master/IELPKTH.CAB",
|
10
|
-
"https://master.dl.sourceforge.net/project/corefonts/OldFiles/IELPKTH.CAB"
|
11
|
-
]
|
12
|
-
|
13
|
-
sha256 "c1be3fb8f0042570be76ec6daa03a99142c88367c1bc810240b85827c715961a"
|
14
|
-
end
|
15
|
-
|
16
|
-
provides_font("Tahoma", match_styles_from_file: {
|
17
|
-
"Regular" => "tahoma.ttf",
|
18
|
-
"Bold" => "tahomabd.ttf"
|
19
|
-
})
|
20
|
-
|
21
|
-
def extract
|
22
|
-
resource("IELPKTH.CAB") do |resource|
|
23
|
-
cab_extract(resource) do |fontdir|
|
24
|
-
match_fonts(fontdir, "Tahoma")
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def install
|
30
|
-
case platform
|
31
|
-
when :macos
|
32
|
-
install_matched_fonts "$HOME/Library/Fonts/Microsoft"
|
33
|
-
when :linux
|
34
|
-
install_matched_fonts "/usr/share/fonts/truetype/microsoft"
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
test do
|
39
|
-
case platform
|
40
|
-
when :macos
|
41
|
-
assert_predicate "$HOME/Library/Fonts/Microsoft/tahoma.ttf", :exist?
|
42
|
-
when :linux
|
43
|
-
assert_predicate "/usr/share/fonts/truetype/microsoft/tahoma.ttf", :exist?
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
requires_license_agreement <<~EOS
|
48
|
-
Microsoft Viewer for Word
|
49
|
-
END-USER LICENSE AGREEMENT FOR MICROSOFT SOFTWARE
|
50
|
-
|
51
|
-
------------------------
|
52
|
-
IMPORTANT-READ CAREFULLY: This Microsoft End-User License Agreement
|
53
|
-
("EULA") is a legal agreement between you (either an individual or a single
|
54
|
-
entity) and Microsoft Corporation for the Microsoft software accompanying
|
55
|
-
this EULA, which includes computer software and may include associated
|
56
|
-
media, printed materials, and "online" or electronic documentation
|
57
|
-
("SOFTWARE PRODUCT" or "SOFTWARE"). By exercising your rights to make and
|
58
|
-
use copies of the SOFTWARE PRODUCT, you agree to be bound by the terms of
|
59
|
-
this EULA. If you do not agree to the terms of this EULA, you may not use
|
60
|
-
the SOFTWARE PRODUCT.
|
61
|
-
|
62
|
-
------------------------
|
63
|
-
Software PRODUCT LICENSE
|
64
|
-
|
65
|
-
The SOFTWARE PRODUCT is protected by copyright laws and international
|
66
|
-
copyright treaties, as well as other intellectual property laws and
|
67
|
-
treaties. The SOFTWARE PRODUCT is licensed, not sold.
|
68
|
-
|
69
|
-
1. GRANT OF LICENSE. This EULA grants you the following rights:
|
70
|
-
- Installation and Use. You may install and use an unlimited number of
|
71
|
-
copies of the SOFTWARE PRODUCT.
|
72
|
-
- Reproduction and Distribution. You may reproduce and distribute an
|
73
|
-
unlimited number of copies of the SOFTWARE PRODUCT; provided that each
|
74
|
-
copy shall be a true and complete copy, including all copyright and
|
75
|
-
trademark notices, and shall be accompanied by a copy of this EULA. Copies
|
76
|
-
of the SOFTWARE PRODUCT may be distributed as a standalone product or
|
77
|
-
included with your own product.
|
78
|
-
|
79
|
-
2. DESCRIPTION OF OTHER RIGHTS AND LIMITATIONS.
|
80
|
-
- Limitations on Reverse Engineering, Decompilation, and Disassembly. You
|
81
|
-
ay not reverse engineer, decompile, or disassemble the SOFTWARE PRODUCT,
|
82
|
-
except and only to the extent that such activity is expressly permitted by
|
83
|
-
applicable law notwithstanding this limitation.
|
84
|
-
- Separation of Components. The SOFTWARE PRODUCT is licensed as a single
|
85
|
-
product. Its component parts may not be separated for use on more than one
|
86
|
-
computer.
|
87
|
-
- Software Transfer. You may permanently transfer all of your rights under
|
88
|
-
this EULA, provided the recipient agrees to the terms of this EULA.
|
89
|
-
- Termination. Without prejudice to any other rights, Microsoft may
|
90
|
-
terminate this EULA if you fail to comply with the terms and conditions of
|
91
|
-
this EULA. In such event, you must destroy all copies of the SOFTWARE
|
92
|
-
PRODUCT and all of its component parts.
|
93
|
-
|
94
|
-
3. COPYRIGHT. All title and copyrights in and to the SOFTWARE PRODUCT
|
95
|
-
(including but not limited to any images, photographs, animations, video,
|
96
|
-
audio, music, text, and "applets" incorporated into the SOFTWARE PRODUCT),
|
97
|
-
the accompanying printed materials, and any copies of the SOFTWARE PRODUCT
|
98
|
-
are owned by Microsoft or its suppliers. The SOFTWARE PRODUCT is protected
|
99
|
-
by copyright laws and international treaty provisions. Therefore, you must
|
100
|
-
treat the SOFTWARE PRODUCT like any other copyrighted material.
|
101
|
-
|
102
|
-
4. U.S. GOVERNMENT RESTRICTED RIGHTS. The SOFTWARE PRODUCT and
|
103
|
-
documentation are provided with RESTRICTED RIGHTS. Use, duplication, or
|
104
|
-
disclosure by the Government is subject to restrictions as set forth in
|
105
|
-
subparagraph (c)(1)(ii) of the Rights in Technical Data and Computer
|
106
|
-
Software clause at DFARS 252.227-7013 or subparagraphs (c)(1) and (2) of
|
107
|
-
the Commercial Computer Software-Restricted Rights at 48 CFR 52.227-19, as
|
108
|
-
applicable. Manufacturer is Microsoft Corporation/One Microsoft
|
109
|
-
Way/Redmond, WA 98052-6399.
|
110
|
-
|
111
|
-
----------------
|
112
|
-
LIMITED WARRANTY
|
113
|
-
|
114
|
-
NO WARRANTIES. Microsoft expressly disclaims any warranty for the SOFTWARE
|
115
|
-
PRODUCT. The SOFTWARE PRODUCT and any related documentation is provided "as
|
116
|
-
is" without warranty of any kind, either express or implied, including,
|
117
|
-
without limitation, the implied warranties or merchantability, fitness for
|
118
|
-
a particular purpose, or noninfringement. The entire risk arising out of
|
119
|
-
use or performance of the SOFTWARE PRODUCT remains with you.
|
120
|
-
|
121
|
-
NO LIABILITY FOR CONSEQUENTIAL DAMAGES. In no event shall Microsoft or its
|
122
|
-
suppliers be liable for any damages whatsoever (including, without
|
123
|
-
limitation, damages for loss of business profits, business interruption,
|
124
|
-
loss of business information, or any other pecuniary loss) arising out of
|
125
|
-
the use of or inability to use this Microsoft product, even if Microsoft
|
126
|
-
has been advised of the possibility of such damages. Because some
|
127
|
-
states/jurisdictions do not allow the exclusion or limitation of liability
|
128
|
-
for consequential or incidental damages, the above limitation may not apply
|
129
|
-
to you.
|
130
|
-
|
131
|
-
--------------
|
132
|
-
Miscellaneous:
|
133
|
-
|
134
|
-
If you acquired this product in the United States, this EULA is governed by
|
135
|
-
the laws of the State of Washington.
|
136
|
-
|
137
|
-
If this product was acquired outside the United States, then local laws may
|
138
|
-
apply.
|
139
|
-
|
140
|
-
Should you have any questions concerning this EULA, or if you desire to
|
141
|
-
contact Microsoft for any reason, please contact the Microsoft subsidiary
|
142
|
-
serving your country, or write: Microsoft Sales Information Center/One
|
143
|
-
Microsoft Way/Redmond, WA 98052-6399.
|
144
|
-
EOS
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end
|
@@ -1,78 +0,0 @@
|
|
1
|
-
module Fontist
|
2
|
-
module Formulas
|
3
|
-
class WebdingFont < FontFormula
|
4
|
-
desc "Microsoft TrueType Core fonts for the Web"
|
5
|
-
homepage "https://www.microsoft.com"
|
6
|
-
|
7
|
-
resource "webdin32.exe" do
|
8
|
-
urls [
|
9
|
-
"https://gitlab.com/fontmirror/archive/-/raw/master/webdin32.exe",
|
10
|
-
"https://nchc.dl.sourceforge.net/project/corefonts/the%20fonts/final/webdin32.exe",
|
11
|
-
"http://sft.if.usp.br/msttcorefonts/webdin32.exe"
|
12
|
-
]
|
13
|
-
sha256 "64595b5abc1080fba8610c5c34fab5863408e806aafe84653ca8575bed17d75a"
|
14
|
-
end
|
15
|
-
|
16
|
-
provides_font("Webdings", match_styles_from_file: {
|
17
|
-
"Regular" => "Webdings.TTF"
|
18
|
-
})
|
19
|
-
|
20
|
-
def extract
|
21
|
-
resource "webdin32.exe" do |resource|
|
22
|
-
cab_extract(resource) do |dir|
|
23
|
-
match_fonts(dir, "Webdings")
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def install
|
29
|
-
case platform
|
30
|
-
when :macos
|
31
|
-
install_matched_fonts "$HOME/Library/Fonts/Microsoft"
|
32
|
-
when :linux
|
33
|
-
install_matched_fonts "/usr/share/fonts/truetype/vista"
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
test do
|
38
|
-
case platform
|
39
|
-
when :macos
|
40
|
-
assert_predicate "$HOME/Library/Fonts/Microsoft/Webdings.ttf", :exist?
|
41
|
-
when :linux
|
42
|
-
assert_predicate "/usr/share/fonts/truetype/vista/Webdings.ttf", :exist?
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
requires_license_agreement <<~EOS
|
47
|
-
(from http://web.archive.org/web/20011222020409/http://www.microsoft.com/typography/fontpack/eula.htm)
|
48
|
-
TrueType core fonts for the Web EULA
|
49
|
-
END-USER LICENSE AGREEMENT FOR
|
50
|
-
MICROSOFT SOFTWARE
|
51
|
-
IMPORTANT-READ CAREFULLY: This Microsoft End-User License Agreement ("EULA") is a legal agreement between you (either an individual or a single entity) and Microsoft Corporation for the Microsoft software accompanying this EULA, which includes computer software and may include associated media, printed materials, and "on-line" or electronic documentation ("SOFTWARE PRODUCT" or "SOFTWARE"). By exercising your rights to make and use copies of the SOFTWARE PRODUCT, you agree to be bound by the terms of this EULA. If you do not agree to the terms of this EULA, you may not use the SOFTWARE PRODUCT.
|
52
|
-
SOFTWARE PRODUCT LICENSE
|
53
|
-
The SOFTWARE PRODUCT is protected by copyright laws and international copyright treaties, as well as other intellectual property laws and treaties. The SOFTWARE PRODUCT is licensed, not sold.
|
54
|
-
1. GRANT OF LICENSE. This EULA grants you the following rights:
|
55
|
-
* Installation and Use. You may install and use an unlimited number of copies of the SOFTWARE PRODUCT.
|
56
|
-
* Reproduction and Distribution. You may reproduce and distribute an unlimited number of copies of the SOFTWARE PRODUCT; provided that each copy shall be a true and complete copy, including all copyright and trademark notices, and shall be accompanied by a copy of this EULA. Copies of the SOFTWARE PRODUCT may not be distributed for profit either on a standalone basis or included as part of your own product.
|
57
|
-
2. DESCRIPTION OF OTHER RIGHTS AND LIMITATIONS.
|
58
|
-
* Limitations on Reverse Engineering, Decompilation, and Disassembly. You may not reverse engineer, decompile, or disassemble the SOFTWARE PRODUCT, except and only to the extent that such activity is expressly permitted by applicable law notwithstanding this limitation.
|
59
|
-
* Restrictions on Alteration. You may not rename, edit or create any derivative works from the SOFTWARE PRODUCT, other than subsetting when embedding them in documents.
|
60
|
-
* Software Transfer. You may permanently transfer all of your rights under this EULA, provided the recipient agrees to the terms of this EULA.
|
61
|
-
* Termination. Without prejudice to any other rights, Microsoft may terminate this EULA if you fail to comply with the terms and conditions of this EULA. In such event, you must destroy all copies of the SOFTWARE PRODUCT and all of its component parts.
|
62
|
-
3. COPYRIGHT. All title and copyrights in and to the SOFTWARE PRODUCT (including but not limited to any images, text, and "applets" incorporated into the SOFTWARE PRODUCT), the accompanying printed materials, and any copies of the SOFTWARE PRODUCT are owned by Microsoft or its suppliers. The SOFTWARE PRODUCT is protected by copyright laws and international treaty provisions. Therefore, you must treat the SOFTWARE PRODUCT like any other copyrighted material.
|
63
|
-
4. U.S. GOVERNMENT RESTRICTED RIGHTS. The SOFTWARE PRODUCT and documentation are provided with RESTRICTED RIGHTS. Use, duplication, or disclosure by the Government is subject to restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in Technical Data and Computer Software clause at DFARS 252.227-7013 or subparagraphs (c)(1) and (2) of the Commercial Computer Software - Restricted Rights at 48 CFR 52.227-19, as applicable. Manufacturer is Microsoft Corporation/One Microsoft Way/Redmond, WA 98052-6399.
|
64
|
-
LIMITED WARRANTY
|
65
|
-
NO WARRANTIES. Microsoft expressly disclaims any warranty for the SOFTWARE PRODUCT. The SOFTWARE PRODUCT and any related documentation is provided "as is" without warranty of any kind, either express or implied, including, without limitation, the implied warranties or merchantability, fitness for a particular purpose, or noninfringement. The entire risk arising out of use or performance of the SOFTWARE PRODUCT remains with you.
|
66
|
-
NO LIABILITY FOR CONSEQUENTIAL DAMAGES. In no event shall Microsoft or its suppliers be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or any other pecuniary loss) arising out of the use of or inability to use this Microsoft product, even if Microsoft has been advised of the possibility of such damages. Because some states/jurisdictions do not allow the exclusion or limitation of liability for consequential or incidental damages, the above limitation may not apply to you.
|
67
|
-
MISCELLANEOUS
|
68
|
-
If you acquired this product in the United States, this EULA is governed by the laws of the State of Washington.
|
69
|
-
If this product was acquired outside the United States, then local laws may apply.
|
70
|
-
Should you have any questions concerning this EULA, or if you desire to contact Microsoft for any reason, please contact the Microsoft subsidiary serving your country, or write: Microsoft Sales Information Center/One Microsoft Way/Redmond, WA 98052-6399.
|
71
|
-
this page was last updated 28 July 1998
|
72
|
-
© 1997 Microsoft Corporation. All rights reserved. Terms of use.
|
73
|
-
comments to the MST group: ttwsite@microsoft.com
|
74
|
-
EOS
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
RSpec.describe "Fontist::Formulas::DemoFormula" do
|
4
|
-
describe "initialization" do
|
5
|
-
it "registers formula resources through the DSL" do
|
6
|
-
formula = Fontist::Formulas::DemoFormula.instance
|
7
|
-
resource = formula.resources["demo-formula"]
|
8
|
-
demo_font = formula.font_list.first
|
9
|
-
|
10
|
-
expect(formula.key).to eq(:demo_formula)
|
11
|
-
expect(formula.license_required).to be_truthy
|
12
|
-
expect(formula.description).to eq("Demo font formula")
|
13
|
-
expect(formula.license).to eq("Vendor specific font licences")
|
14
|
-
expect(formula.homepage).to eq("https://github.com/fontist/fontist")
|
15
|
-
|
16
|
-
expect(resource[:file_size]).to eq("1234567890")
|
17
|
-
expect(resource[:urls].first).to eq("https://github.com/fontist/fontist")
|
18
|
-
expect(resource[:sha256]).to eq("594e0f42e6581add4dead70c1dfb9")
|
19
|
-
|
20
|
-
expect(demo_font[:styles].count).to eq(2)
|
21
|
-
expect(demo_font[:name]).to eq("Demo font")
|
22
|
-
expect(demo_font[:styles].first[:font]).to eq("demo-font.ttf")
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe "method invokation" do
|
27
|
-
it "invokes the correct method for installation" do
|
28
|
-
expect {
|
29
|
-
Fontist::Formulas::DemoFormula.fetch_font("Demo font", confirmation: "yes")
|
30
|
-
}.not_to raise_error
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
module Fontist
|
35
|
-
module Formulas
|
36
|
-
class DemoFormula < FontFormula
|
37
|
-
key :demo_formula
|
38
|
-
desc "Demo font formula"
|
39
|
-
homepage "https://github.com/fontist/fontist"
|
40
|
-
requires_license_agreement "Vendor specific font licences"
|
41
|
-
|
42
|
-
resource "demo-formula" do
|
43
|
-
urls [ "https://github.com/fontist/fontist" ]
|
44
|
-
sha256 "594e0f42e6581add4dead70c1dfb9"
|
45
|
-
file_size "1234567890"
|
46
|
-
end
|
47
|
-
|
48
|
-
provides_font "Demo font", match_styles_from_file: {
|
49
|
-
"Regular" => "demo-font.ttf",
|
50
|
-
"Italic" => "demo-fonti.ttf"
|
51
|
-
}
|
52
|
-
|
53
|
-
provides_font_collection("Meiryo Bold") do |coll|
|
54
|
-
filename "demo-font.ttc"
|
55
|
-
provides_font "Demo collection", extract_styles_from_collection: {
|
56
|
-
"Regular" => "demo-col-font.ttf",
|
57
|
-
"Italic" => "demo-col-fonti.ttf"
|
58
|
-
}
|
59
|
-
end
|
60
|
-
|
61
|
-
def extract
|
62
|
-
[]
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
data/spec/fontist/font_spec.rb
DELETED
@@ -1,113 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
RSpec.describe Fontist::Font do
|
4
|
-
describe ".all" do
|
5
|
-
it "list all supported fonts" do
|
6
|
-
fonts = Fontist::Font.all
|
7
|
-
|
8
|
-
expect(fonts.count).to be > 10
|
9
|
-
expect(fonts.first.name).not_to be_nil
|
10
|
-
expect(fonts.first.styles).not_to be_nil
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
describe ".find" do
|
15
|
-
context "with valid font name" do
|
16
|
-
it "returns the fonts path" do
|
17
|
-
name = "DejaVuSerif.ttf"
|
18
|
-
stub_system_font_finder_to_fixture(name)
|
19
|
-
dejavu_ttf = Fontist::Font.find(name)
|
20
|
-
|
21
|
-
expect(dejavu_ttf.first).to include(name)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
context "with downloadable font name" do
|
26
|
-
it "raises font missing error" do
|
27
|
-
name = "Courier"
|
28
|
-
|
29
|
-
allow(Fontist::SystemFont).to receive(:find).and_return(nil)
|
30
|
-
expect {
|
31
|
-
Fontist::Font.find(name)
|
32
|
-
}.to raise_error(Fontist::Errors::MissingFontError)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
context "with invalid font name" do
|
37
|
-
it "raises font unsupported error" do
|
38
|
-
font_name = "InvalidFont.ttf"
|
39
|
-
|
40
|
-
expect {
|
41
|
-
Fontist::Font.find(font_name)
|
42
|
-
}.to raise_error(Fontist::Errors::NonSupportedFontError)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe ".install" do
|
48
|
-
context "with valid font name" do
|
49
|
-
it "installs and returns paths for fonts with open license" do
|
50
|
-
stub_fontist_path_to_temp_path
|
51
|
-
|
52
|
-
font = { name: "Overpass Mono", filename: "overpass-mono-regular.otf" }
|
53
|
-
font_paths = Fontist::Font.install(font[:name], confirmation: "no")
|
54
|
-
|
55
|
-
expect(font_paths.join("|").downcase).to include(font[:filename])
|
56
|
-
end
|
57
|
-
|
58
|
-
it "install proprietary fonts with correct license agreement" do
|
59
|
-
stub_fontist_path_to_temp_path
|
60
|
-
stub_license_agreement_prompt_with("yes")
|
61
|
-
|
62
|
-
font = { name: "Calibri", filename: "calibri.ttf" }
|
63
|
-
font_paths = Fontist::Font.install(font[:name])
|
64
|
-
|
65
|
-
expect(font_paths.join("|").downcase).to include(font[:filename])
|
66
|
-
end
|
67
|
-
|
68
|
-
it "raises error for missing license agreement" do
|
69
|
-
stub_fontist_path_to_temp_path
|
70
|
-
stub_license_agreement_prompt_with("no")
|
71
|
-
|
72
|
-
font = { name: "Calibri", filename: "calibri.ttf" }
|
73
|
-
allow(Fontist::SystemFont).to receive(:find).and_return(nil)
|
74
|
-
|
75
|
-
expect { Fontist::Font.install(font[:name]) }.to raise_error(
|
76
|
-
Fontist::Errors::LicensingError
|
77
|
-
)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
context "with existing font name" do
|
82
|
-
it "returns the existing font paths" do
|
83
|
-
name = "Courier"
|
84
|
-
stub_fontist_path_to_temp_path
|
85
|
-
Fontist::Font.install(name, confirmation: "yes")
|
86
|
-
|
87
|
-
font_paths = Fontist::Font.install(name, confirmation: "yes")
|
88
|
-
|
89
|
-
expect(font_paths.count).to be > 3
|
90
|
-
expect(Fontist::Formulas::CourierFont).not_to receive(:fetch_font)
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
context "with unsupported fonts" do
|
95
|
-
it "raises an unsupported error" do
|
96
|
-
name = "Invalid font name"
|
97
|
-
|
98
|
-
expect {
|
99
|
-
Fontist::Font.install(name, confirmation: "yes")
|
100
|
-
}.to raise_error(Fontist::Errors::NonSupportedFontError)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
def stub_system_font_finder_to_fixture(name)
|
106
|
-
allow(Fontist::SystemFont).to receive(:find).
|
107
|
-
and_return(["spec/fixtures/fonts/#{name}"])
|
108
|
-
end
|
109
|
-
|
110
|
-
def stub_license_agreement_prompt_with(confirmation = "yes")
|
111
|
-
allow(Fontist.ui).to receive(:ask).and_return(confirmation)
|
112
|
-
end
|
113
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
RSpec.describe Fontist::Formula do
|
4
|
-
describe ".find" do
|
5
|
-
context "by font name" do
|
6
|
-
it "returns the font formulas" do
|
7
|
-
name = "Calibri"
|
8
|
-
|
9
|
-
clear_type = Fontist::Formula.find(name)
|
10
|
-
|
11
|
-
expect(clear_type.fonts.map(&:name)).to include(name)
|
12
|
-
expect(clear_type.installer).to eq("Fontist::Formulas::ClearTypeFonts")
|
13
|
-
expect(clear_type.description).to include("Microsoft ClearType Fonts")
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
context "by exact font" do
|
18
|
-
it "returns the font formulas" do
|
19
|
-
name = "CAMBRIAI.TTF"
|
20
|
-
|
21
|
-
clear_type = Fontist::Formula.find(name)
|
22
|
-
font_files = clear_type.fonts.map { |font| font.styles.map(&:font) }
|
23
|
-
|
24
|
-
expect(font_files.flatten).to include(name)
|
25
|
-
expect(clear_type.installer).to eq("Fontist::Formulas::ClearTypeFonts")
|
26
|
-
expect(clear_type.description).to include("Microsoft ClearType Fonts")
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
context "for invalid font" do
|
31
|
-
it "returns nil to the caller" do
|
32
|
-
name = "Calibri Made Up Name"
|
33
|
-
formulas = Fontist::Formula.find(name)
|
34
|
-
|
35
|
-
expect(formulas).to be_nil
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe ".find_fonts" do
|
41
|
-
it "returns the exact font font names" do
|
42
|
-
name = "Calibri"
|
43
|
-
font = Fontist::Formula.find_fonts(name).last
|
44
|
-
|
45
|
-
expect(font.styles.map(&:font)).to include("CALIBRI.TTF")
|
46
|
-
expect(font.styles.map(&:font)).to include("CALIBRIB.TTF")
|
47
|
-
expect(font.styles.map(&:font)).to include("CALIBRII.TTF")
|
48
|
-
end
|
49
|
-
|
50
|
-
it "returns nil if invalid name provided" do
|
51
|
-
name = "Calibri Invlaid"
|
52
|
-
fonts = Fontist::Formula.find_fonts(name)
|
53
|
-
|
54
|
-
expect(fonts).to be_nil
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
describe ".all" do
|
59
|
-
it "returns all registered formulas" do
|
60
|
-
formulas = Fontist::Formula.all
|
61
|
-
|
62
|
-
expect(formulas.cleartype.fonts.count).to be > 10
|
63
|
-
expect(formulas.cleartype.homepage).to eq("https://www.microsoft.com")
|
64
|
-
expect(formulas.cleartype.description).to eq("Microsoft ClearType Fonts")
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|