fontist 1.14.5 → 1.15.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c68fb06c5de27009bdfe263acef48958d5ec89d8599ab410e11781b24f582070
4
- data.tar.gz: 11b4b0d923fd4cb2c80723fc6d222b3ee67bf83f496cda0ec1348382563b33ff
3
+ metadata.gz: 8ef3c1df1ab7760fa50abdca9dc9c760d7f953dfc209f3841a8c01b9297760e9
4
+ data.tar.gz: b6e32f79b2cdeb3af88ec2ae3bdbf9ad767f41d3721dcfa2991f670e74ceaade
5
5
  SHA512:
6
- metadata.gz: ba79faf4ab79d0f61b45139b2d2b377aac6c05568a776c8a9066ce22ce888ad3c5ccac29d4a7c70edfaee0a864563f2d0d09951ca888e05b2413975375c64893
7
- data.tar.gz: 47be34621947a7bb5a0cb0ffe2a60c997049887329aa1d2a86dc12443139034f9d1ec712531c01393f179ace16e083f1890e24eb549093c3bedd8e724ad3e4b0
6
+ metadata.gz: bb6f7c6325ba122a79e6713b642dd6ca4967f6622f013dc1c56b41a03e0228da6e5a7e3707211dd293d78d9a3e4a07eec7edc545710f9b322c45f0f7b4c0e7e1
7
+ data.tar.gz: 2e42062f05fa332dcea0b93fde315db285c8d5894f029e85fdcfcda9f3f57eeed60dc55ed816cb33405c80581a7b313e15cb44e2c13eedafab1d011043b20336
@@ -10,30 +10,44 @@ concurrency:
10
10
  group: '${{ github.workflow }}-${{ github.job }}-${{ github.head_ref || github.ref_name }}'
11
11
  cancel-in-progress: true
12
12
 
13
+ env:
14
+ BUNDLER_VER: 2.3.24
15
+ # Forcing bundler version to ensure that it is consistent everywhere and
16
+ # does not cause bundler gem reinstalls
17
+ # bundler/rubygems 2.3.22 is a minimal requirement to support gnu/musl differentiation
18
+ # https://github.com/rubygems/rubygems/pull/4488
19
+
13
20
  jobs:
21
+ prepare:
22
+ uses: metanorma/ci/.github/workflows/prepare-rake.yml@main
23
+
14
24
  test:
15
- name: Test on Ruby ${{ matrix.ruby }} ${{ matrix.os }}
25
+ name: Test on Ruby ${{ matrix.ruby.version }} ${{ matrix.os }}
16
26
  runs-on: ${{ matrix.os }}
17
- continue-on-error: false
27
+
28
+ needs: prepare
29
+ if: needs.prepare.outputs.push-for-tag != 'true'
30
+
31
+ continue-on-error: ${{ matrix.ruby.experimental }}
18
32
  strategy:
19
33
  fail-fast: false
20
- matrix:
21
- ruby: [ '2.6', '2.7', '3.0', '3.1' ]
22
- os: [ ubuntu-18.04, ubuntu-latest, windows-latest, macos-latest ]
34
+ max-parallel: 5
35
+ matrix: ${{ fromJson(needs.prepare.outputs.matrix) }}
23
36
 
24
37
  steps:
25
38
  - uses: actions/checkout@v3
26
39
 
27
40
  - uses: ruby/setup-ruby@v1
28
41
  with:
29
- ruby-version: ${{ matrix.ruby }}
42
+ ruby-version: ${{ matrix.ruby.version }}
43
+ rubygems: ${{ matrix.ruby.rubygems }}
44
+ bundler: ${{ env.BUNDLER_VER }}
30
45
  bundler-cache: true
31
46
 
32
47
  - if: matrix.os == 'macos-latest'
33
- run: brew install lcdf-typetools
34
-
35
- - if: matrix.os == 'macos-latest'
36
- run: bundle exec rspec
48
+ run: |
49
+ brew install lcdf-typetools
50
+ bundle exec rspec
37
51
  env:
38
52
  TEST_ENV: CI
39
53
 
@@ -47,7 +61,6 @@ jobs:
47
61
  runs-on: ubuntu-latest
48
62
  container:
49
63
  image: 'archlinux:latest'
50
- continue-on-error: false
51
64
  strategy:
52
65
  fail-fast: false
53
66
 
@@ -62,14 +75,55 @@ jobs:
62
75
  - name: Test
63
76
  run: bundle exec rspec --tag ~dev
64
77
 
78
+ metanorma:
79
+ name: Test metanorma on Ruby ${{ matrix.ruby.version }} ${{ matrix.os }}
80
+ runs-on: ${{ matrix.os }}
81
+
82
+ needs: prepare
83
+ if: needs.prepare.outputs.push-for-tag != 'true'
84
+
85
+ continue-on-error: ${{ matrix.ruby.experimental }}
86
+ strategy:
87
+ fail-fast: false
88
+ max-parallel: 5
89
+ matrix: ${{ fromJson(needs.prepare.outputs.matrix) }}
90
+
91
+ steps:
92
+ - uses: actions/checkout@v3
93
+ with:
94
+ repository: metanorma/metanorma
95
+
96
+ - uses: actions/checkout@master
97
+ with:
98
+ path: "fontist"
99
+
100
+ - run: 'echo ''gem "fontist", path: "./fontist"'' > Gemfile.devel'
101
+
102
+ - uses: ruby/setup-ruby@v1
103
+ with:
104
+ ruby-version: ${{ matrix.ruby.version }}
105
+ rubygems: ${{ matrix.ruby.rubygems }}
106
+ bundler: ${{ env.BUNDLER_VER }}
107
+ bundler-cache: true
108
+
109
+ - uses: metanorma/metanorma-build-scripts/inkscape-setup-action@main
110
+
111
+ - run: bundle exec rake
112
+
65
113
  release:
66
114
  name: Release gem
67
- needs: [ test, archlinux-test ]
115
+ needs: [ test, archlinux-test, metanorma ]
68
116
  runs-on: ubuntu-latest
69
117
  if: contains(github.ref, 'refs/tags/v')
70
118
  steps:
71
119
  - uses: actions/checkout@v3
72
120
 
73
- - uses: cadwallion/publish-rubygems-action@master
74
- env:
75
- RUBYGEMS_API_KEY: ${{secrets.FONTIST_CI_RUBYGEMS_API_KEY}}
121
+ - uses: ruby/setup-ruby@v1
122
+ with:
123
+ ruby-version: 3.1
124
+ bundler-cache: true
125
+
126
+ - uses: actions-mn/gem-release@main
127
+ with:
128
+ api-key: ${{ secrets.FONTIST_CI_RUBYGEMS_API_KEY }}
129
+ release-command: bundle exec rake release
data/.rubocop.yml CHANGED
@@ -2,4 +2,5 @@ inherit_from:
2
2
  - 'https://raw.githubusercontent.com/fontist/oss-guides/master/ci/rubocop.yml'
3
3
 
4
4
  AllCops:
5
+ TargetRubyVersion: 2.7
5
6
  SuggestExtensions: false
data/README.adoc CHANGED
@@ -6,6 +6,8 @@ image:https://img.shields.io/github/issues-pr-raw/fontist/fontist.svg["Pull Requ
6
6
 
7
7
  A simple library to find and download fonts for Windows, Linux and Mac.
8
8
 
9
+ :toc:
10
+
9
11
  == Installation
10
12
 
11
13
  Install it directly as:
@@ -52,7 +54,7 @@ has the following requirements:
52
54
  These dependencies are generally present on all systems.
53
55
 
54
56
 
55
- == Usage of the Fontist command-line interface
57
+ == Using the command-line interface (CLI)
56
58
 
57
59
  === The `fontist` command
58
60
 
@@ -192,8 +194,8 @@ segoe_ui
192
194
  $ fontist list "roboto mono"
193
195
  google/roboto_mono
194
196
  Roboto Mono
195
- Regular (uninstalled)
196
- Italic (uninstalled)
197
+ Regular (not installed)
198
+ Italic (not installed)
197
199
  ----
198
200
 
199
201
  === List installed font paths: `fontist manifest-locations`
@@ -311,6 +313,15 @@ To remove it, please use:
311
313
  $ fontist fontconfig remove
312
314
  ----
313
315
 
316
+ === Work with cache
317
+
318
+ [source,sh]
319
+ ----
320
+ $ fontist cache clear
321
+ ----
322
+
323
+ The command above will clear fontist's download cache
324
+
314
325
  === Help: `fontist help`
315
326
 
316
327
  List of all commands could be seen by:
@@ -331,7 +342,7 @@ FONTIST_PATH=~/.fontist_new fontist update
331
342
  ----
332
343
 
333
344
 
334
- == Usage of the Fontist Ruby library
345
+ == Using the Ruby library
335
346
 
336
347
  === `Fontist::Font`
337
348
 
@@ -565,13 +576,23 @@ Fontist::Fontconfig.remove # disable detection
565
576
  Fontist::Fontconfig.remove(force: true) # do not fail if no config exists
566
577
  ----
567
578
 
568
- == Installing macOS-specific add-on fonts
569
579
 
570
- The purpose of Fontist allowing macOS-specific add-on fonts is to allow CI jobs
571
- on macOS environments to use these specially licensed fonts that are not
572
- available on other platforms.
580
+ == Platform-specific features
581
+
582
+ === macOS-specific add-on fonts
583
+
584
+ Newer versions of macOS provide on-demand installations of a wide range of
585
+ licensed fonts. These macOS-specific add-on fonts can be installed via Fontist.
586
+
587
+ A typical use for installing macOS add-on fonts is to allow CI jobs on
588
+ macOS environments to use these specially-licensed fonts not available on other
589
+ platforms.
590
+
591
+ This blog post describes how this works:
592
+
593
+ * https://www.fontist.org/blog/2022-02-11-macos-fonts/[Fontist blog: Installing macOS-specific add-on fonts]
573
594
 
574
- The "Canela" font is a commercial font that comes free with macOS.
595
+ For example, the "Canela" font is a commercial font that comes free with macOS.
575
596
 
576
597
  Run this command to install Canela on macOS.
577
598
 
@@ -580,10 +601,20 @@ Run this command to install Canela on macOS.
580
601
  $ fontist install Canela
581
602
  ----
582
603
 
604
+ The full list of available fonts on various macOS versions can be found on the
605
+ Apple Support site:
606
+
607
+ * https://support.apple.com/en-us/HT213266[Fonts in macOS 13 Ventura]
608
+ * https://support.apple.com/en-us/HT212587[Fonts in macOS 12 Monteray]
609
+ * https://support.apple.com/en-in/HT211240[Fonts in macOS 11 Big Sur]
610
+
583
611
  WARNING: Fontist does not allow installing macOS-specific fonts on non-macOS
584
- platforms due to font licensing of those fonts.
612
+ platforms due to font license restrictions of those fonts.
613
+
585
614
 
586
- == Using Fontist with proxy servers
615
+ == Advanced usage
616
+
617
+ === Using proxy servers
587
618
 
588
619
  Fontist uses Git internally for fetching formulas and fonts.
589
620
 
@@ -640,33 +671,36 @@ https://github.com/evantoli[evantoli]).
640
671
 
641
672
 
642
673
 
643
- == Authoring Fontist formulas
644
-
645
- === Private Fontist formulas and font repositories
674
+ == Custom Fontist repositories
646
675
 
647
- Fontist supports installing private fonts via private Fontist repositories.
676
+ === General
648
677
 
649
678
  A Fontist repository is a Git repo which contains YAML Formula files.
650
- Formulas can be created manually
679
+ Fontist Formulas can be created manually within a Fontist repository
651
680
  (see https://github.com/fontist/formulas/tree/master/Formulas[examples]),
652
- or <<create-formula,auto-generated from an archive>>.
681
+ or <<create-formula,auto-generated from a font archive>>.
653
682
 
654
- A repository can be either a HTTPS or SSH Git repo. In case of SSH, a
655
- corresponding SSH key should be setup with `ssh-agent` in order to access this
656
- private repository.
683
+ A Fontist repository can be accessed either through HTTPS or SSH. In case of
684
+ SSH, a corresponding SSH key should be setup with `ssh-agent` in order to access
685
+ this custom repository.
657
686
 
658
- The `fontist repo setup` command fetches a repository's formulas, and saves the
659
- repository's name and URL for later use.
687
+ === Registering a Fontist repository
660
688
 
661
- Internally, all repositories are stored at
662
- `~/.fontist/formulas/Formulas/private`.
689
+ The `fontist repo setup` command fetches a custom repository's formulas, and
690
+ stores the repository's name and URL for later use.
691
+
692
+ The `fontist repo setup` command uses the following syntax.
663
693
 
664
694
  [source,sh]
665
695
  ----
666
696
  fontist repo setup NAME URL
667
697
  ----
668
698
 
669
- E.g.
699
+ Internally, all custom Fontist repository information is stored at
700
+ `~/.fontist/formulas/Formulas/private`.
701
+
702
+ For example, given a Fontist repository called "acme" accessible via a
703
+ URL or an SSH address:
670
704
 
671
705
  [source,sh]
672
706
  ----
@@ -675,41 +709,64 @@ fontist repo setup acme https://example.com/acme/formulas.git
675
709
  fontist repo setup acme git@example.com:acme/formulas.git
676
710
  ----
677
711
 
678
- Then you can just install fonts from this repo:
712
+
713
+ === Listing custom Fontist repositories
714
+
715
+ [source,sh]
716
+ ----
717
+ fontist repo list
718
+ ----
719
+
720
+
721
+ === Installing fonts from a Fontist repository
722
+
723
+ Once the custom Fontist repository is setup, one can install fonts from the
724
+ repo through its formulas:
679
725
 
680
726
  [source,sh]
681
727
  ----
682
- fontist install "private font"
728
+ fontist install "custom font"
683
729
  ----
684
730
 
685
- If the private Fontist formula repository is updated, you can fetch the updates
686
- with the `repo update` command:
731
+
732
+ === Updating a registered Fontist repository
733
+
734
+ If the custom Fontist formula repository is updated, the `repo update` command
735
+ is used to pull the newest changes:
687
736
 
688
737
  [source,sh]
689
738
  ----
690
- fontist repo update acme
739
+ fontist repo update NAME
691
740
  ----
692
741
 
693
- If there is a need to avoid using private formulas, the repo can be removed
694
- with:
742
+ For example, given a Fontist repository called "acme", the following command
743
+ is used.
695
744
 
696
745
  [source,sh]
697
746
  ----
698
- fontist repo remove acme
747
+ fontist repo update acme
699
748
  ----
700
749
 
701
- [[create-formula]]
702
- === Auto-generate a Fontist formula from a font archive
703
750
 
704
- A formula could be generated from a fonts archive. Just specify a URL to the
705
- archive:
751
+ === Removing a registered Fontist repository
752
+
753
+ If there is a need to remove a registered Fontist repository, the repo can be
754
+ removed with:
706
755
 
707
756
  [source,sh]
708
757
  ----
709
- fontist create-formula https://www.latofonts.com/download/lato2ofl-zip/
710
- cp lato.yml ~/.fontist/formulas/Formulas/
758
+ fontist repo remove acme
711
759
  ----
712
760
 
761
+
762
+ === Private access
763
+
764
+ Custom Fontist formulas and Fontist repositories can be made private to require
765
+ authentication.
766
+
767
+ For HTTPS and SSH Git Fontist repositories
768
+
769
+
713
770
  === Authentication for private formulas or private formula repositories
714
771
 
715
772
  Authorization of private archives in private formulas can be implemented with
@@ -728,11 +785,129 @@ resources:
728
785
  Authorization: token ghp_1234567890abcdefghi
729
786
  ----
730
787
 
731
- A token can be obtained on the
732
- https://github.com/settings/tokens[GitHub Settings > Tokens page].
788
+ If the Fontist formula repository is a GitHub repo, a token can be obtained on
789
+ the https://github.com/settings/tokens[GitHub Settings > Tokens page].
733
790
  This token should have at least the `repo` scope for access to these assets.
734
791
 
735
792
 
793
+
794
+ [[create-formula]]
795
+ === Create Fontist formulas
796
+
797
+ ==== General
798
+
799
+ Fontist formulas can be easily hand-crafted in YAML. However, the
800
+ auto-generation method is recommended for data accuracy and convenience.
801
+
802
+
803
+ ==== Auto-generate a Fontist formula from a font archive
804
+
805
+ A formula could be generated from a fonts archive.
806
+
807
+ The `fontist create-formula` command allows detecting all font files from a
808
+ font archive in a multitude of formats (those supported by
809
+ https://github.com/fontist/excavate[Excavate], including zip, 7z, gzip, tar,
810
+ cab, exe).
811
+
812
+ The `fontist create-formula` command supports archives located at remote URLs or
813
+ local file paths.
814
+
815
+ For file paths, specify the file path as argument:
816
+
817
+ [source,sh]
818
+ ----
819
+ wget https://www.latofonts.com/download/lato2ofl-zip/
820
+ fontist create-formula lato.zip
821
+ ----
822
+
823
+ For URLs, simply specify the URL as the argument:
824
+
825
+ [source,sh]
826
+ ----
827
+ fontist create-formula https://www.latofonts.com/download/lato2ofl-zip/
828
+ # > file created at lato.yml because the file downloaded is lato.zip
829
+ ----
830
+
831
+ To test out the created formula, one may copy the formula into the user's
832
+ private formula repository location.
833
+
834
+ [source,sh]
835
+ ----
836
+ fontist create-formula https://www.latofonts.com/download/lato2ofl-zip/
837
+ cp lato.yml ~/.fontist/formulas/Formulas/
838
+ ----
839
+
840
+
841
+ ==== Overriding font metadata in Fontist formulas
842
+
843
+ The `fontist create-formula` command creates font formulas using information
844
+ embedded in the OTF metadata section.
845
+
846
+ However, some fonts (such as older fonts) often contain inconsistent or
847
+ imperfect metadata information. Some fonts for example applies different OTF
848
+ `Family` values for different font styles. This will result in all font styles
849
+ not being registered in the same Family.
850
+
851
+ Fontist formula authors can rectify this situation by using the `override:` key,
852
+ which allows the formula to override metadata information obtained from the font
853
+ metadata.
854
+
855
+ NOTE: The `override` key does not cause any change in the font files, it is only
856
+ for updating information used by Fontist internally.
857
+
858
+ The `override` key exists under the definition of individual font styles:
859
+
860
+ [source,yaml]
861
+ ----
862
+ resources:
863
+ ...
864
+ fonts:
865
+ - name: Original font name
866
+ styles:
867
+ - family_name: Original family name
868
+ type: Original style
869
+ override:
870
+ family_name: Overridden family name
871
+ type: Overridden style
872
+ preferred_family_name: Overridden preferred family name
873
+ ----
874
+
875
+ For example, the "Frutiger" fonts published by Adobe in 1994 use numbers to
876
+ represent the individual font styles, and have those names embedded in the OTF
877
+ `Family` field, such as "Frutiger 45 Light". These fonts also do not use the OTF
878
+ `Preferred Family` field, which is a more recent addition to OTF, due to their
879
+ age.
880
+
881
+ Here is how the `override` property can enforce all relevant styles to be
882
+ registered under the same family name (by overriding the `preferred_family_name`
883
+ value):
884
+
885
+ [source,yaml]
886
+ ----
887
+ ...
888
+ resources:
889
+ ...
890
+ fonts:
891
+ - name: Frutiger 45 Light
892
+ styles:
893
+ - family_name: Frutiger 45 Light
894
+ type: Regular
895
+ full_name: Frutiger-Light
896
+ post_script_name: Frutiger-Light
897
+ override:
898
+ preferred_family_name: Frutiger
899
+ - ...
900
+ ----
901
+
902
+ This fragment above will allow Fontist to generate correct indexes and allow
903
+ installation of all `Frutiger` fonts with a single command:
904
+
905
+ [source,sh]
906
+ ----
907
+ $ fontist install "Frutiger" --preferred-family
908
+ ----
909
+
910
+
736
911
  === Upgrading Fontist
737
912
 
738
913
  [[preferred-family-change]]
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
+ require "rubocop/rake_task"
3
4
 
4
5
  RSpec::Core::RakeTask.new(:spec)
6
+ RuboCop::RakeTask.new
5
7
 
6
- task :default => :spec
8
+ task default: %i[spec rubocop]
data/fontist.gemspec CHANGED
@@ -15,6 +15,8 @@ Gem::Specification.new do |spec|
15
15
 
16
16
  spec.post_install_message = "Please run `fontist update` to fetch formulas."
17
17
 
18
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
19
+
18
20
  spec.metadata["homepage_uri"] = spec.homepage
19
21
  spec.metadata["source_code_uri"] = "https://github.com/fontist/fontist"
20
22
  spec.metadata["changelog_uri"] = "https://github.com/fontist/fontist"
@@ -36,11 +38,11 @@ Gem::Specification.new do |spec|
36
38
  spec.add_runtime_dependency "git", "~> 1.0"
37
39
  spec.add_runtime_dependency "ttfunk", "~> 1.6"
38
40
  spec.add_runtime_dependency "plist", "~> 3.0"
39
- spec.add_runtime_dependency "excavate", "~> 0.3.1"
41
+ spec.add_runtime_dependency "excavate", "~> 0.3"
40
42
  spec.add_runtime_dependency "socksify", "~> 1.7"
41
43
 
42
44
  spec.add_development_dependency "pry", "~> 0.14"
43
- spec.add_development_dependency "bundler", "~> 2.0"
45
+ spec.add_development_dependency "bundler", "~> 2.3"
44
46
  spec.add_development_dependency "rake", "~> 13"
45
47
  spec.add_development_dependency "rspec", "~> 3.0"
46
48
  spec.add_development_dependency "rspec-benchmark", "~> 0.6"
@@ -0,0 +1,14 @@
1
+ module Fontist
2
+ class CacheCLI < Thor
3
+ include CLI::ClassOptions
4
+
5
+ desc "clear", "Clear fontist download cache"
6
+ def clear
7
+ handle_class_options(options)
8
+ dir = Fontist.downloads_path
9
+ dir.each_child(&:delete) if dir.exist?
10
+ Fontist.ui.success("Download cache has been successfully removed.")
11
+ CLI::STATUS_SUCCESS
12
+ end
13
+ end
14
+ end
data/lib/fontist/cli.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require "thor"
2
2
  require "fontist/cli/class_options"
3
3
  require "fontist/repo_cli"
4
+ require "fontist/cache_cli"
4
5
  require "fontist/import_cli"
5
6
  require "fontist/fontconfig_cli"
6
7
 
@@ -212,6 +213,9 @@ module Fontist
212
213
  desc "fontconfig SUBCOMMAND ...ARGS", "Manage fontconfig"
213
214
  subcommand "fontconfig", Fontist::FontconfigCLI
214
215
 
216
+ desc "cache SUBCOMMAND ...ARGS", "Manage fontist cache"
217
+ subcommand "cache", Fontist::CacheCLI
218
+
215
219
  private
216
220
 
217
221
  def success
@@ -253,7 +257,7 @@ module Fontist
253
257
  styles.each do |style, installed|
254
258
  opts = []
255
259
  opts << "manual" if formula.manual?
256
- opts << (installed ? "installed" : "uninstalled")
260
+ opts << (installed ? "installed" : "not installed")
257
261
  msg = " #{style.type} (#{opts.join(', ')})"
258
262
 
259
263
  if installed
@@ -52,6 +52,16 @@ module Fontist
52
52
  new_from_file(path)
53
53
  end
54
54
 
55
+ def self.find_by_font_file(font_file)
56
+ key = Indexes::FilenameIndex
57
+ .from_yaml
58
+ .load_index_formulas(File.basename(font_file))
59
+ .map(&:name)
60
+ .first
61
+
62
+ find_by_key(key)
63
+ end
64
+
55
65
  def self.new_from_file(path)
56
66
  data = YAML.load_file(path)
57
67
  new(data, path)
@@ -142,11 +152,19 @@ module Fontist
142
152
  @data["digest"]
143
153
  end
144
154
 
155
+ def style_override(font)
156
+ fonts
157
+ .map(&:styles)
158
+ .flatten
159
+ .detect { |s| s.family_name == font }
160
+ &.dig(:override) || {}
161
+ end
162
+
145
163
  private
146
164
 
147
165
  def key_from_path
148
- escaped = Regexp.escape(Fontist.formulas_path.to_s + "/")
149
- @path.sub(Regexp.new("^" + escaped), "").sub(/\.yml$/, "")
166
+ escaped = Regexp.escape("#{Fontist.formulas_path}/")
167
+ @path.sub(Regexp.new("^#{escaped}"), "").sub(/\.yml$/, "")
150
168
  end
151
169
 
152
170
  def fonts_by_family
@@ -3,7 +3,7 @@ module Fontist
3
3
  module Google
4
4
  def self.metadata_name(path)
5
5
  metadata_path = File.join(path, "METADATA.pb")
6
- return unless File.exists?(metadata_path)
6
+ return unless File.exist?(metadata_path)
7
7
 
8
8
  File.foreach(metadata_path) do |line|
9
9
  name = line.match(/^name: "(.+)"/)
data/lib/fontist/repo.rb CHANGED
@@ -60,7 +60,11 @@ module Fontist
60
60
  if Dir.exist?(path)
61
61
  Git.open(path).pull
62
62
  else
63
- Git.clone(url, path, depth: 1)
63
+ repo = Git.clone(url, path, depth: 1)
64
+ if repo.branches[:main].name != repo.current_branch
65
+ # https://github.com/ruby-git/ruby-git/issues/531
66
+ repo.checkout(:main).pull
67
+ end
64
68
  end
65
69
  end
66
70
 
@@ -12,6 +12,10 @@ module Fontist
12
12
  def type(name)
13
13
  name.font_subfamily
14
14
  end
15
+
16
+ def transform_override_keys(dict)
17
+ dict
18
+ end
15
19
  end
16
20
 
17
21
  class PreferredFamily
@@ -26,6 +30,11 @@ module Fontist
26
30
 
27
31
  name.preferred_subfamily
28
32
  end
33
+
34
+ def transform_override_keys(dict)
35
+ mapping = { preferred_family_name: :family_name, preferred_type: :type }
36
+ dict.transform_keys! { |k| mapping[k] }
37
+ end
29
38
  end
30
39
 
31
40
  PLATFORM_MACINTOSH = 1
@@ -37,6 +46,8 @@ module Fontist
37
46
  LANGUAGE_MAC_ENGLISH = 0
38
47
  LANGUAGE_MS_ENGLISH_AMERICAN = 0x409
39
48
 
49
+ ALLOWED_KEYS = %i[path full_name family_name type].freeze
50
+
40
51
  def self.system_index
41
52
  path = if Fontist.preferred_family?
42
53
  Fontist.system_preferred_family_index_path
@@ -121,8 +132,8 @@ module Fontist
121
132
  end
122
133
  end
123
134
 
124
- def changed?(this, other)
125
- this.map { |x| x[:path] }.uniq.sort != other.map { |x| x[:path] }.uniq.sort
135
+ def changed?(this, that)
136
+ this.map { |x| x[:path] }.uniq.sort != that.map { |x| x[:path] }.uniq.sort
126
137
  end
127
138
 
128
139
  def load_index
@@ -133,7 +144,7 @@ module Fontist
133
144
 
134
145
  def check_index(index)
135
146
  index.each do |item|
136
- missing_keys = %i[path full_name family_name type] - item.keys
147
+ missing_keys = ALLOWED_KEYS - item.keys
137
148
  unless missing_keys.empty?
138
149
  raise(Errors::FontIndexCorrupted, <<~MSG.chomp)
139
150
  Font index is corrupted.
@@ -164,10 +175,10 @@ module Fontist
164
175
  raise Errors::UnknownFontTypeError.new(path)
165
176
  end
166
177
  rescue StandardError
167
- Fontist.ui.error($!.message)
168
- Fontist.ui.error(
169
- "Warning: File at #{path} not recognized as a font file.",
170
- )
178
+ Fontist.ui.error(<<~MSG.chomp)
179
+ #{$!.message}
180
+ Warning: File at #{path} not recognized as a font file.
181
+ MSG
171
182
  end
172
183
 
173
184
  def detect_file_font(path)
@@ -187,13 +198,14 @@ module Fontist
187
198
 
188
199
  def parse_font(file, path)
189
200
  x = file.name
201
+ family_name = english_name(@family.family_name(x))
190
202
 
191
203
  {
192
204
  path: path,
193
205
  full_name: english_name(x.font_name),
194
- family_name: english_name(@family.family_name(x)),
206
+ family_name: family_name,
195
207
  type: english_name(@family.type(x)),
196
- }
208
+ }.merge(override_font_props(path, family_name))
197
209
  end
198
210
 
199
211
  def english_name(name)
@@ -222,9 +234,17 @@ module Fontist
222
234
  text.gsub(/[^[:print:]]/, "").to_s
223
235
  end
224
236
 
237
+ def override_font_props(path, font_name)
238
+ override = Formula.find_by_font_file(path)
239
+ &.style_override(font_name)&.to_h || {}
240
+
241
+ @family.transform_override_keys(override)
242
+ .slice(*ALLOWED_KEYS)
243
+ end
244
+
225
245
  def save_index(index)
226
246
  dir = File.dirname(@index_path)
227
- FileUtils.mkdir_p(dir) unless File.exist?(dir)
247
+ FileUtils.mkdir_p(dir)
228
248
  File.write(@index_path, YAML.dump(index))
229
249
  end
230
250
  end
@@ -1,3 +1,3 @@
1
1
  module Fontist
2
- VERSION = "1.14.5".freeze
2
+ VERSION = "1.15.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fontist
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.14.5
4
+ version: 1.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-26 00:00:00.000000000 Z
11
+ date: 2023-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: down
@@ -142,14 +142,14 @@ dependencies:
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 0.3.1
145
+ version: '0.3'
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: 0.3.1
152
+ version: '0.3'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: socksify
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -184,14 +184,14 @@ dependencies:
184
184
  requirements:
185
185
  - - "~>"
186
186
  - !ruby/object:Gem::Version
187
- version: '2.0'
187
+ version: '2.3'
188
188
  type: :development
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
192
  - - "~>"
193
193
  - !ruby/object:Gem::Version
194
- version: '2.0'
194
+ version: '2.3'
195
195
  - !ruby/object:Gem::Dependency
196
196
  name: rake
197
197
  requirement: !ruby/object:Gem::Requirement
@@ -284,7 +284,6 @@ executables:
284
284
  extensions: []
285
285
  extra_rdoc_files: []
286
286
  files:
287
- - ".github/workflows/metanorma.yml"
288
287
  - ".github/workflows/test-and-release.yml"
289
288
  - ".gitignore"
290
289
  - ".hound.yml"
@@ -297,6 +296,7 @@ files:
297
296
  - exe/fontist
298
297
  - fontist.gemspec
299
298
  - lib/fontist.rb
299
+ - lib/fontist/cache_cli.rb
300
300
  - lib/fontist/cli.rb
301
301
  - lib/fontist/cli/class_options.rb
302
302
  - lib/fontist/errors.rb
@@ -376,14 +376,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
376
376
  requirements:
377
377
  - - ">="
378
378
  - !ruby/object:Gem::Version
379
- version: '0'
379
+ version: 2.7.0
380
380
  required_rubygems_version: !ruby/object:Gem::Requirement
381
381
  requirements:
382
382
  - - ">="
383
383
  - !ruby/object:Gem::Version
384
384
  version: '0'
385
385
  requirements: []
386
- rubygems_version: 3.3.7
386
+ rubygems_version: 3.3.26
387
387
  signing_key:
388
388
  specification_version: 4
389
389
  summary: Install openly-licensed fonts on Windows, Linux and Mac!
@@ -1,49 +0,0 @@
1
- name: metanorma
2
-
3
- on:
4
- push:
5
- branches: [ main ]
6
- pull_request:
7
-
8
- concurrency:
9
- group: '${{ github.workflow }}-${{ github.job }}-${{ github.head_ref || github.ref_name }}'
10
- cancel-in-progress: true
11
-
12
- jobs:
13
- test:
14
- name: Test on Ruby ${{ matrix.ruby }} ${{ matrix.os }}
15
- runs-on: ${{ matrix.os }}
16
- continue-on-error: ${{ matrix.experimental }}
17
- strategy:
18
- fail-fast: false
19
- matrix:
20
- ruby: [ '2.7', '3.0', '3.1' ]
21
- os: [ ubuntu-latest, windows-latest, macos-latest ]
22
- experimental: [ true ]
23
- steps:
24
- - uses: actions/checkout@v3
25
- with:
26
- repository: metanorma/metanorma
27
-
28
- - uses: actions/checkout@master
29
- with:
30
- path: "fontist"
31
-
32
- - run: 'echo ''gem "fontist", path: "./fontist"'' > Gemfile.devel'
33
-
34
- - if: matrix.ruby == '3.0'
35
- uses: ruby/setup-ruby@v1
36
- with:
37
- ruby-version: ${{ matrix.ruby }}
38
- bundler-cache: true
39
- rubygems: latest
40
-
41
- - if: matrix.ruby != '3.0'
42
- uses: ruby/setup-ruby@v1
43
- with:
44
- ruby-version: ${{ matrix.ruby }}
45
- bundler-cache: true
46
-
47
- - uses: metanorma/metanorma-build-scripts/inkscape-setup-action@main
48
-
49
- - run: bundle exec rake