fontist 1.14.6 → 1.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test-and-release.yml +44 -2
- data/.rubocop.yml +1 -0
- data/README.adoc +216 -41
- data/Rakefile +3 -1
- data/fontist.gemspec +4 -2
- data/lib/fontist/cache_cli.rb +14 -0
- data/lib/fontist/cli.rb +5 -1
- data/lib/fontist/formula.rb +20 -2
- data/lib/fontist/import/google.rb +1 -1
- data/lib/fontist/system_index.rb +30 -10
- data/lib/fontist/version.rb +1 -1
- metadata +8 -8
- data/.github/workflows/metanorma.yml +0 -46
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ef3c1df1ab7760fa50abdca9dc9c760d7f953dfc209f3841a8c01b9297760e9
|
4
|
+
data.tar.gz: b6e32f79b2cdeb3af88ec2ae3bdbf9ad767f41d3721dcfa2991f670e74ceaade
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb6f7c6325ba122a79e6713b642dd6ca4967f6622f013dc1c56b41a03e0228da6e5a7e3707211dd293d78d9a3e4a07eec7edc545710f9b322c45f0f7b4c0e7e1
|
7
|
+
data.tar.gz: 2e42062f05fa332dcea0b93fde315db285c8d5894f029e85fdcfcda9f3f57eeed60dc55ed816cb33405c80581a7b313e15cb44e2c13eedafab1d011043b20336
|
@@ -10,6 +10,13 @@ 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:
|
14
21
|
prepare:
|
15
22
|
uses: metanorma/ci/.github/workflows/prepare-rake.yml@main
|
@@ -34,6 +41,7 @@ jobs:
|
|
34
41
|
with:
|
35
42
|
ruby-version: ${{ matrix.ruby.version }}
|
36
43
|
rubygems: ${{ matrix.ruby.rubygems }}
|
44
|
+
bundler: ${{ env.BUNDLER_VER }}
|
37
45
|
bundler-cache: true
|
38
46
|
|
39
47
|
- if: matrix.os == 'macos-latest'
|
@@ -53,7 +61,6 @@ jobs:
|
|
53
61
|
runs-on: ubuntu-latest
|
54
62
|
container:
|
55
63
|
image: 'archlinux:latest'
|
56
|
-
continue-on-error: false
|
57
64
|
strategy:
|
58
65
|
fail-fast: false
|
59
66
|
|
@@ -68,9 +75,44 @@ jobs:
|
|
68
75
|
- name: Test
|
69
76
|
run: bundle exec rspec --tag ~dev
|
70
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
|
+
|
71
113
|
release:
|
72
114
|
name: Release gem
|
73
|
-
needs: [ test, archlinux-test ]
|
115
|
+
needs: [ test, archlinux-test, metanorma ]
|
74
116
|
runs-on: ubuntu-latest
|
75
117
|
if: contains(github.ref, 'refs/tags/v')
|
76
118
|
steps:
|
data/.rubocop.yml
CHANGED
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
|
-
==
|
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 (
|
196
|
-
Italic (
|
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
|
-
==
|
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
|
-
|
571
|
-
|
572
|
-
|
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
|
-
|
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
|
612
|
+
platforms due to font license restrictions of those fonts.
|
613
|
+
|
585
614
|
|
586
|
-
==
|
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
|
-
==
|
644
|
-
|
645
|
-
=== Private Fontist formulas and font repositories
|
674
|
+
== Custom Fontist repositories
|
646
675
|
|
647
|
-
|
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
|
681
|
+
or <<create-formula,auto-generated from a font archive>>.
|
653
682
|
|
654
|
-
A repository can be either
|
655
|
-
corresponding SSH key should be setup with `ssh-agent` in order to access
|
656
|
-
|
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
|
-
|
659
|
-
repository's name and URL for later use.
|
687
|
+
=== Registering a Fontist repository
|
660
688
|
|
661
|
-
|
662
|
-
|
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
|
-
|
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
|
-
|
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 "
|
728
|
+
fontist install "custom font"
|
683
729
|
----
|
684
730
|
|
685
|
-
|
686
|
-
|
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
|
739
|
+
fontist repo update NAME
|
691
740
|
----
|
692
741
|
|
693
|
-
|
694
|
-
|
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
|
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
|
-
|
705
|
-
|
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
|
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
|
-
|
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
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
|
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.
|
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" : "
|
260
|
+
opts << (installed ? "installed" : "not installed")
|
257
261
|
msg = " #{style.type} (#{opts.join(', ')})"
|
258
262
|
|
259
263
|
if installed
|
data/lib/fontist/formula.rb
CHANGED
@@ -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
|
149
|
-
@path.sub(Regexp.new("
|
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.
|
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/system_index.rb
CHANGED
@@ -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,
|
125
|
-
this.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 =
|
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(
|
168
|
-
|
169
|
-
|
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:
|
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)
|
247
|
+
FileUtils.mkdir_p(dir)
|
228
248
|
File.write(@index_path, YAML.dump(index))
|
229
249
|
end
|
230
250
|
end
|
data/lib/fontist/version.rb
CHANGED
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.
|
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: 2023-
|
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
|
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
|
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.
|
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.
|
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,7 +376,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
376
376
|
requirements:
|
377
377
|
- - ">="
|
378
378
|
- !ruby/object:Gem::Version
|
379
|
-
version:
|
379
|
+
version: 2.7.0
|
380
380
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
381
381
|
requirements:
|
382
382
|
- - ">="
|
@@ -1,46 +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
|
-
prepare:
|
14
|
-
uses: metanorma/ci/.github/workflows/prepare-rake.yml@main
|
15
|
-
|
16
|
-
test:
|
17
|
-
name: Test on Ruby ${{ matrix.ruby.version }} ${{ matrix.os }}
|
18
|
-
runs-on: ${{ matrix.os }}
|
19
|
-
|
20
|
-
needs: prepare
|
21
|
-
if: needs.prepare.outputs.push-for-tag != 'true'
|
22
|
-
|
23
|
-
continue-on-error: ${{ matrix.ruby.experimental }}
|
24
|
-
strategy:
|
25
|
-
fail-fast: false
|
26
|
-
max-parallel: 5
|
27
|
-
matrix: ${{ fromJson(needs.prepare.outputs.matrix) }}
|
28
|
-
|
29
|
-
steps:
|
30
|
-
- uses: actions/checkout@v3
|
31
|
-
with:
|
32
|
-
repository: metanorma/metanorma
|
33
|
-
|
34
|
-
- uses: actions/checkout@master
|
35
|
-
with:
|
36
|
-
path: "fontist"
|
37
|
-
|
38
|
-
- uses: ruby/setup-ruby@v1
|
39
|
-
with:
|
40
|
-
ruby-version: ${{ matrix.ruby.version }}
|
41
|
-
rubygems: ${{ matrix.ruby.rubygems }}
|
42
|
-
bundler-cache: true
|
43
|
-
|
44
|
-
- uses: metanorma/ci/inkscape-setup-action@main
|
45
|
-
|
46
|
-
- run: bundle exec rake
|