fontist 1.2.1 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) 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 +224 -0
  10. data/bin/check_google +8 -0
  11. data/bin/convert_formulas +8 -0
  12. data/bin/fontist +7 -0
  13. data/bin/generate_otfinfo +8 -0
  14. data/bin/import_google +8 -0
  15. data/fontist.gemspec +16 -1
  16. data/lib/fontist.rb +23 -13
  17. data/lib/fontist/cli.rb +162 -0
  18. data/lib/fontist/errors.rb +5 -0
  19. data/lib/fontist/font.rb +181 -8
  20. data/lib/fontist/font_formula.rb +12 -5
  21. data/lib/fontist/fontist_font.rb +70 -0
  22. data/lib/fontist/formula.rb +27 -9
  23. data/lib/fontist/formula_template.rb +108 -0
  24. data/lib/fontist/formulas.rb +41 -0
  25. data/lib/fontist/import.rb +9 -0
  26. data/lib/fontist/import/convert_formulas.rb +65 -0
  27. data/lib/fontist/import/create_formula.rb +74 -0
  28. data/lib/fontist/import/extractors.rb +5 -0
  29. data/lib/fontist/import/extractors/cab_extractor.rb +37 -0
  30. data/lib/fontist/import/extractors/extractor.rb +19 -0
  31. data/lib/fontist/import/extractors/ole_extractor.rb +41 -0
  32. data/lib/fontist/import/extractors/seven_zip_extractor.rb +44 -0
  33. data/lib/fontist/import/extractors/zip_extractor.rb +31 -0
  34. data/lib/fontist/import/files/collection_file.rb +47 -0
  35. data/lib/fontist/import/formula_builder.rb +162 -0
  36. data/lib/fontist/import/formula_serializer.rb +133 -0
  37. data/lib/fontist/import/google.rb +16 -0
  38. data/lib/fontist/import/google/fonts_public.md +10 -0
  39. data/lib/fontist/import/google/fonts_public.pb.rb +71 -0
  40. data/lib/fontist/import/google/fonts_public.proto +46 -0
  41. data/lib/fontist/import/google/new_fonts_fetcher.rb +121 -0
  42. data/lib/fontist/import/google/skiplist.yml +8 -0
  43. data/lib/fontist/import/google_check.rb +34 -0
  44. data/lib/fontist/import/google_import.rb +180 -0
  45. data/lib/fontist/import/helpers/hash_helper.rb +13 -0
  46. data/lib/fontist/import/helpers/system_helper.rb +23 -0
  47. data/lib/fontist/import/otf/font_file.rb +91 -0
  48. data/lib/fontist/import/otf_parser.rb +25 -0
  49. data/lib/fontist/import/otf_style.rb +29 -0
  50. data/lib/fontist/import/otfinfo/otfinfo_requirement.rb +22 -0
  51. data/lib/fontist/import/otfinfo/template.erb +20 -0
  52. data/lib/fontist/import/otfinfo_generate.rb +45 -0
  53. data/lib/fontist/import/recursive_extraction.rb +128 -0
  54. data/lib/fontist/import/template_helper.rb +19 -0
  55. data/lib/fontist/import/text_helper.rb +30 -0
  56. data/lib/fontist/manifest.rb +2 -0
  57. data/lib/fontist/manifest/common.rb +60 -0
  58. data/lib/fontist/manifest/install.rb +36 -0
  59. data/lib/fontist/manifest/locations.rb +13 -0
  60. data/lib/fontist/registry.rb +1 -0
  61. data/lib/fontist/system_font.rb +53 -22
  62. data/lib/fontist/utils.rb +5 -0
  63. data/lib/fontist/utils/cache.rb +88 -0
  64. data/lib/fontist/utils/downloader.rb +69 -8
  65. data/lib/fontist/utils/dsl.rb +4 -0
  66. data/lib/fontist/utils/dsl/font.rb +37 -0
  67. data/lib/fontist/utils/exe_extractor.rb +20 -18
  68. data/lib/fontist/utils/msi_extractor.rb +31 -0
  69. data/lib/fontist/utils/seven_zip_extractor.rb +41 -0
  70. data/lib/fontist/utils/system.rb +23 -0
  71. data/lib/fontist/utils/ui.rb +27 -0
  72. data/lib/fontist/utils/zip_extractor.rb +10 -4
  73. data/lib/fontist/version.rb +1 -1
  74. metadata +185 -48
  75. data/lib/fontist/formulas/andale_font.rb +0 -80
  76. data/lib/fontist/formulas/arial_black_font.rb +0 -79
  77. data/lib/fontist/formulas/cleartype_fonts.rb +0 -227
  78. data/lib/fontist/formulas/comic_font.rb +0 -78
  79. data/lib/fontist/formulas/courier_font.rb +0 -81
  80. data/lib/fontist/formulas/euphemia_font.rb +0 -85
  81. data/lib/fontist/formulas/georgia_font.rb +0 -80
  82. data/lib/fontist/formulas/impact_font.rb +0 -78
  83. data/lib/fontist/formulas/montserrat_font.rb +0 -132
  84. data/lib/fontist/formulas/ms_truetype_fonts.rb +0 -125
  85. data/lib/fontist/formulas/open_sans_fonts.rb +0 -263
  86. data/lib/fontist/formulas/overpass_font.rb +0 -73
  87. data/lib/fontist/formulas/source_fonts.rb +0 -109
  88. data/lib/fontist/formulas/stix_fonts.rb +0 -108
  89. data/lib/fontist/formulas/tahoma_font.rb +0 -147
  90. data/lib/fontist/formulas/webding_font.rb +0 -78
  91. data/spec/fontist/font_formula_spec.rb +0 -67
  92. data/spec/fontist/font_spec.rb +0 -87
  93. data/spec/fontist/formula_spec.rb +0 -67
  94. data/spec/fontist/formulas/andale_font_spec.rb +0 -29
  95. data/spec/fontist/formulas/arial_black_font_spec.rb +0 -29
  96. data/spec/fontist/formulas/cleartype_fonts_spec.rb +0 -38
  97. data/spec/fontist/formulas/comic_font_spec.rb +0 -29
  98. data/spec/fontist/formulas/courier_font_spec.rb +0 -29
  99. data/spec/fontist/formulas/euphemia_font_spec.rb +0 -29
  100. data/spec/fontist/formulas/georgia_font_spec.rb +0 -29
  101. data/spec/fontist/formulas/impact_font_spec.rb +0 -29
  102. data/spec/fontist/formulas/montserrat_font_spec.rb +0 -29
  103. data/spec/fontist/formulas/ms_truetype_fonts_spec.rb +0 -29
  104. data/spec/fontist/formulas/open_sans_fonts_spec.rb +0 -29
  105. data/spec/fontist/formulas/overpass_font_spec.rb +0 -29
  106. data/spec/fontist/formulas/source_fonts_spec.rb +0 -31
  107. data/spec/fontist/formulas/stix_fonts_spec.rb +0 -29
  108. data/spec/fontist/formulas/tahoma_font_spec.rb +0 -29
  109. data/spec/fontist/formulas/webding_font_spec.rb +0 -29
  110. data/spec/fontist/registry_spec.rb +0 -47
  111. data/spec/fontist/system_font_spec.rb +0 -44
  112. data/spec/fontist/utils/downloader_spec.rb +0 -35
  113. data/spec/fontist_spec.rb +0 -5
  114. data/spec/spec_helper.rb +0 -22
  115. data/spec/support/fontist_helper.rb +0 -10
@@ -1,87 +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 the font and return the paths" do
50
- name = "Calibri"
51
-
52
- stub_fontist_path_to_temp_path
53
- font_paths = Fontist::Font.install(name, confirmation: "yes")
54
-
55
- expect(font_paths.join("|").downcase).to include("#{name.downcase}.ttf")
56
- end
57
- end
58
-
59
- context "with existing font name" do
60
- it "returns the existing font paths" do
61
- name = "Courier"
62
- stub_fontist_path_to_temp_path
63
- Fontist::Font.install(name, confirmation: "yes")
64
-
65
- font_paths = Fontist::Font.install(name, confirmation: "yes")
66
-
67
- expect(font_paths.count).to be > 3
68
- expect(Fontist::Formulas::CourierFont).not_to receive(:fetch_font)
69
- end
70
- end
71
-
72
- context "with unsupported fonts" do
73
- it "raises an unsupported error" do
74
- name = "Invalid font name"
75
-
76
- expect {
77
- Fontist::Font.install(name, confirmation: "yes")
78
- }.to raise_error(Fontist::Errors::NonSupportedFontError)
79
- end
80
- end
81
- end
82
-
83
- def stub_system_font_finder_to_fixture(name)
84
- allow(Fontist::SystemFont).to receive(:find).
85
- and_return(["spec/fixtures/fonts/#{name}"])
86
- end
87
- 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
@@ -1,29 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe Fontist::Formulas::AndaleFont do
4
- describe "initializing" do
5
- it "builds the data dictionary" do
6
- formula = Fontist::Formulas::AndaleFont.instance
7
-
8
- expect(formula.fonts.count).to eq(1)
9
- expect(formula.fonts.first[:name]).to eq("Andale Mono")
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 = "Andale Mono"
17
- confirmation = "yes"
18
-
19
- stub_fontist_path_to_temp_path
20
- paths = Fontist::Formulas::AndaleFont.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/AndaleMo.TTF")
26
- end
27
- end
28
- end
29
- end
@@ -1,29 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe Fontist::Formulas::ArialBlackFont do
4
- describe "initializing" do
5
- it "builds the data dictionary" do
6
- formula = Fontist::Formulas::ArialBlackFont.instance
7
-
8
- expect(formula.fonts.count).to eq(1)
9
- expect(formula.fonts.first[:name]).to eq("Arial Black")
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 = "Arial Black"
17
- confirmation = "yes"
18
-
19
- stub_fontist_path_to_temp_path
20
- paths = Fontist::Formulas::ArialBlackFont.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/AriBlk.TTF")
26
- end
27
- end
28
- end
29
- end
@@ -1,38 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe Fontist::Formulas::ClearTypeFonts do
4
- describe "initializing" do
5
- it "builds the data dictionary" do
6
- formula = Fontist::Formulas::ClearTypeFonts.instance
7
-
8
- expect(formula.fonts.count).to eq(12)
9
- expect(formula.fonts[1][:name]).to eq("Cambria Math")
10
- expect(formula.fonts.first[:name]).to eq("Cambria")
11
- end
12
- end
13
-
14
- describe "installation" do
15
- context "with valid licence agreement", slow: true do
16
- it "installs the valid fonts", skip_in_windows: true do
17
- name = "Calibri"
18
- confirmation = "yes"
19
-
20
- paths = Fontist::Formulas::ClearTypeFonts.fetch_font(
21
- name, confirmation: confirmation
22
- )
23
-
24
- expect(paths.first).to include("fonts/#{name.upcase}.TTF")
25
- end
26
- end
27
-
28
- context "with missing licence agreement" do
29
- it "raises an Fontist::Errors::LicensingError" do
30
- name = "Calibri"
31
-
32
- expect {
33
- Fontist::Formulas::ClearTypeFonts.fetch_font(name, confirmation: "no")
34
- }.to raise_error(Fontist::Errors::LicensingError)
35
- end
36
- end
37
- end
38
- end
@@ -1,29 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe Fontist::Formulas::ComicFont do
4
- describe "initializing" do
5
- it "builds the data dictionary" do
6
- formula = Fontist::Formulas::ComicFont.instance
7
-
8
- expect(formula.fonts.count).to eq(1)
9
- expect(formula.fonts.first[:name]).to eq("Comic Sans")
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 = "Comic Sans"
17
- confirmation = "yes"
18
-
19
- stub_fontist_path_to_temp_path
20
- paths = Fontist::Formulas::ComicFont.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/Comicbd.TTF")
26
- end
27
- end
28
- end
29
- end
@@ -1,29 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe Fontist::Formulas::CourierFont do
4
- describe "initializing" do
5
- it "builds the data dictionary" do
6
- formula = Fontist::Formulas::CourierFont.instance
7
-
8
- expect(formula.fonts.count).to eq(1)
9
- expect(formula.fonts.first[:name]).to eq("Courier")
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 = "Courier"
17
- confirmation = "yes"
18
-
19
- stub_fontist_path_to_temp_path
20
- paths = Fontist::Formulas::CourierFont.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/cour.ttf")
26
- end
27
- end
28
- end
29
- end
@@ -1,29 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe Fontist::Formulas::EuphemiaFont do
4
- describe "initializing" do
5
- it "builds the data dictionary" do
6
- formula = Fontist::Formulas::EuphemiaFont.instance
7
-
8
- expect(formula.fonts.count).to eq(1)
9
- expect(formula.fonts.first[:name]).to eq("Euphemia UCAS")
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 = "Euphemia UCAS"
17
- confirmation = "yes"
18
-
19
- stub_fontist_path_to_temp_path
20
- paths = Fontist::Formulas::EuphemiaFont.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} Italic 2.6.6.ttf")
26
- end
27
- end
28
- end
29
- end
@@ -1,29 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe Fontist::Formulas::GeorgiaFont do
4
- describe "initializing" do
5
- it "builds the data dictionary" do
6
- formula = Fontist::Formulas::GeorgiaFont.instance
7
-
8
- expect(formula.fonts.count).to eq(1)
9
- expect(formula.fonts.first[:name]).to eq("Georgia")
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 = "Georgia"
17
- confirmation = "yes"
18
-
19
- stub_fontist_path_to_temp_path
20
- paths = Fontist::Formulas::GeorgiaFont.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/Georgiaz.TTF")
26
- end
27
- end
28
- end
29
- end
@@ -1,29 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe Fontist::Formulas::ImpactFont do
4
- describe "initializing" do
5
- it "builds the data dictionary" do
6
- formula = Fontist::Formulas::ImpactFont.instance
7
-
8
- expect(formula.fonts.count).to eq(1)
9
- expect(formula.fonts.first[:name]).to eq("Impact")
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 = "Impact"
17
- confirmation = "yes"
18
-
19
- stub_fontist_path_to_temp_path
20
- paths = Fontist::Formulas::ImpactFont.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::MontserratFont do
4
- describe "initializing" do
5
- it "builds the data dictionary" do
6
- formula = Fontist::Formulas::MontserratFont.instance
7
-
8
- expect(formula.fonts.count).to eq(2)
9
- expect(formula.fonts.first[:name]).to eq("Montserrat")
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 = "Montserrat"
17
- confirmation = "yes"
18
-
19
- stub_fontist_path_to_temp_path
20
- paths = Fontist::Formulas::MontserratFont.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}-Thin.otf")
26
- end
27
- end
28
- end
29
- end
@@ -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