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,90 @@
1
+ module Fontist
2
+ class Formula
3
+ def initialize(options = {})
4
+ @font_name = options.fetch(:font_name, nil)
5
+
6
+ check_and_register_font_formulas
7
+ end
8
+
9
+ def self.all
10
+ new.all
11
+ end
12
+
13
+ def self.find(font_name)
14
+ new(font_name: font_name).find
15
+ end
16
+
17
+ def self.find_fonts(name)
18
+ new(font_name: name).find_fonts
19
+ end
20
+
21
+ def all
22
+ @all ||= Fontist::Registry.instance.formulas
23
+ end
24
+
25
+ def find
26
+ [find_formula].flatten.first
27
+ end
28
+
29
+ def find_fonts
30
+ formulas = [find_formula].flatten
31
+ match_fonts_by_name(formulas) unless formulas.empty?
32
+ end
33
+
34
+ private
35
+
36
+ attr_reader :font_name
37
+
38
+ def find_formula
39
+ find_by_font_name || find_by_font || []
40
+ end
41
+
42
+ def formulas
43
+ @formulas ||= all.to_h
44
+ end
45
+
46
+ def match_fonts_by_name(formulas)
47
+ matched_fonts = formulas.map do |formula|
48
+ formula.fonts.select do |font|
49
+ font.name.downcase == font_name.downcase
50
+ end
51
+ end
52
+
53
+ matched_fonts.empty? ? nil : matched_fonts.flatten
54
+ end
55
+
56
+ def find_by_font_name
57
+ matched_formulas = formulas.select do |key, value|
58
+ !value.fonts.map(&:name).grep(/#{font_name}/i).empty?
59
+ end
60
+
61
+ matched_formulas.empty? ? nil : matched_formulas.values
62
+ end
63
+
64
+ # Note
65
+ #
66
+ # These interface recursively look into every single font styles,
67
+ # so ideally try to avoid using it when possible, and that's why
68
+ # we've added it as last option in formula finder.
69
+ #
70
+ def find_by_font
71
+ matched_formulas = formulas.select do |key, value|
72
+ match_in_font_styles?(value[:fonts])
73
+ end
74
+
75
+ matched_formulas.empty? ? nil : matched_formulas.values
76
+ end
77
+
78
+ def match_in_font_styles?(fonts)
79
+ styles = fonts.select do |font|
80
+ !font.styles.map(&:font).grep(/#{font_name}/i).empty?
81
+ end
82
+
83
+ styles.empty? ? false : true
84
+ end
85
+
86
+ def check_and_register_font_formulas
87
+ $check_and_register_font_formulas ||= Fontist::Formulas.register_formulas
88
+ end
89
+ end
90
+ end
@@ -1,10 +1,15 @@
1
- require "fontist/formulas/base"
2
- require "fontist/formulas/ms_vista"
3
- require "fontist/formulas/ms_system"
4
- require "fontist/formulas/source_font"
5
- require "fontist/formulas/courier_font"
1
+ require "fontist/utils"
2
+ require "fontist/font_formula"
6
3
 
7
4
  module Fontist
8
5
  module Formulas
6
+ def self.register_formulas
7
+ Formulas.constants.select do |constant|
8
+ if Formulas.const_get(constant).is_a?(Class)
9
+ klass = "Fontist::Formulas::#{constant}"
10
+ Fontist::Registry.register(Object.const_get(klass))
11
+ end
12
+ end
13
+ end
9
14
  end
10
15
  end
@@ -0,0 +1,79 @@
1
+ module Fontist
2
+ module Formulas
3
+ class AndaleFont < FontFormula
4
+ key :andale_font
5
+ desc "Microsoft TrueType Core fonts for the Web"
6
+ homepage "https://www.microsoft.com"
7
+
8
+ resource "andale32.exe" do
9
+ urls [
10
+ "https://nchc.dl.sourceforge.net/project/corefonts/the%20fonts/final/andale32.exe",
11
+ "http://sft.if.usp.br/msttcorefonts/andale32.exe"
12
+ ]
13
+ sha256 "0524fe42951adc3a7eb870e32f0920313c71f170c859b5f770d82b4ee111e970"
14
+ end
15
+
16
+ provides_font("Andale Mono", match_styles_from_file: {
17
+ "Regular" => "AndaleMo.TTF"
18
+ })
19
+
20
+ def extract
21
+ resource "andale32.exe" do |resource|
22
+ cab_extract(resource) do |dir|
23
+ match_fonts(dir, "Andale Mono")
24
+ end
25
+ end
26
+
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/vista"
35
+ end
36
+ end
37
+
38
+ test do
39
+ case platform
40
+ when :macos
41
+ assert_predicate "$HOME/Library/Fonts/Microsoft/AndaleMo.ttf", :exist?
42
+ when :linux
43
+ assert_predicate "/usr/share/fonts/truetype/vista/AndaleMo.ttf", :exist?
44
+ end
45
+ end
46
+
47
+ requires_license_agreement <<~EOS
48
+ (from http://web.archive.org/web/20011222020409/http://www.microsoft.com/typography/fontpack/eula.htm)
49
+ TrueType core fonts for the Web EULA
50
+ END-USER LICENSE AGREEMENT FOR
51
+ MICROSOFT SOFTWARE
52
+ 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.
53
+ SOFTWARE PRODUCT LICENSE
54
+ 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.
55
+ 1. GRANT OF LICENSE. This EULA grants you the following rights:
56
+ * Installation and Use. You may install and use an unlimited number of copies of the SOFTWARE PRODUCT.
57
+ * 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.
58
+ 2. DESCRIPTION OF OTHER RIGHTS AND LIMITATIONS.
59
+ * 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.
60
+ * 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.
61
+ * Software Transfer. You may permanently transfer all of your rights under this EULA, provided the recipient agrees to the terms of this EULA.
62
+ * 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.
63
+ 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.
64
+ 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.
65
+ LIMITED WARRANTY
66
+ 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.
67
+ 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.
68
+ MISCELLANEOUS
69
+ If you acquired this product in the United States, this EULA is governed by the laws of the State of Washington.
70
+ If this product was acquired outside the United States, then local laws may apply.
71
+ 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.
72
+ this page was last updated 28 July 1998
73
+ © 1997 Microsoft Corporation. All rights reserved. Terms of use.
74
+ comments to the MST group: ttwsite@microsoft.com
75
+ EOS
76
+ end
77
+ end
78
+
79
+ end
@@ -0,0 +1,78 @@
1
+ module Fontist
2
+ module Formulas
3
+ class ArialBlackFont < FontFormula
4
+ key :arial_black
5
+ desc "Microsoft TrueType Core fonts for the Web"
6
+ homepage "https://www.microsoft.com"
7
+
8
+ resource "arialb32.exe" do
9
+ urls [
10
+ "https://nchc.dl.sourceforge.net/project/corefonts/the%20fonts/final/arialb32.exe",
11
+ "http://sft.if.usp.br/msttcorefonts/arialb32.exe"
12
+ ]
13
+ sha256 "a425f0ffb6a1a5ede5b979ed6177f4f4f4fdef6ae7c302a7b7720ef332fec0a8"
14
+ end
15
+
16
+ provides_font("Arial Black", match_styles_from_file: {
17
+ "Regular" => "AriBlk.TTF"
18
+ })
19
+
20
+ def extract
21
+ resource "arialb32.exe" do |resource|
22
+ cab_extract(resource) do |dir|
23
+ match_fonts(dir, "Arial Black")
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/AriBlk.ttf", :exist?
41
+ when :linux
42
+ assert_predicate "/usr/share/fonts/truetype/vista/AriBlk.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
@@ -0,0 +1,225 @@
1
+ module Fontist
2
+ module Formulas
3
+ class ClearTypeFonts < Fontist::FontFormula
4
+ key :cleartype
5
+ desc "Microsoft ClearType Fonts"
6
+ homepage "https://www.microsoft.com"
7
+
8
+ resource "PowerPointViewer.exe" do
9
+ urls [
10
+ "https://nchc.dl.sourceforge.net/project/mscorefonts2/cabs/PowerPointViewer.exe",
11
+ "https://sourceforge.net/projects/mscorefonts2/files/cabs/PowerPointViewer.exe/download",
12
+ "https://web.archive.org/web/20171225132744/http://download.microsoft.com/download/E/6/7/E675FFFC-2A6D-4AB0-B3EB-27C9F8C8F696/PowerPointViewer.exe",
13
+ "https://archive.org/download/PowerPointViewer_201801/PowerPointViewer.exe"
14
+ ]
15
+
16
+ sha256 [
17
+ "249473568eba7a1e4f95498acba594e0f42e6581add4dead70c1dfb908a09423",
18
+ "c4e753548d3092ffd7dd3849105e0a26d9b5a1afe46e6e667fe7c6887893701f",
19
+ ]
20
+
21
+ file_size "62914560"
22
+ end
23
+
24
+ provides_font_collection do |coll|
25
+ filename "CAMBRIA.TTC"
26
+ provides_font "Cambria", extract_styles_from_collection: {
27
+ "Regular" => "Cambria"
28
+ }
29
+ provides_font "Cambria Math"
30
+ end
31
+
32
+ provides_font_collection do |coll|
33
+ filename "MEIRYO.TTC"
34
+ provides_font "Meiryo", extract_styles_from_collection: {
35
+ "Regular" => "Meiryo",
36
+ "Italic" => "Meiryo Italic"
37
+ }
38
+
39
+ provides_font "Meiryo UI", extract_styles_from_collection: {
40
+ "Regular" => "Meiryo UI",
41
+ "Italic" => "Meiryo UI Italic"
42
+ }
43
+ end
44
+
45
+ provides_font_collection("Meiryo Bold") do |coll|
46
+ filename "MEIRYOB.TTC"
47
+ provides_font "Meiryo", extract_styles_from_collection: {
48
+ "Bold" => "Meiryo Bold",
49
+ "Bold Italic" => "Meiryo Bold Italic"
50
+ }
51
+
52
+ provides_font "Meiryo UI", extract_styles_from_collection: {
53
+ "Bold" => "Meiryo UI Bold",
54
+ "Bold Italic" => "Meiryo UI Bold Italic"
55
+ }
56
+ end
57
+
58
+ provides_font("Cambria", match_styles_from_file: {
59
+ "Bold" => "CAMBRIAB.TTF",
60
+ "Italic" => "CAMBRIAI.TTF",
61
+ "Bold Italic" => "CAMBRIAZ.TTF",
62
+ })
63
+
64
+ provides_font("Calibri", match_styles_from_file: {
65
+ "Regular" => "CALIBRI.TTF",
66
+ "Bold" => "CALIBRIB.TTF",
67
+ "Italic" => "CALIBRII.TTF",
68
+ "Bold Italic" => "CALIBRIZ.TTF"
69
+ })
70
+
71
+ provides_font("Candara", match_styles_from_file: {
72
+ "Regular" => "CANDARA.TTF",
73
+ "Bold" => "CANDARAB.TTF",
74
+ "Italic" => "CANDARAI.TTF",
75
+ "Bold Italic" => "CANDARAZ.TTF"
76
+ })
77
+
78
+ provides_font("Consola", match_styles_from_file: {
79
+ "Regular" => "CONSOLA.TTF",
80
+ "Bold" => "CONSOLAB.TTF",
81
+ "Italic" => "CONSOLAI.TTF",
82
+ "Bold Italic" => "CONSOLAZ.TTF"
83
+ })
84
+
85
+ provides_font("Constantia", match_styles_from_file: {
86
+ "Regular" => "CONSTAN.TTF",
87
+ "Bold" => "CONSTANB.TTF",
88
+ "Italic" => "CONSTANI.TTF",
89
+ "Bold Italic" => "CONSTANZ.TTF"
90
+ })
91
+
92
+ provides_font("Corbel", match_styles_from_file: {
93
+ "Regular" => "CORBEL.TTF",
94
+ "Bold" => "CORBELB.TTF",
95
+ "Italic" => "CORBELI.TTF",
96
+ "Bold Italic" => "CORBELZ.TTF"
97
+ })
98
+
99
+ def extract
100
+ resource("PowerPointViewer.exe") do |resource|
101
+ exe_extract(resource) do |dir|
102
+ cab_extract(dir["ppviewer.cab"]) do |fontdir|
103
+ match_fonts(fontdir, "Calibri")
104
+ match_fonts(fontdir, "Cambria")
105
+ match_fonts(fontdir, "Candara")
106
+ match_fonts(fontdir, "Consola")
107
+ match_fonts(fontdir, "Constantia")
108
+ match_fonts(fontdir, "Corbel")
109
+ match_fonts(fontdir, "Meiryo")
110
+ match_fonts(fontdir, "Meiryo UI")
111
+ end
112
+ end
113
+ end
114
+ end
115
+
116
+ def install
117
+ case platform
118
+ when :macos
119
+ install_matched_fonts "$HOME/Library/Fonts/Microsoft"
120
+ when :linux
121
+ install_matched_fonts "/usr/share/fonts/truetype/cleartype"
122
+ end
123
+ end
124
+
125
+ def caveats
126
+ "Show caveats here"
127
+ end
128
+
129
+ test do
130
+ case platform
131
+ when :macos
132
+ assert_predicate "$HOME/Library/Fonts/Microsoft/candarab.ttf", :exist?
133
+ when :linux
134
+ assert_predicate "/usr/share/fonts/truetype/cleartype/candarab.ttf", :exist?
135
+ end
136
+ end
137
+
138
+ requires_license_agreement <<~EOS
139
+ MICROSOFT SOFTWARE LICENSE TERMS
140
+ MICROSOFT POWERPOINT VIEWER
141
+ These license terms are an agreement between Microsoft Corporation (or based on where you live, one of its affiliates) and you. Please read them. They apply to the software named above, which includes the media on which you received it, if any. The terms also apply to any Microsoft
142
+
143
+ * updates,
144
+ * supplements,
145
+ * Internet-based services, and
146
+ * support services
147
+
148
+ for this software, unless other terms accompany those items. If so, those terms apply.
149
+
150
+ BY USING THE SOFTWARE, YOU ACCEPT THESE TERMS. IF YOU DO NOT ACCEPT THEM, DO NOT USE THE SOFTWARE.
151
+
152
+ If you comply with these license terms, you have the rights below.
153
+
154
+ 1. INSTALLATION AND USE RIGHTS.
155
+
156
+ a. General. You may install and use any number of copies of the software on your devices. You may use the software only to view and print files created with Microsoft Office software. You may not use the software for any other purpose.
157
+
158
+ b. Distribution. You may copy and distribute the software, provided that:
159
+
160
+ * each copy is complete and unmodified, including presentation of this agreement for each user's acceptance; and
161
+ * you indemnify, defend, and hold harmless Microsoft and its affiliates and suppliers from any claims, including attorneys fees, related to your distribution of the software.
162
+
163
+ You may not:
164
+
165
+ * distribute the software with any non-Microsoft software that may use the software to enhance its functionality,
166
+ * alter any copyright, trademark or patent notices in the software,
167
+ * use Microsoft s or affiliates or suppliers name, logo or trademarks to market your products or services,
168
+ * distribute the software with malicious, deceptive or unlawful programs, or
169
+ * modify or distribute the software so that any part of it becomes subject to an Excluded License. An Excluded License is one that requires, as a condition of use, modification or distribution, that
170
+ * the code be disclosed or distributed in source code form; or
171
+ * others have the right to modify it.
172
+
173
+ 2. SCOPE OF LICENSE. The software is licensed, not sold. This agreement only gives you some rights to use the software. Microsoft reserves all other rights. Unless applicable law gives you more rights despite this limitation, you may use the software only as expressly permitted in this agreement. In doing so, you must comply with any technical limitations in the software that only allow you to use it in certain ways. You may not
174
+
175
+ * work around any technical limitations in the software;
176
+ * reverse engineer, decompile or disassemble the software, except and only to the extent that applicable law expressly permits, despite this limitation;
177
+ * make more copies of the software than specified in this agreement or allowed by applicable law, despite this limitation;
178
+ * publish the software for others to copy;
179
+ * rent, lease or lend the software; or
180
+ * use the software for commercial software hosting services.
181
+
182
+ 3. BACKUP COPY. You may make one backup copy of the software. You may use it only to reinstall the software.
183
+
184
+ 4. FONT COMPONENTS. While the software is running, you may use its fonts to display and print content. You may only
185
+
186
+ * embed fonts in content as permitted by the embedding restrictions in the fonts; and
187
+ * temporarily download them to a printer or other output device to print content.
188
+
189
+ 5. DOCUMENTATION. Any person that has valid access to your computer or internal network may copy and use the documentation for your internal, reference purposes.
190
+
191
+ 6. TRANSFER TO ANOTHER DEVICE. You may uninstall the software and install it on another device for your use. You may not do so to share this license between devices.
192
+
193
+ 7. TRANSFER TO A THIRD PARTY. The first user of the software may transfer it and this agreement directly to a third party. Before the transfer, that party must agree that this agreement applies to the transfer and use of the software. The first user must uninstall the software before transferring it separately from the device. The first user may not retain any copies.
194
+
195
+ 8. EXPORT RESTRICTIONS. The software is subject to United States export laws and regulations. You must comply with all domestic and international export laws and regulations that apply to the software. These laws include restrictions on destinations, end users and end use. For additional information, see www.microsoft.com/exporting.
196
+
197
+ 9. SUPPORT SERVICES. Because this software is as is, we may not provide support services for it.
198
+
199
+ 10. ENTIRE AGREEMENT. This agreement, and the terms for supplements, updates, Internet-based services and support services that you use, are the entire agreement for the software and support services.
200
+
201
+ 11. APPLICABLE LAW.
202
+
203
+ a. United States. If you acquired the software in the United States, Washington state law governs the interpretation of this agreement and applies to claims for breach of it, regardless of conflict of laws principles. The laws of the state where you live govern all other claims, including claims under state consumer protection laws, unfair competition laws, and in tort.
204
+
205
+ b. Outside the United States. If you acquired the software in any other country, the laws of that country apply.
206
+
207
+ 12. LEGAL EFFECT. This agreement describes certain legal rights. You may have other rights under the laws of your country. You may also have rights with respect to the party from whom you acquired the software. This agreement does not change your rights under the laws of your country if the laws of your country do not permit it to do so.
208
+
209
+ 13. DISCLAIMER OF WARRANTY. THE SOFTWARE IS LICENSED AS-IS. YOU BEAR THE RISK OF USING IT. MICROSOFT GIVES NO EXPRESS WARRANTIES, GUARANTEES OR CONDITIONS. YOU MAY HAVE ADDITIONAL CONSUMER RIGHTS UNDER YOUR LOCAL LAWS WHICH THIS AGREEMENT CANNOT CHANGE. TO THE EXTENT PERMITTED UNDER YOUR LOCAL LAWS, MICROSOFT EXCLUDES THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
210
+
211
+ 14. LIMITATION ON AND EXCLUSION OF REMEDIES AND DAMAGES. YOU CAN RECOVER FROM MICROSOFT AND ITS SUPPLIERS ONLY DIRECT DAMAGES UP TO U.S. $5.00. YOU CANNOT RECOVER ANY OTHER DAMAGES, INCLUDING CONSEQUENTIAL, LOST PROFITS, SPECIAL, INDIRECT OR INCIDENTAL DAMAGES.
212
+
213
+ This limitation applies to
214
+
215
+ * anything related to the software, services, content (including code) on third party Internet sites, or third party programs; and
216
+ * claims for breach of contract, breach of warranty, guarantee or condition, strict liability, negligence, or other tort to the extent permitted by applicable law.
217
+
218
+ It also applies even if Microsoft knew or should have known about the possibility of the damages. The above limitation or exclusion may not apply to you because your country may not allow the exclusion or limitation of incidental, consequential or other damages.
219
+
220
+ EULAID:O14_RTM_PPV.1_RTM_EN
221
+
222
+ EOS
223
+ end
224
+ end
225
+ end