fontist 1.21.4 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +4 -0
  3. data/Gemfile +11 -0
  4. data/README.adoc +77 -11
  5. data/docs/guide/api-ruby.md +10 -11
  6. data/fontist.gemspec +14 -24
  7. data/formula_filename_index.yml +6210 -0
  8. data/formula_index.yml +2568 -0
  9. data/lib/fontist/cli.rb +16 -14
  10. data/lib/fontist/config.rb +75 -14
  11. data/lib/fontist/errors.rb +2 -0
  12. data/lib/fontist/extract.rb +25 -0
  13. data/lib/fontist/font.rb +6 -8
  14. data/lib/fontist/font_collection.rb +16 -0
  15. data/lib/fontist/font_installer.rb +4 -4
  16. data/lib/fontist/font_model.rb +15 -0
  17. data/lib/fontist/font_path.rb +1 -1
  18. data/lib/fontist/font_style.rb +37 -0
  19. data/lib/fontist/formula.rb +169 -112
  20. data/lib/fontist/helpers.rb +5 -4
  21. data/lib/fontist/import/create_formula.rb +2 -1
  22. data/lib/fontist/import/files/collection_file.rb +5 -15
  23. data/lib/fontist/import/font_style.rb +22 -0
  24. data/lib/fontist/import/formula_serializer.rb +4 -4
  25. data/lib/fontist/import/google_import.rb +1 -1
  26. data/lib/fontist/import/otf/font_file.rb +8 -3
  27. data/lib/fontist/import/otf_style.rb +3 -1
  28. data/lib/fontist/import/recursive_extraction.rb +9 -4
  29. data/lib/fontist/index.rb +47 -8
  30. data/lib/fontist/indexes/default_family_font_index.rb +28 -9
  31. data/lib/fontist/indexes/filename_index.rb +45 -8
  32. data/lib/fontist/indexes/font_index.rb +3 -3
  33. data/lib/fontist/indexes/formula_key_to_path.rb +35 -0
  34. data/lib/fontist/indexes/index_mixin.rb +109 -0
  35. data/lib/fontist/indexes/preferred_family_font_index.rb +28 -9
  36. data/lib/fontist/manifest.rb +144 -2
  37. data/lib/fontist/manifest_request.rb +64 -0
  38. data/lib/fontist/manifest_response.rb +66 -0
  39. data/lib/fontist/repo.rb +1 -1
  40. data/lib/fontist/resources/archive_resource.rb +3 -2
  41. data/lib/fontist/system_font.rb +7 -25
  42. data/lib/fontist/system_index.rb +137 -126
  43. data/lib/fontist/utils/cache.rb +54 -4
  44. data/lib/fontist/utils/downloader.rb +6 -4
  45. data/lib/fontist/version.rb +1 -1
  46. data/lib/fontist.rb +33 -13
  47. metadata +23 -148
  48. data/lib/fontist/indexes/base_index.rb +0 -92
  49. data/lib/fontist/indexes/index_formula.rb +0 -36
  50. data/lib/fontist/manifest/install.rb +0 -35
  51. data/lib/fontist/manifest/locations.rb +0 -84
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cfd5ec32758b1fac561e81c902c8a6be42fba0050802a65a1c856d01c4c28239
4
- data.tar.gz: 7530a3efd9cb1921aa9c074a7dc09c343ffb281b2ebd294750fd8621f75c2d83
3
+ metadata.gz: 579975f05c71659ca72914f2e273dead08930e5943f230fbc4ad5029d19b5bad
4
+ data.tar.gz: c3529656ee99bbd27cd9b7c37025e79350c99ead6b5f222cb08773460b2e6feb
5
5
  SHA512:
6
- metadata.gz: 32526e4bee6a47c6ac946acbbf1a831cf9b41b2c1f4ce0e9750ee60dfee06a4c9122bcd521b2f5612ab87d89d75dc13b18d35eed2c25fe8a57e8d1e31ab66738
7
- data.tar.gz: 920c81e9380c7874cc91599161887709a897ae6b37ac21fcda8aa8285eb86b367f9eb4def36d26d96c3f7da891989da1aff4be5085219ecd71cceea594c35259
6
+ metadata.gz: 7cffa6efd591fc625aff86d71774ef70aff09b6c0fe9d5cb53f4ff0fff81a80fb76950701267ecfd8bea637a26e046a1ce698111226c8972049d86cd0110dd7a
7
+ data.tar.gz: 8e0386ba63208db999567979f733521ff11b64b745bfd492436012761335a6a406b0fc0104176e05cecb283c4bd3924504e7668ab388a2937fd1596f6bfe8fa4
@@ -4,7 +4,11 @@ on:
4
4
  push:
5
5
  branches: [ main ]
6
6
  tags: [ 'v*' ]
7
+ paths-ignore:
8
+ - '**.adoc'
7
9
  pull_request:
10
+ paths-ignore:
11
+ - '**.adoc'
8
12
 
9
13
  concurrency:
10
14
  group: '${{ github.workflow }}-${{ github.job }}-${{ github.head_ref || github.ref_name }}'
data/Gemfile CHANGED
@@ -2,3 +2,14 @@ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in fontist.gemspec
4
4
  gemspec
5
+
6
+ gem "pry"
7
+ gem "bundler"
8
+ gem "rake"
9
+ gem "rspec"
10
+ gem "rspec-benchmark"
11
+ gem "rubocop"
12
+ gem "rubocop-rails"
13
+ gem "rubocop-performance"
14
+ gem "vcr"
15
+ gem "webmock"
data/README.adoc CHANGED
@@ -4,7 +4,17 @@ image:https://github.com/fontist/fontist/actions/workflows/test-and-release.yml/
4
4
  image:https://img.shields.io/gem/v/fontist.svg["Gem Version", link="https://rubygems.org/gems/fontist"]
5
5
  image:https://img.shields.io/github/issues-pr-raw/fontist/fontist.svg["Pull Requests", link="https://github.com/fontist/fontist/pulls"]
6
6
 
7
- A simple library to find and download fonts for Windows, Linux and Mac.
7
+ Fontist lets you find and download fonts for Windows, Linux and Mac.
8
+
9
+ Fontist is designed to facilitate automated and unattended management of font
10
+ installations on modern operating systems.
11
+
12
+ Fontist provides a repository of open
13
+ https://github.com/fontist/formulas[Fontist Formulas] that can be easily
14
+ installed, and also supports private font formula repositories for private or
15
+ licensed commercial fonts.
16
+
17
+ Learn more (and find your font) at https://www.fontist.org[fontist.org].
8
18
 
9
19
  :toc:
10
20
 
@@ -468,8 +478,8 @@ styles. You can do that by using:
468
478
  Fontist::Font.all
469
479
  ----
470
480
 
471
- The return values are `OpenStruct` objects, so you can easily do any other
472
- operation you would do in any ruby object.
481
+ The return values are model objects, so you can easily access their properties
482
+ and perform operations on them.
473
483
 
474
484
  === `Fontist::Formula`
475
485
 
@@ -518,8 +528,8 @@ what type fonts can be installed using that formula. Usages:
518
528
  Fontist::Formula.all
519
529
  ----
520
530
 
521
- The return values are `OpenStruct` objects, so you can easily do any other
522
- operation you would do in any ruby object.
531
+ The return values are model objects, so you can easily access their properties
532
+ and perform operations on them.
523
533
 
524
534
  === `Fontist::Manifest`
525
535
 
@@ -534,7 +544,7 @@ Fontist.preferred_family = true
534
544
  ----
535
545
 
536
546
  [[fontist-locations]]
537
- ==== `Fontist::Manifest::Locations`
547
+ ==== Locations
538
548
 
539
549
  Fontist lets you find font locations from a defined manifest Hash in the
540
550
  following format:
@@ -552,7 +562,7 @@ Font name is useful to choose a specific font in a font collection file (TTC).
552
562
 
553
563
  [source,ruby]
554
564
  ----
555
- Fontist::Manifest::Locations.from_hash(manifest)
565
+ Fontist::Manifest.from_hash(manifest, locations: true)
556
566
  ----
557
567
 
558
568
  [source,ruby]
@@ -578,14 +588,14 @@ Fontist::Manifest::Locations.from_hash(manifest)
578
588
  ----
579
589
 
580
590
  [[fontist-install]]
581
- ==== `Fontist::Manifest::Install`
591
+ ==== Install
582
592
 
583
593
  Fontist lets you not only to obtain font locations but also to install fonts
584
594
  from the manifest:
585
595
 
586
596
  [source,ruby]
587
597
  ----
588
- Fontist::Manifest::Install.from_hash(manifest, confirmation: "yes")
598
+ manifest.install(confirmation: "yes")
589
599
  ----
590
600
 
591
601
  It will install fonts and return their locations:
@@ -631,8 +641,8 @@ Then the following calls would return font names and paths, as from the
631
641
 
632
642
  [source,ruby]
633
643
  ----
634
- Fontist::Manifest::Locations.from_file("manifest.yml")
635
- Fontist::Manifest::Install.from_file("manifest.yml", confirmation: "yes")
644
+ manifest = Fontist::Manifest.from_file("manifest.yml")
645
+ manifest.install(confirmation: "yes")
636
646
  ----
637
647
 
638
648
  === `Fontist::Fontconfig`
@@ -916,6 +926,62 @@ fontist create-formula https://www.latofonts.com/files/Lato2OFL.zip
916
926
  cp lato.yml ~/.fontist/formulas/Formulas/
917
927
  ----
918
928
 
929
+ ==== Options for `create-formula`
930
+
931
+ The `create-formula` command supports several options to customize formula generation:
932
+
933
+ `--name`::
934
+ Specify a custom formula name instead of auto-detecting from fonts.
935
+ +
936
+ [source,sh]
937
+ ----
938
+ fontist create-formula https://example.com/fonts.zip --name "My Custom Fonts"
939
+ ----
940
+
941
+ `--subdir`::
942
+ Extract fonts only from a specific subdirectory within the archive.
943
+ Uses `fnmatch` patterns.
944
+ +
945
+ [source,sh]
946
+ ----
947
+ fontist create-formula https://example.com/fonts.zip --subdir "fonts/otf"
948
+ ----
949
+
950
+ `--file-pattern`::
951
+ Filter font files by pattern. Uses `fnmatch` patterns.
952
+ +
953
+ [source,sh]
954
+ ----
955
+ fontist create-formula https://example.com/fonts.zip --file-pattern "*.otf"
956
+ ----
957
+
958
+ `--name-prefix`::
959
+ Add a prefix to all font family names in the generated formula. This is useful
960
+ for distinguishing compatibility or replacement fonts from original proprietary
961
+ fonts.
962
+ +
963
+ [source,sh]
964
+ ----
965
+ fontist create-formula https://dl.winehq.org/wine/source/10.x/wine-10.18.tar.xz \
966
+ --subdir fonts \
967
+ --file-pattern '*.ttf' \
968
+ --name-prefix 'Wine '
969
+ ----
970
+ +
971
+ This will generate a formula where all fonts have names prefixed with `"Wine "`,
972
+ such as "Wine Courier", "Wine Tahoma", "Wine Symbol", etc., making it clear
973
+ these are Wine compatibility fonts rather than the original Microsoft fonts.
974
+
975
+ `--mirror`::
976
+ Specify mirror URLs for the font archive (can be used multiple times).
977
+ +
978
+ [source,sh]
979
+ ----
980
+ fontist create-formula https://example.com/fonts.zip \
981
+ --mirror https://mirror1.example.com/fonts.zip \
982
+ --mirror https://mirror2.example.com/fonts.zip
983
+ ----
984
+
919
985
 
920
986
  ==== Overriding font metadata in Fontist formulas
921
987
 
@@ -45,7 +45,7 @@ This might be useful if you want to know the name of the font or the available s
45
45
  Fontist::Font.all
46
46
  ```
47
47
 
48
- The return values are `OpenStruct` objects, so you can easily do any other operation you would do in any Ruby object.
48
+ The return values are model objects, so you can easily access their properties and perform operations on them.
49
49
 
50
50
  ## Fontist::Formula
51
51
 
@@ -79,7 +79,7 @@ The `Fontist::Formula` interface exposes an interface to list all registered fon
79
79
  Fontist::Formula.all
80
80
  ```
81
81
 
82
- The return values are `OpenStruct` objects, so you can easily do any other operation you would do in any Ruby object.
82
+ The return values are model objects, so you can easily access their properties and perform operations on them.
83
83
 
84
84
  ## Fontist::Manifest
85
85
 
@@ -91,7 +91,7 @@ Fontist can be switched to use the preferred family names. This format was used
91
91
  Fontist.preferred_family = true
92
92
  ```
93
93
 
94
- ### Fontist::Manifest::Locations
94
+ ### Manifest from YAML file or Hash
95
95
 
96
96
  Fontist lets you find font locations from a defined manifest Hash in the following format:
97
97
 
@@ -105,7 +105,8 @@ Fontist lets you find font locations from a defined manifest Hash in the followi
105
105
  Calling the following code returns a nested Hash with font paths and names. Font name is useful to choose a specific font in a font collection file (TTC).
106
106
 
107
107
  ```ruby
108
- Fontist::Manifest::Locations.from_hash(manifest)
108
+ Fontist::Manifest.from_yaml(manifest)
109
+ Fontist::Manifest.from_hash(manifest)
109
110
  ```
110
111
 
111
112
  ```ruby
@@ -129,12 +130,10 @@ Fontist::Manifest::Locations.from_hash(manifest)
129
130
  }
130
131
  ```
131
132
 
132
- ### Fontist::Manifest::Install
133
-
134
133
  Fontist lets you not only obtain font locations but also install fonts from the manifest:
135
134
 
136
135
  ```ruby
137
- Fontist::Manifest::Install.from_hash(manifest, confirmation: "yes")
136
+ manifest.install(confirmation: "yes")
138
137
  ```
139
138
 
140
139
  It will install fonts and return their locations:
@@ -159,7 +158,7 @@ It will install fonts and return their locations:
159
158
  }
160
159
  ```
161
160
 
162
- ### Support of YAML format
161
+ #### Support of YAML format
163
162
 
164
163
  Both commands support a YAML file as an input with a `from_file` method. For example, if there is a `manifest.yml` file containing:
165
164
 
@@ -172,11 +171,11 @@ Roboto Mono:
172
171
  - Regular
173
172
  ```
174
173
 
175
- Then the following calls would return font names and paths, as from the `from_hash` method (see Fontist::Manifest::Install and Fontist::Manifest::Locations).
174
+ Then the following calls would return font names and paths, as from the `from_hash` method (see Fontist::Manifest).
176
175
 
177
176
  ```ruby
178
- Fontist::Manifest::Locations.from_file("manifest.yml")
179
- Fontist::Manifest::Install.from_file("manifest.yml", confirmation: "yes")
177
+ manifest = Fontist::Manifest.from_file("manifest.yml")
178
+ manifest.install(confirmation: "yes")
180
179
  ```
181
180
 
182
181
  ## Fontist::Fontconfig
data/fontist.gemspec CHANGED
@@ -29,28 +29,18 @@ Gem::Specification.new do |spec|
29
29
  spec.executables = ["fontist"]
30
30
  spec.test_files = `git ls-files -- {spec}/*`.split("\n")
31
31
 
32
- spec.add_runtime_dependency "down", "~> 5.0"
33
- spec.add_runtime_dependency "extract_ttc", "~> 0.1"
34
- spec.add_runtime_dependency "fuzzy_match", "~> 2.1"
35
- spec.add_runtime_dependency "json", "~> 2.0"
36
- spec.add_runtime_dependency "nokogiri", "~> 1.0"
37
- spec.add_runtime_dependency "mime-types", "~> 3.0"
38
- spec.add_runtime_dependency "sys-uname", "~> 1.2"
39
- spec.add_runtime_dependency "thor", "~> 1.2", ">= 1.2.1"
40
- spec.add_runtime_dependency "git", "~> 1.0"
41
- spec.add_runtime_dependency "ttfunk", "~> 1.6"
42
- spec.add_runtime_dependency "plist", "~> 3.0"
43
- spec.add_runtime_dependency "excavate", "~> 0.3", '>= 0.3.4'
44
- spec.add_runtime_dependency "socksify", "~> 1.7"
45
-
46
- spec.add_development_dependency "pry", "~> 0.14"
47
- spec.add_development_dependency "bundler", "~> 2.3"
48
- spec.add_development_dependency "rake", "~> 13"
49
- spec.add_development_dependency "rspec", "~> 3.0"
50
- spec.add_development_dependency "rspec-benchmark", "~> 0.6"
51
- spec.add_development_dependency "rubocop", "~> 1.22.1"
52
- spec.add_development_dependency "rubocop-rails", "~> 2.9"
53
- spec.add_development_dependency "rubocop-performance", "~> 1.10"
54
- spec.add_development_dependency "vcr"
55
- spec.add_development_dependency "webmock"
32
+ spec.add_dependency "down", "~> 5.0"
33
+ spec.add_dependency "extract_ttc", "~> 0.3.7"
34
+ spec.add_dependency "fuzzy_match", "~> 2.1"
35
+ spec.add_dependency "json", "~> 2.0"
36
+ spec.add_dependency "nokogiri", "~> 1.0"
37
+ spec.add_dependency "mime-types", "~> 3.0"
38
+ spec.add_dependency "sys-uname", "~> 1.2"
39
+ spec.add_dependency "thor", "~> 1.4"
40
+ spec.add_dependency "git", "~> 1.0"
41
+ spec.add_dependency "ttfunk", "~> 1.6"
42
+ spec.add_dependency "plist", "~> 3.0"
43
+ spec.add_dependency "excavate", "~> 0.3", '>= 0.3.8'
44
+ spec.add_dependency "socksify", "~> 1.7"
45
+ spec.add_dependency "lutaml-model", "~> 0.7"
56
46
  end