fontist 0.4.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/macosx.yml +1 -1
  3. data/.github/workflows/ubuntu.yml +1 -1
  4. data/.gitignore +4 -2
  5. data/README.md +87 -25
  6. data/lib/fontist.rb +28 -13
  7. data/lib/fontist/downloader.rb +11 -11
  8. data/lib/fontist/errors.rb +1 -0
  9. data/lib/fontist/font.rb +78 -0
  10. data/lib/fontist/font_formula.rb +116 -0
  11. data/lib/fontist/formula.rb +90 -0
  12. data/lib/fontist/formulas.rb +10 -5
  13. data/lib/fontist/formulas/andale_font.rb +79 -0
  14. data/lib/fontist/formulas/arial_black_font.rb +78 -0
  15. data/lib/fontist/formulas/cleartype_fonts.rb +225 -0
  16. data/lib/fontist/formulas/comic_font.rb +77 -0
  17. data/lib/fontist/formulas/courier_font.rb +67 -12
  18. data/lib/fontist/formulas/euphemia_font.rb +85 -0
  19. data/lib/fontist/formulas/georgia_font.rb +79 -0
  20. data/lib/fontist/formulas/impact_font.rb +77 -0
  21. data/lib/fontist/formulas/montserrat_font.rb +132 -0
  22. data/lib/fontist/formulas/ms_truetype_fonts.rb +124 -0
  23. data/lib/fontist/formulas/open_sans_fonts.rb +263 -0
  24. data/lib/fontist/formulas/overpass_font.rb +73 -0
  25. data/lib/fontist/formulas/source_fonts.rb +109 -0
  26. data/lib/fontist/formulas/stix_fonts.rb +108 -0
  27. data/lib/fontist/formulas/tahoma_font.rb +147 -0
  28. data/lib/fontist/formulas/webding_font.rb +77 -0
  29. data/lib/fontist/registry.rb +42 -0
  30. data/lib/fontist/{data/source.yml → system.yml} +0 -7
  31. data/lib/fontist/system_font.rb +9 -13
  32. data/lib/fontist/utils.rb +8 -0
  33. data/lib/fontist/utils/dsl.rb +73 -0
  34. data/lib/fontist/utils/exe_extractor.rb +72 -0
  35. data/lib/fontist/utils/zip_extractor.rb +38 -0
  36. data/lib/fontist/version.rb +1 -1
  37. data/spec/fontist/downloader_spec.rb +2 -1
  38. data/spec/fontist/font_formula_spec.rb +67 -0
  39. data/spec/fontist/font_spec.rb +87 -0
  40. data/spec/fontist/formula_spec.rb +67 -0
  41. data/spec/fontist/formulas/andale_font_spec.rb +29 -0
  42. data/spec/fontist/formulas/arial_black_font_spec.rb +29 -0
  43. data/spec/fontist/formulas/cleartype_fonts_spec.rb +38 -0
  44. data/spec/fontist/formulas/comic_font_spec.rb +29 -0
  45. data/spec/fontist/formulas/courier_font_spec.rb +18 -19
  46. data/spec/fontist/formulas/euphemia_font_spec.rb +29 -0
  47. data/spec/fontist/formulas/georgia_font_spec.rb +29 -0
  48. data/spec/fontist/formulas/impact_font_spec.rb +29 -0
  49. data/spec/fontist/formulas/montserrat_font_spec.rb +29 -0
  50. data/spec/fontist/formulas/ms_truetype_fonts_spec.rb +29 -0
  51. data/spec/fontist/formulas/open_sans_fonts_spec.rb +29 -0
  52. data/spec/fontist/formulas/overpass_font_spec.rb +29 -0
  53. data/spec/fontist/formulas/source_fonts_spec.rb +31 -0
  54. data/spec/fontist/formulas/stix_fonts_spec.rb +29 -0
  55. data/spec/fontist/formulas/tahoma_font_spec.rb +29 -0
  56. data/spec/fontist/formulas/webding_font_spec.rb +29 -0
  57. data/spec/fontist/registry_spec.rb +47 -0
  58. data/spec/fontist/system_font_spec.rb +6 -6
  59. data/spec/spec_helper.rb +4 -2
  60. data/spec/support/fontist_helper.rb +4 -2
  61. metadata +45 -25
  62. data/lib/fontist/data/formulas/courier.yml +0 -26
  63. data/lib/fontist/data/formulas/ms_system.yml +0 -68
  64. data/lib/fontist/data/formulas/ms_vista.yml +0 -118
  65. data/lib/fontist/data/formulas/source_font.yml +0 -163
  66. data/lib/fontist/finder.rb +0 -45
  67. data/lib/fontist/formula_finder.rb +0 -94
  68. data/lib/fontist/formulas/base.rb +0 -72
  69. data/lib/fontist/formulas/helpers/exe_extractor.rb +0 -45
  70. data/lib/fontist/formulas/helpers/zip_extractor.rb +0 -36
  71. data/lib/fontist/formulas/ms_system.rb +0 -29
  72. data/lib/fontist/formulas/ms_vista.rb +0 -42
  73. data/lib/fontist/formulas/source_font.rb +0 -25
  74. data/lib/fontist/installer.rb +0 -42
  75. data/lib/fontist/source.rb +0 -58
  76. data/spec/fontist/finder_spec.rb +0 -41
  77. data/spec/fontist/formula_finder_spec.rb +0 -54
  78. data/spec/fontist/formulas/ms_system_spec.rb +0 -31
  79. data/spec/fontist/formulas/ms_vista_spec.rb +0 -27
  80. data/spec/fontist/formulas/source_font_spec.rb +0 -18
  81. data/spec/fontist/installer_spec.rb +0 -48
  82. data/spec/fontist/source_spec.rb +0 -24
@@ -0,0 +1,29 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Fontist::Formulas::TahomaFont do
4
+ describe "initializing" do
5
+ it "builds the data dictionary" do
6
+ formula = Fontist::Formulas::TahomaFont.instance
7
+
8
+ expect(formula.fonts.count).to eq(1)
9
+ expect(formula.fonts.first[:name]).to eq("Tahoma")
10
+ end
11
+ end
12
+
13
+ describe "installation" do
14
+ context "with valid licence agreement", slow: true do
15
+ it "installs the valid fonts", skip_in_windows: true do
16
+ name = "Tahoma"
17
+ confirmation = "yes"
18
+
19
+ stub_fontist_path_to_temp_path
20
+ paths = Fontist::Formulas::TahomaFont.fetch_font(
21
+ name, confirmation: confirmation
22
+ )
23
+
24
+ expect(Fontist::Font.find(name)).not_to be_empty
25
+ expect(paths.first).to include("fonts/#{name.downcase}.ttf")
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Fontist::Formulas::WebdingFont do
4
+ describe "initializing" do
5
+ it "builds the data dictionary" do
6
+ formula = Fontist::Formulas::WebdingFont.instance
7
+
8
+ expect(formula.fonts.count).to eq(1)
9
+ expect(formula.fonts.first[:name]).to eq("Webdings")
10
+ end
11
+ end
12
+
13
+ describe "installation" do
14
+ context "with valid licence agreement", slow: true do
15
+ it "installs the valid fonts", skip_in_windows: true do
16
+ name = "Webdings"
17
+ confirmation = "yes"
18
+
19
+ stub_fontist_path_to_temp_path
20
+ paths = Fontist::Formulas::WebdingFont.fetch_font(
21
+ name, confirmation: confirmation
22
+ )
23
+
24
+ expect(Fontist::Font.find(name)).not_to be_empty
25
+ expect(paths.first).to include("fonts/#{name}.TTF")
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,47 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Fontist::Registry do
4
+ describe ".register" do
5
+ context "with no key provided" do
6
+ it "registers a fontist formula with default key" do
7
+ Fontist::Registry.register(Fontist::Formulas::DemoFormula)
8
+ demo_formula = Fontist::Registry.formulas.demo_formula
9
+
10
+ expect(demo_formula.license).to eq("Vendor specific font licences")
11
+ expect(demo_formula.fonts.first.styles.first.type).to eq("Regular")
12
+ expect(demo_formula.installer).to eq("Fontist::Formulas::DemoFormula")
13
+ expect(demo_formula.homepage).to eq("https://github.com/fontist/fontist")
14
+ end
15
+ end
16
+
17
+ context "with custom key provided" do
18
+ it "registers the formula with this custom key" do
19
+ Fontist::Registry.register(Fontist::Formulas::DemoFormula, :custom_key)
20
+
21
+ expect(Fontist::Registry.formulas.custom_key).not_to be_nil
22
+ end
23
+ end
24
+ end
25
+
26
+ module Fontist
27
+ module Formulas
28
+ class DemoFormula < FontFormula
29
+ key :demo_formula
30
+ desc "Demo font formula"
31
+ homepage "https://github.com/fontist/fontist"
32
+ requires_license_agreement "Vendor specific font licences"
33
+
34
+ resource "demo-formula" do
35
+ urls [ "https://github.com/fontist/fontist" ]
36
+ sha256 "594e0f42e6581add4dead70c1dfb9"
37
+ file_size "1234567890"
38
+ end
39
+
40
+ provides_font "Demo font", match_styles_from_file: {
41
+ "Regular" => "demo-font.ttf",
42
+ "Italic" => "demo-fonti.ttf"
43
+ }
44
+ end
45
+ end
46
+ end
47
+ end
@@ -13,13 +13,13 @@ RSpec.describe Fontist::SystemFont do
13
13
  end
14
14
 
15
15
  context "with valid font name" do
16
- it "returns the complete font path", file_download: true do
17
- name = "Courier"
18
- stub_fontist_path_to_assets
19
- Fontist::Formulas::CourierFont.fetch_font(name, confirmation: "yes")
16
+ it "returns the complete font path", slow: true do
17
+ name = "Calibri"
18
+ stub_fontist_path_to_temp_path
19
+ Fontist::Formulas::ClearTypeFonts.fetch_font(name, confirmation: "yes")
20
20
 
21
- courier = Fontist::SystemFont.find(name, sources: [font_sources])
22
- expect(courier.first).to include("cour.ttf")
21
+ calbiri = Fontist::SystemFont.find(name, sources: [font_sources])
22
+ expect(calbiri.join("|").downcase).to include("#{name.downcase}.ttf")
23
23
  end
24
24
  end
25
25
 
@@ -11,8 +11,10 @@ RSpec.configure do |config|
11
11
  # Disable RSpec exposing methods globally on `Module` and `main`
12
12
  config.disable_monkey_patching!
13
13
 
14
- # Skip the actual file_download by default
15
- config.filter_run_excluding file_download: true
14
+ # Skip the slow tests locally
15
+ unless ENV.fetch("TEST_ENV", "local").upcase === "CI"
16
+ config.filter_run_excluding slow: true
17
+ end
16
18
 
17
19
  config.expect_with :rspec do |c|
18
20
  c.syntax = :expect
@@ -1,7 +1,9 @@
1
1
  module Fontist
2
2
  module Helper
3
- def stub_fontist_path_to_assets
4
- allow(Fontist).to receive(:fontist_path).and_return(Fontist.assets_path)
3
+ def stub_fontist_path_to_temp_path
4
+ allow(Fontist).to receive(:fontist_path).and_return(
5
+ Fontist.root_path.join("spec", "fixtures")
6
+ )
5
7
  end
6
8
  end
7
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fontist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-05-24 00:00:00.000000000 Z
12
+ date: 2020-06-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: down
@@ -126,43 +126,63 @@ files:
126
126
  - LICENSE.txt
127
127
  - README.md
128
128
  - Rakefile
129
- - assets/fonts/.keep
130
129
  - bin/console
131
130
  - bin/rspec
132
131
  - bin/setup
133
132
  - fontist.gemspec
134
133
  - lib/fontist.rb
135
- - lib/fontist/data/formulas/courier.yml
136
- - lib/fontist/data/formulas/ms_system.yml
137
- - lib/fontist/data/formulas/ms_vista.yml
138
- - lib/fontist/data/formulas/source_font.yml
139
- - lib/fontist/data/source.yml
140
134
  - lib/fontist/downloader.rb
141
135
  - lib/fontist/errors.rb
142
- - lib/fontist/finder.rb
143
- - lib/fontist/formula_finder.rb
136
+ - lib/fontist/font.rb
137
+ - lib/fontist/font_formula.rb
138
+ - lib/fontist/formula.rb
144
139
  - lib/fontist/formulas.rb
145
- - lib/fontist/formulas/base.rb
140
+ - lib/fontist/formulas/andale_font.rb
141
+ - lib/fontist/formulas/arial_black_font.rb
142
+ - lib/fontist/formulas/cleartype_fonts.rb
143
+ - lib/fontist/formulas/comic_font.rb
146
144
  - lib/fontist/formulas/courier_font.rb
147
- - lib/fontist/formulas/helpers/exe_extractor.rb
148
- - lib/fontist/formulas/helpers/zip_extractor.rb
149
- - lib/fontist/formulas/ms_system.rb
150
- - lib/fontist/formulas/ms_vista.rb
151
- - lib/fontist/formulas/source_font.rb
152
- - lib/fontist/installer.rb
153
- - lib/fontist/source.rb
145
+ - lib/fontist/formulas/euphemia_font.rb
146
+ - lib/fontist/formulas/georgia_font.rb
147
+ - lib/fontist/formulas/impact_font.rb
148
+ - lib/fontist/formulas/montserrat_font.rb
149
+ - lib/fontist/formulas/ms_truetype_fonts.rb
150
+ - lib/fontist/formulas/open_sans_fonts.rb
151
+ - lib/fontist/formulas/overpass_font.rb
152
+ - lib/fontist/formulas/source_fonts.rb
153
+ - lib/fontist/formulas/stix_fonts.rb
154
+ - lib/fontist/formulas/tahoma_font.rb
155
+ - lib/fontist/formulas/webding_font.rb
156
+ - lib/fontist/registry.rb
157
+ - lib/fontist/system.yml
154
158
  - lib/fontist/system_font.rb
159
+ - lib/fontist/utils.rb
160
+ - lib/fontist/utils/dsl.rb
161
+ - lib/fontist/utils/exe_extractor.rb
162
+ - lib/fontist/utils/zip_extractor.rb
155
163
  - lib/fontist/version.rb
156
164
  - spec/fixtures/fonts/DejaVuSerif.ttf
157
165
  - spec/fontist/downloader_spec.rb
158
- - spec/fontist/finder_spec.rb
159
- - spec/fontist/formula_finder_spec.rb
166
+ - spec/fontist/font_formula_spec.rb
167
+ - spec/fontist/font_spec.rb
168
+ - spec/fontist/formula_spec.rb
169
+ - spec/fontist/formulas/andale_font_spec.rb
170
+ - spec/fontist/formulas/arial_black_font_spec.rb
171
+ - spec/fontist/formulas/cleartype_fonts_spec.rb
172
+ - spec/fontist/formulas/comic_font_spec.rb
160
173
  - spec/fontist/formulas/courier_font_spec.rb
161
- - spec/fontist/formulas/ms_system_spec.rb
162
- - spec/fontist/formulas/ms_vista_spec.rb
163
- - spec/fontist/formulas/source_font_spec.rb
164
- - spec/fontist/installer_spec.rb
165
- - spec/fontist/source_spec.rb
174
+ - spec/fontist/formulas/euphemia_font_spec.rb
175
+ - spec/fontist/formulas/georgia_font_spec.rb
176
+ - spec/fontist/formulas/impact_font_spec.rb
177
+ - spec/fontist/formulas/montserrat_font_spec.rb
178
+ - spec/fontist/formulas/ms_truetype_fonts_spec.rb
179
+ - spec/fontist/formulas/open_sans_fonts_spec.rb
180
+ - spec/fontist/formulas/overpass_font_spec.rb
181
+ - spec/fontist/formulas/source_fonts_spec.rb
182
+ - spec/fontist/formulas/stix_fonts_spec.rb
183
+ - spec/fontist/formulas/tahoma_font_spec.rb
184
+ - spec/fontist/formulas/webding_font_spec.rb
185
+ - spec/fontist/registry_spec.rb
166
186
  - spec/fontist/system_font_spec.rb
167
187
  - spec/fontist_spec.rb
168
188
  - spec/spec_helper.rb
@@ -1,26 +0,0 @@
1
- courier:
2
- agreement: "yes"
3
-
4
- fonts:
5
- - name: Courier
6
- styles:
7
- - type: Regular
8
- font: cour.ttf
9
-
10
- - type: Bold
11
- font: courbd.ttf
12
-
13
- - type: Italic
14
- font: couri.ttf
15
-
16
- - type: Bold Italic
17
- font: courbi.ttf
18
-
19
- file_size: "1675184"
20
- sha: "bb511d861655dde879ae552eb86b134d6fae67cb58502e6ff73ec5d9151f3384"
21
- urls:
22
- - https://nchc.dl.sourceforge.net/project/corefonts/the%20fonts/final/courie32.exe
23
- - http://sft.if.usp.br/msttcorefonts/courie32.exe
24
-
25
- licence: |
26
- Details of the license goes here.
@@ -1,68 +0,0 @@
1
- ms_system:
2
- agreement: "yes"
3
-
4
- fonts:
5
- - name: Arial
6
- styles:
7
- - type: Regular
8
- font: Arial.ttf
9
-
10
- - type: Bold
11
- font: ArialBd.ttf
12
-
13
- - type: Italic
14
- font: ArialBd.ttf
15
-
16
- - type: Bold Italic
17
- font: ArialBI.ttf
18
-
19
- - name: Times New Roman
20
- styles:
21
- - type: Regular
22
- font: Times.ttf
23
-
24
- - type: Bold
25
- font: TimesBd.ttf
26
-
27
- - type: Italic
28
- font: TimesI.ttf
29
-
30
- - type: Bold Italic
31
- font: TimesBI.ttf
32
-
33
- - name: Verdana
34
- styles:
35
- - type: Regular
36
- font: Verdana.ttf
37
-
38
- - type: Bold
39
- font: Verdanab.ttf
40
-
41
- - type: Italic
42
- font: Verdanai.ttf
43
-
44
- - type: Bold Italic
45
- font: Verdanaz.ttf
46
-
47
- - name: Trebuchet
48
- styles:
49
- - type: Regular
50
- font: trebuc.ttf
51
-
52
- - type: Bold
53
- font: trebucbd.ttf
54
-
55
- - type: Italic
56
- font: trebucit.ttf
57
-
58
- - type: Bold Italic
59
- font: trebucbi.ttf
60
-
61
- file_size: "1675184"
62
- sha: "464dd2cd5f09f489f9ac86ea7790b7b8548fc4e46d9f889b68d2cdce47e09ea8"
63
- urls:
64
- - https://download.microsoft.com/download/a/1/8/a180e21e-9c2b-4b54-9c32-bf7fd7429970/EUupdate.EXE
65
- - https://nchc.dl.sourceforge.net/project/corefonts/the%20fonts/final/EUupdate.EXE
66
-
67
- licence: |
68
- Details license goes here
@@ -1,118 +0,0 @@
1
- msvista:
2
- agreement: "yes"
3
-
4
- fonts:
5
- - name: Cambria
6
- styles:
7
- - type: Regular
8
- font: CAMBRIA.TTC
9
-
10
- - type: Bold
11
- font: CAMBRIAB.TTF
12
-
13
- - type: Italic
14
- font: CAMBRIAI.TTF
15
-
16
- - type: Bold Italic
17
- font: CAMBRIAZ.TTF
18
-
19
- - name: Calibri
20
- styles:
21
- - type: Regular
22
- font: CALIBRI.TTF
23
-
24
- - type: Bold
25
- font: CALIBRIB.TTF
26
-
27
- - type: Italic
28
- font: CALIBRII.TTF
29
-
30
- - type: Bold Italic
31
- font: CALIBRIZ.TTF
32
-
33
- - name: Candara
34
- styles:
35
- - type: Regular
36
- font: CANDARA.TTF
37
-
38
- - type: Bold
39
- font: CANDARAB.TTF
40
-
41
- - type: Italic
42
- font: CANDARAI.TTF
43
-
44
- - type: Bold Italic
45
- font: CANDARAZ.TTF
46
-
47
- - name: Consola
48
- styles:
49
- - type: Regular
50
- font: CONSOLA.TTF
51
-
52
- - type: Bold
53
- font: CONSOLAB.TTF
54
-
55
- - type: Italic
56
- font: CONSOLAI.TTF
57
-
58
- - type: Bold Italic
59
- font: CONSOLAZ.TTF
60
-
61
- - name: Constantia
62
- styles:
63
- - type: Regular
64
- font: CONSTAN.TTF
65
-
66
- - type: Bold
67
- font: CONSTANB.TTF
68
-
69
- - type: Italic
70
- font: CONSTANI.TTF
71
-
72
- - type: Bold Italic
73
- font: CONSTANZ.TTF
74
-
75
- - name: Corbel
76
- styles:
77
- - type: Regular
78
- font: CORBEL.TTF
79
-
80
- - type: Bold
81
- font: CORBELB.TTF
82
-
83
- - type: Italic
84
- font: CORBELI.TTF
85
-
86
- - type: Bold Italic
87
- font: CORBELZ.TTF
88
-
89
- # Note: further work necessary
90
- #
91
- # The initial version is returing the ttc fonts as
92
- # it is, but maybe in the upcoming releases we will need
93
- # to extract/parse the ttc fonts if necessary.
94
- #
95
- - name: Meiryo
96
- styles:
97
- - type: Regular
98
- font: MEIRYO.TTC
99
-
100
- - type: Bold
101
- font: MEIRYO.TTC
102
-
103
- - name: Meiryo UI
104
- styles:
105
- - type: Regular
106
- font: MEIRYO.TTC
107
-
108
- - type: Bold
109
- font: MEIRYO.TTC
110
-
111
- file_size: "62914560"
112
- sha: "249473568eba7a1e4f95498acba594e0f42e6581add4dead70c1dfb908a09423"
113
- urls:
114
- - "https://www.dropbox.com/s/dl/6lclhxpydwgkjzh/PowerPointViewer.exe?dl=1"
115
- - "https://web.archive.org/web/20171225132744/http://download.microsoft.com/download/E/6/7/E675FFFC-2A6D-4AB0-B3EB-27C9F8C8F696/PowerPointViewer.exe"
116
-
117
- license: |
118
- Complete MS licence;