fontist 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/check_google.yml +28 -0
  3. data/.github/workflows/macosx.yml +3 -0
  4. data/.github/workflows/ubuntu.yml +1 -1
  5. data/.github/workflows/windows.yml +1 -1
  6. data/.gitignore +6 -0
  7. data/.hound.yml +2 -0
  8. data/.rubocop.yml +22 -0
  9. data/README.md +54 -0
  10. data/bin/check_google +8 -0
  11. data/bin/convert_formulas +8 -0
  12. data/bin/fontist +8 -0
  13. data/bin/generate_otfinfo +8 -0
  14. data/bin/import_google +8 -0
  15. data/bin/stripttc +0 -0
  16. data/fontist.gemspec +14 -1
  17. data/lib/fontist.rb +18 -13
  18. data/lib/fontist/cli.rb +118 -0
  19. data/lib/fontist/errors.rb +3 -0
  20. data/lib/fontist/font.rb +117 -2
  21. data/lib/fontist/font_formula.rb +7 -3
  22. data/lib/fontist/fontist_font.rb +70 -0
  23. data/lib/fontist/formula.rb +11 -8
  24. data/lib/fontist/formula_template.rb +103 -0
  25. data/lib/fontist/formulas.rb +41 -0
  26. data/lib/fontist/import.rb +9 -0
  27. data/lib/fontist/import/convert_formulas.rb +65 -0
  28. data/lib/fontist/import/create_formula.rb +74 -0
  29. data/lib/fontist/import/extractors.rb +5 -0
  30. data/lib/fontist/import/extractors/cab_extractor.rb +37 -0
  31. data/lib/fontist/import/extractors/extractor.rb +19 -0
  32. data/lib/fontist/import/extractors/ole_extractor.rb +41 -0
  33. data/lib/fontist/import/extractors/seven_zip_extractor.rb +44 -0
  34. data/lib/fontist/import/extractors/zip_extractor.rb +31 -0
  35. data/lib/fontist/import/files/collection_file.rb +48 -0
  36. data/lib/fontist/import/formula_builder.rb +115 -0
  37. data/lib/fontist/import/formula_serializer.rb +133 -0
  38. data/lib/fontist/import/google.rb +16 -0
  39. data/lib/fontist/import/google/fonts_public.md +10 -0
  40. data/lib/fontist/import/google/fonts_public.pb.rb +71 -0
  41. data/lib/fontist/import/google/fonts_public.proto +46 -0
  42. data/lib/fontist/import/google/new_fonts_fetcher.rb +121 -0
  43. data/lib/fontist/import/google/skiplist.yml +6 -0
  44. data/lib/fontist/import/google_check.rb +34 -0
  45. data/lib/fontist/import/google_import.rb +180 -0
  46. data/lib/fontist/import/helpers/hash_helper.rb +13 -0
  47. data/lib/fontist/import/helpers/system_helper.rb +20 -0
  48. data/lib/fontist/import/otf/font_file.rb +89 -0
  49. data/lib/fontist/import/otf_parser.rb +25 -0
  50. data/lib/fontist/import/otf_style.rb +29 -0
  51. data/lib/fontist/import/otfinfo/otfinfo_requirement.rb +22 -0
  52. data/lib/fontist/import/otfinfo/template.erb +20 -0
  53. data/lib/fontist/import/otfinfo_generate.rb +45 -0
  54. data/lib/fontist/import/recursive_extraction.rb +101 -0
  55. data/lib/fontist/import/template_helper.rb +19 -0
  56. data/lib/fontist/import/text_helper.rb +30 -0
  57. data/lib/fontist/system_font.rb +12 -18
  58. data/lib/fontist/utils.rb +4 -0
  59. data/lib/fontist/utils/cache.rb +69 -0
  60. data/lib/fontist/utils/downloader.rb +15 -2
  61. data/lib/fontist/utils/dsl.rb +4 -0
  62. data/lib/fontist/utils/dsl/font.rb +37 -0
  63. data/lib/fontist/utils/exe_extractor.rb +12 -19
  64. data/lib/fontist/utils/msi_extractor.rb +31 -0
  65. data/lib/fontist/utils/seven_zip_extractor.rb +41 -0
  66. data/lib/fontist/utils/system.rb +23 -0
  67. data/lib/fontist/utils/ui.rb +8 -0
  68. data/lib/fontist/utils/zip_extractor.rb +9 -4
  69. data/lib/fontist/version.rb +1 -1
  70. metadata +154 -49
  71. data/lib/fontist/formulas/andale_font.rb +0 -80
  72. data/lib/fontist/formulas/arial_black_font.rb +0 -79
  73. data/lib/fontist/formulas/cleartype_fonts.rb +0 -227
  74. data/lib/fontist/formulas/comic_font.rb +0 -78
  75. data/lib/fontist/formulas/courier_font.rb +0 -81
  76. data/lib/fontist/formulas/euphemia_font.rb +0 -85
  77. data/lib/fontist/formulas/georgia_font.rb +0 -80
  78. data/lib/fontist/formulas/impact_font.rb +0 -78
  79. data/lib/fontist/formulas/montserrat_font.rb +0 -132
  80. data/lib/fontist/formulas/ms_truetype_fonts.rb +0 -125
  81. data/lib/fontist/formulas/open_sans_fonts.rb +0 -263
  82. data/lib/fontist/formulas/overpass_font.rb +0 -73
  83. data/lib/fontist/formulas/source_fonts.rb +0 -109
  84. data/lib/fontist/formulas/stix_fonts.rb +0 -108
  85. data/lib/fontist/formulas/tahoma_font.rb +0 -147
  86. data/lib/fontist/formulas/webding_font.rb +0 -78
  87. data/spec/fontist/font_formula_spec.rb +0 -67
  88. data/spec/fontist/font_spec.rb +0 -113
  89. data/spec/fontist/formula_spec.rb +0 -67
  90. data/spec/fontist/formulas/andale_font_spec.rb +0 -29
  91. data/spec/fontist/formulas/arial_black_font_spec.rb +0 -29
  92. data/spec/fontist/formulas/cleartype_fonts_spec.rb +0 -38
  93. data/spec/fontist/formulas/comic_font_spec.rb +0 -29
  94. data/spec/fontist/formulas/courier_font_spec.rb +0 -29
  95. data/spec/fontist/formulas/euphemia_font_spec.rb +0 -29
  96. data/spec/fontist/formulas/georgia_font_spec.rb +0 -29
  97. data/spec/fontist/formulas/impact_font_spec.rb +0 -29
  98. data/spec/fontist/formulas/montserrat_font_spec.rb +0 -29
  99. data/spec/fontist/formulas/ms_truetype_fonts_spec.rb +0 -29
  100. data/spec/fontist/formulas/open_sans_fonts_spec.rb +0 -29
  101. data/spec/fontist/formulas/overpass_font_spec.rb +0 -29
  102. data/spec/fontist/formulas/source_fonts_spec.rb +0 -31
  103. data/spec/fontist/formulas/stix_fonts_spec.rb +0 -29
  104. data/spec/fontist/formulas/tahoma_font_spec.rb +0 -29
  105. data/spec/fontist/formulas/webding_font_spec.rb +0 -29
  106. data/spec/fontist/registry_spec.rb +0 -47
  107. data/spec/fontist/system_font_spec.rb +0 -44
  108. data/spec/fontist/utils/downloader_spec.rb +0 -35
  109. data/spec/fontist_spec.rb +0 -5
  110. data/spec/spec_helper.rb +0 -22
  111. data/spec/support/fontist_helper.rb +0 -10
@@ -1,29 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe Fontist::Formulas::MsTruetypeFonts do
4
- describe "initializing" do
5
- it "builds the data dictionary" do
6
- formula = Fontist::Formulas::MsTruetypeFonts.instance
7
-
8
- expect(formula.fonts.count).to eq(4)
9
- expect(formula.fonts.first[:name]).to eq("Arial")
10
- end
11
- end
12
-
13
- describe "installation" do
14
- context "with valid licence agreement" do
15
- it "installs the valid fonts", skip_in_windows: true do
16
- name = "Arial"
17
- confirmation = "yes"
18
-
19
- stub_fontist_path_to_temp_path
20
- paths = Fontist::Formulas::MsTruetypeFonts.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
@@ -1,29 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe Fontist::Formulas::OpenSansFonts do
4
- describe "initializing" do
5
- it "builds the data dictionary" do
6
- formula = Fontist::Formulas::OpenSansFonts.instance
7
-
8
- expect(formula.fonts.count).to eq(1)
9
- expect(formula.fonts.first[:name]).to eq("OpenSans")
10
- end
11
- end
12
-
13
- describe "installation" do
14
- context "with valid licence agreement", slow: true do
15
- it "installs the valid fonts" do
16
- name = "OpenSans"
17
- confirmation = "yes"
18
-
19
- stub_fontist_path_to_temp_path
20
- paths = Fontist::Formulas::OpenSansFonts.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}-Light.ttf")
26
- end
27
- end
28
- end
29
- end
@@ -1,29 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe Fontist::Formulas::OverpassFont do
4
- describe "initializing" do
5
- it "builds the data dictionary" do
6
- formula = Fontist::Formulas::OverpassFont.instance
7
-
8
- expect(formula.fonts.count).to eq(2)
9
- expect(formula.fonts.first[:name]).to eq("Overpass")
10
- end
11
- end
12
-
13
- describe "installation" do
14
- context "with valid licence agreement" do
15
- it "installs the valid fonts" do
16
- name = "Overpass"
17
- confirmation = "yes"
18
-
19
- stub_fontist_path_to_temp_path
20
- paths = Fontist::Formulas::OverpassFont.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}-bold-italic.otf")
26
- end
27
- end
28
- end
29
- end
@@ -1,31 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe Fontist::Formulas::SourceFonts do
4
- describe "initializing" do
5
- it "builds the data dictionary" do
6
- formula = Fontist::Formulas::SourceFonts.instance
7
-
8
- expect(formula.fonts.count).to eq(33)
9
- expect(formula.fonts.first[:name]).to eq("Source Code Pro")
10
- end
11
- end
12
-
13
- describe "installation" do
14
- context "with valid licence agreement", slow: true do
15
- it "installs the valid fonts" do
16
- name = "Source Code Pro"
17
- confirmation = "yes"
18
-
19
- stub_fontist_path_to_temp_path
20
- paths = Fontist::Formulas::SourceFonts.fetch_font(
21
- name, confirmation: confirmation
22
- )
23
-
24
- expect(Fontist::Font.find(name)).not_to be_empty
25
- expect(paths).to include(
26
- Fontist.fonts_path.join("SourceCodePro-Black.ttf").to_s
27
- )
28
- end
29
- end
30
- end
31
- end
@@ -1,29 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe Fontist::Formulas::StixFont do
4
- describe "initializing" do
5
- it "builds the data dictionary" do
6
- formula = Fontist::Formulas::StixFont.instance
7
-
8
- expect(formula.fonts.count).to eq(2)
9
- expect(formula.fonts.first[:name]).to eq("STIX Two Math")
10
- end
11
- end
12
-
13
- describe "installation" do
14
- context "with valid licence agreement" do
15
- it "installs the valid fonts" do
16
- name = "STIX Two Math"
17
- confirmation = "yes"
18
-
19
- stub_fontist_path_to_temp_path
20
- paths = Fontist::Formulas::StixFont.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/STIX2Math.otf")
26
- end
27
- end
28
- end
29
- end
@@ -1,29 +0,0 @@
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
@@ -1,29 +0,0 @@
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
@@ -1,47 +0,0 @@
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
@@ -1,44 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe Fontist::SystemFont do
4
- describe ".find" do
5
- context "with a valid existing font" do
6
- it "returns the complete font path" do
7
- name = "DejaVuSerif.ttf"
8
- dejavu_ttf = Fontist::SystemFont.find(name, sources: [font_sources])
9
-
10
- expect(dejavu_ttf).not_to be_nil
11
- expect(dejavu_ttf.first).to include("spec/fixtures/fonts/")
12
- end
13
- end
14
-
15
- context "with valid font name" do
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
-
21
- calbiri = Fontist::SystemFont.find(name, sources: [font_sources])
22
- expect(calbiri.join("|").downcase).to include("#{name.downcase}.ttf")
23
- end
24
- end
25
-
26
- context "with invalid font" do
27
- it "returns nil for partial-not match" do
28
- name = "Deje"
29
- expect(Fontist::SystemFont.find(name)).to be_nil
30
- end
31
-
32
- it "returns nill to the caller" do
33
- name = "invalid-font.ttf"
34
- invalid_font = Fontist::SystemFont.find(name, sources: [font_sources])
35
-
36
- expect(invalid_font).to be_nil
37
- end
38
- end
39
- end
40
-
41
- def font_sources
42
- @font_sources ||= Fontist.root_path.join("spec/fixtures/fonts/*")
43
- end
44
- end
@@ -1,35 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe Fontist::Utils::Downloader do
4
- describe ".download" do
5
- it "return the valid downloaded file" do
6
- tempfile = Fontist::Utils::Downloader.download(
7
- sample_file[:file],
8
- sha: sample_file[:sha],
9
- file_size: sample_file[:file_size],
10
- )
11
-
12
- expect(tempfile).not_to be_nil
13
- expect(tempfile.size).to eq(sample_file[:file_size])
14
- end
15
-
16
- it "raises an error for tempared file" do
17
- expect{
18
- Fontist::Utils::Downloader.download(
19
- sample_file[:file],
20
- sha: sample_file[:sha] + "mm",
21
- file_size: sample_file[:file_size]
22
- )
23
- }.to raise_error(Fontist::Errors::TamperedFileError)
24
- end
25
- end
26
-
27
- def sample_file
28
- @sample_file ||= {
29
- file_size: 150899,
30
- file: "https://drive.google.com/u/0/uc?id=1Kk-rpLyQk98ubgxhTRKD2ZkMoY9KqKXk&export=download",
31
- sha: "5e513e4bfdada0ff10dd5b96414fcaeade84e235ce043865416ad7673cb6f3d8"
32
- }
33
- end
34
- end
35
-
@@ -1,5 +0,0 @@
1
- RSpec.describe Fontist do
2
- it "has a version number" do
3
- expect(Fontist::VERSION).not_to be nil
4
- end
5
- end
@@ -1,22 +0,0 @@
1
- require "bundler/setup"
2
- require "fontist"
3
-
4
- Dir["./spec/support/**/*.rb"].sort.each { |file| require file }
5
-
6
- RSpec.configure do |config|
7
- # Enable flags like --only-failures and --next-failure
8
- config.example_status_persistence_file_path = ".rspec_status"
9
- config.include Fontist::Helper
10
-
11
- # Disable RSpec exposing methods globally on `Module` and `main`
12
- config.disable_monkey_patching!
13
-
14
- # Skip the slow tests locally
15
- unless ENV.fetch("TEST_ENV", "local").upcase === "CI"
16
- config.filter_run_excluding slow: true
17
- end
18
-
19
- config.expect_with :rspec do |c|
20
- c.syntax = :expect
21
- end
22
- end
@@ -1,10 +0,0 @@
1
- module Fontist
2
- module Helper
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
- )
7
- end
8
- end
9
- end
10
-