fontist 1.0.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) 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 +15 -1
  17. data/lib/fontist.rb +22 -15
  18. data/lib/fontist/cli.rb +118 -0
  19. data/lib/fontist/errors.rb +5 -1
  20. data/lib/fontist/font.rb +153 -3
  21. data/lib/fontist/font_formula.rb +17 -6
  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/registry.rb +1 -0
  58. data/lib/fontist/system.yml +5 -1
  59. data/lib/fontist/system_font.rb +23 -20
  60. data/lib/fontist/utils.rb +6 -0
  61. data/lib/fontist/utils/cache.rb +69 -0
  62. data/lib/fontist/utils/downloader.rb +92 -0
  63. data/lib/fontist/utils/dsl.rb +8 -0
  64. data/lib/fontist/utils/dsl/font.rb +37 -0
  65. data/lib/fontist/utils/exe_extractor.rb +12 -19
  66. data/lib/fontist/utils/msi_extractor.rb +31 -0
  67. data/lib/fontist/utils/seven_zip_extractor.rb +41 -0
  68. data/lib/fontist/utils/system.rb +23 -0
  69. data/lib/fontist/utils/ui.rb +23 -0
  70. data/lib/fontist/utils/zip_extractor.rb +9 -4
  71. data/lib/fontist/version.rb +1 -1
  72. metadata +170 -50
  73. data/lib/fontist/downloader.rb +0 -70
  74. data/lib/fontist/formulas/andale_font.rb +0 -79
  75. data/lib/fontist/formulas/arial_black_font.rb +0 -78
  76. data/lib/fontist/formulas/cleartype_fonts.rb +0 -225
  77. data/lib/fontist/formulas/comic_font.rb +0 -77
  78. data/lib/fontist/formulas/courier_font.rb +0 -80
  79. data/lib/fontist/formulas/euphemia_font.rb +0 -85
  80. data/lib/fontist/formulas/georgia_font.rb +0 -79
  81. data/lib/fontist/formulas/impact_font.rb +0 -77
  82. data/lib/fontist/formulas/montserrat_font.rb +0 -132
  83. data/lib/fontist/formulas/ms_truetype_fonts.rb +0 -124
  84. data/lib/fontist/formulas/open_sans_fonts.rb +0 -263
  85. data/lib/fontist/formulas/overpass_font.rb +0 -73
  86. data/lib/fontist/formulas/source_fonts.rb +0 -109
  87. data/lib/fontist/formulas/stix_fonts.rb +0 -108
  88. data/lib/fontist/formulas/tahoma_font.rb +0 -147
  89. data/lib/fontist/formulas/webding_font.rb +0 -77
  90. data/spec/fontist/downloader_spec.rb +0 -35
  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 -39
  112. data/spec/fontist_spec.rb +0 -5
  113. data/spec/spec_helper.rb +0 -22
  114. 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 "wd97vwr32.exe" do
8
- urls [
9
- "https://nchc.dl.sourceforge.net/project/corefonts/the%20fonts/final/wd97vwr32.exe",
10
- "http://sourceforge.mirrorservice.org/c/co/corefonts/the%20fonts/final/wd97vwr32.exe"
11
- ]
12
- sha256 "f61126a6d17b2d126a7f31b142504dce4934f7989c55f1c13c6477b3fe80b3d2"
13
- end
14
-
15
- provides_font("Tahoma", match_styles_from_file: {
16
- "Regular" => "tahoma.TTF"
17
- })
18
-
19
- def extract
20
- resource("wd97vwr32.exe") do |resource|
21
- exe_extract(resource) do |dir|
22
- cab_extract(dir["Viewer1.cab"]) do |fontdir|
23
- match_fonts(fontdir, "Tahoma")
24
- end
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,77 +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://nchc.dl.sourceforge.net/project/corefonts/the%20fonts/final/webdin32.exe",
10
- "http://sft.if.usp.br/msttcorefonts/webdin32.exe"
11
- ]
12
- sha256 "64595b5abc1080fba8610c5c34fab5863408e806aafe84653ca8575bed17d75a"
13
- end
14
-
15
- provides_font("Webdings", match_styles_from_file: {
16
- "Regular" => "Webdings.TTF"
17
- })
18
-
19
- def extract
20
- resource "webdin32.exe" do |resource|
21
- cab_extract(resource) do |dir|
22
- match_fonts(dir, "Webdings")
23
- end
24
- end
25
- end
26
-
27
- def install
28
- case platform
29
- when :macos
30
- install_matched_fonts "$HOME/Library/Fonts/Microsoft"
31
- when :linux
32
- install_matched_fonts "/usr/share/fonts/truetype/vista"
33
- end
34
- end
35
-
36
- test do
37
- case platform
38
- when :macos
39
- assert_predicate "$HOME/Library/Fonts/Microsoft/Webdings.ttf", :exist?
40
- when :linux
41
- assert_predicate "/usr/share/fonts/truetype/vista/Webdings.ttf", :exist?
42
- end
43
- end
44
-
45
- requires_license_agreement <<~EOS
46
- (from http://web.archive.org/web/20011222020409/http://www.microsoft.com/typography/fontpack/eula.htm)
47
- TrueType core fonts for the Web EULA
48
- END-USER LICENSE AGREEMENT FOR
49
- MICROSOFT SOFTWARE
50
- 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.
51
- SOFTWARE PRODUCT LICENSE
52
- 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.
53
- 1. GRANT OF LICENSE. This EULA grants you the following rights:
54
- * Installation and Use. You may install and use an unlimited number of copies of the SOFTWARE PRODUCT.
55
- * 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.
56
- 2. DESCRIPTION OF OTHER RIGHTS AND LIMITATIONS.
57
- * 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.
58
- * 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.
59
- * Software Transfer. You may permanently transfer all of your rights under this EULA, provided the recipient agrees to the terms of this EULA.
60
- * 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.
61
- 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.
62
- 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.
63
- LIMITED WARRANTY
64
- 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.
65
- 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.
66
- MISCELLANEOUS
67
- If you acquired this product in the United States, this EULA is governed by the laws of the State of Washington.
68
- If this product was acquired outside the United States, then local laws may apply.
69
- 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.
70
- this page was last updated 28 July 1998
71
- © 1997 Microsoft Corporation. All rights reserved. Terms of use.
72
- comments to the MST group: ttwsite@microsoft.com
73
- EOS
74
- end
75
- end
76
-
77
- end
@@ -1,35 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe Fontist::Downloader do
4
- describe ".download" do
5
- it "return the valid downloaded file" do
6
- tempfile = Fontist::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::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::TemparedFileError)
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,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
@@ -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