fontist 3.0.36 → 3.0.38

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d9740ba780da1a789c85954976ffa0d49227705ee62a24dc266dbc4448e63d84
4
- data.tar.gz: 05dd6af4bb8303c4ee4807c6b0a1b2f24607dffbd448352ba9dc8dd145d924c2
3
+ metadata.gz: 3ec4754ec2eb25b7e106ecd9254296d72900bf8df94b59d1707099f1585333c6
4
+ data.tar.gz: f41467d946e5513fb8f297d52984c792ffceb6ee20f4400b238ac786c844960f
5
5
  SHA512:
6
- metadata.gz: 8663ae799c949874b9b61a23c382812f6654a379702f93907530ed8602158725ebf83dd9320cde2539b6e757e51c209833efdc167f820f7d4d695983ad0c27f0
7
- data.tar.gz: 6f01160c9dfc7c11ace56ebac1b92c332be258716b64bd0eb8a95d8271913efc14c1499897c962e170cee914385f1ccbd79b9157f2060582f3ace220b7f3ccde
6
+ metadata.gz: 4a89a610ffd86cf8c4eaef413cb58e4837496b3eb637cb218ba9ba043f61c9f72e4b6e637c34d03c50acc539006fbefd02db5be870a35627758e789b3b583977
7
+ data.tar.gz: 1070a5850da3b68d883b9c578718d072ccad5c249df5f580e1510a9a2019313f76f645f063f6b39186a45deb9391d4c9a6cd501135ac54698da579ffbf5f68cb
@@ -28,3 +28,13 @@ jobs:
28
28
  next_version: ${{ github.event.inputs.next_version }}
29
29
  secrets:
30
30
  rubygems-api-key: ${{ secrets.FONTIST_CI_RUBYGEMS_API_KEY }}
31
+
32
+ # Self-contained executables and .deb/.rpm packages for the new version,
33
+ # attached to its GitHub Release (fontist/fontist#463).
34
+ packages:
35
+ needs: release
36
+ permissions:
37
+ contents: write
38
+ uses: ./.github/workflows/tebako-pack.yml
39
+ with:
40
+ publish: true
@@ -1,65 +1,278 @@
1
1
  name: tebako-pack
2
2
 
3
+ # Packs fontist into one self-contained executable per platform with
4
+ # tebako v2, wraps the Linux ones into .deb/.rpm packages, checks both on
5
+ # machines with no Ruby, and attaches them to the GitHub Release when given
6
+ # a tag.
7
+
3
8
  on:
4
- repository_dispatch:
5
- types: [ do-release ]
9
+ # Called by release.yml once the gem is out. Its releases are created with
10
+ # GITHUB_TOKEN, and GitHub starts no workflow from such an event, so a
11
+ # `release: published` trigger here would never fire.
12
+ workflow_call:
13
+ inputs:
14
+ publish:
15
+ type: boolean
16
+ default: true
6
17
  workflow_dispatch:
18
+ inputs:
19
+ tag:
20
+ description: Release tag to build and attach to (empty = build only)
21
+ required: false
22
+ default: ''
23
+ pull_request:
24
+ paths:
25
+ - .github/workflows/tebako-pack.yml
26
+ - script/tebako/**
27
+ - packaging/**
7
28
 
8
29
  permissions:
9
30
  contents: read
10
- packages: write
11
31
 
12
32
  concurrency:
13
- group: '${{ github.workflow }}-${{ github.job }}-${{ github.head_ref || github.ref_name }}'
33
+ group: '${{ github.workflow }}-${{ github.head_ref || github.ref_name }}'
14
34
  cancel-in-progress: true
15
35
 
16
36
  env:
17
- # This is Ruby version that will be as a base for tebako package
18
- # I.e.: fontist binary will be executed by this version of Ruby
19
- PACKAGE_RUBY_VER: 3.2.3
20
- # This is Ruby version that will be used to execute tebako itself
21
- # It can be the same as PACKAGE_RUBY_VER but for whatever reason 3.1.4
22
- # has better performance
23
- TEBAKO_RUBY_VER: 3.1.4
37
+ # Ruby the packed fontist runs on: a version tebako ships a runtime for
38
+ # (tebako press rejects the rest).
39
+ PACKAGE_RUBY_VERSION: 3.3.12
40
+ TEBAKO_VERSION: 2.8.68
41
+ NFPM_VERSION: 2.48.0
24
42
 
25
43
  jobs:
44
+ resolve:
45
+ name: resolve tag
46
+ runs-on: ubuntu-24.04
47
+ outputs:
48
+ tag: ${{ steps.tag.outputs.tag }}
49
+ steps:
50
+ # After release.yml the default branch carries the released version.
51
+ - uses: actions/checkout@v4
52
+ with:
53
+ ref: ${{ github.event.repository.default_branch }}
54
+
55
+ - id: tag
56
+ env:
57
+ GH_TOKEN: ${{ github.token }}
58
+ # A called workflow sees the caller's event (release.yml runs on
59
+ # workflow_dispatch), so tell the triggers apart by their inputs:
60
+ # only workflow_call has `publish`, only workflow_dispatch has `tag`.
61
+ CALLED: ${{ inputs.publish == true }}
62
+ INPUT_TAG: ${{ inputs.tag || '' }}
63
+ run: |
64
+ if [ "$CALLED" = true ]; then
65
+ tag="v$(sed -n 's/.*VERSION = "\(.*\)".*/\1/p' lib/fontist/version.rb)"
66
+ else
67
+ tag="$INPUT_TAG"
68
+ fi
69
+ if [ -n "$tag" ]; then
70
+ # Only a version tag that is a published release of this repo.
71
+ if ! printf '%s' "$tag" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+$'; then
72
+ echo "not a release tag: $tag" >&2
73
+ exit 1
74
+ fi
75
+ gh release view "$tag" --repo "$GITHUB_REPOSITORY" --json tagName >/dev/null
76
+ fi
77
+ echo "tag=$tag" >> "$GITHUB_OUTPUT"
78
+ echo "building ${tag:-$GITHUB_SHA}"
79
+
26
80
  pack:
27
- name: Pack fontist
81
+ name: pack ${{ matrix.name }}
82
+ needs: resolve
83
+ runs-on: ${{ matrix.os }}
84
+ strategy:
85
+ fail-fast: false
86
+ matrix:
87
+ include:
88
+ # Linux is packed on the oldest runner so the result runs on older
89
+ # glibc distros too.
90
+ - { os: ubuntu-22.04, triplet: linux-gnu-x86_64, name: linux-x86_64 }
91
+ - { os: ubuntu-22.04-arm, triplet: linux-gnu-arm64, name: linux-arm64 }
92
+ - { os: macos-15, triplet: macos-arm64, name: macos-arm64 }
93
+ - { os: macos-15-intel, triplet: macos-x86_64, name: macos-x86_64 }
94
+ steps:
95
+ - uses: actions/checkout@v4
96
+ with:
97
+ fetch-depth: 0
98
+
99
+ # A release build packs the validated release tag, not the dispatching
100
+ # commit (release.yml bumps the version after this run's commit).
101
+ - name: Check out the release tag
102
+ if: needs.resolve.outputs.tag != ''
103
+ env:
104
+ TAG: ${{ needs.resolve.outputs.tag }}
105
+ run: git checkout --detach "refs/tags/$TAG"
106
+
107
+ - uses: ruby/setup-ruby@v1
108
+ with:
109
+ ruby-version: '3.3'
110
+
111
+ - name: Press
112
+ env:
113
+ GH_TOKEN: ${{ github.token }}
114
+ run: script/tebako/press.sh "${{ matrix.triplet }}" "out/fontist-${{ matrix.name }}"
115
+
116
+ # Uploaded before the smoke test so a failing binary can be fetched
117
+ # and inspected.
118
+ - uses: actions/upload-artifact@v4
119
+ with:
120
+ name: fontist-${{ matrix.name }}
121
+ path: out/fontist-${{ matrix.name }}
122
+ if-no-files-found: error
123
+
124
+ # Only the system directories and git stay on PATH, so the Ruby set up
125
+ # above is out of reach. (macOS keeps a system ruby in /usr/bin; the
126
+ # fresh distro containers in package-smoke are the no-Ruby-at-all
127
+ # check.) fontist's git gem needs git >= 2.43, newer than Apple's, so
128
+ # the runner's own git is kept.
129
+ - name: Smoke test without the build Ruby
130
+ run: |
131
+ git_dir="$(dirname "$(command -v git)")"
132
+ env -i HOME="$HOME" PATH="$git_dir:/usr/bin:/bin:/usr/sbin:/sbin" \
133
+ script/tebako/smoke.sh "out/fontist-${{ matrix.name }}"
134
+
135
+ packages:
136
+ name: deb and rpm
137
+ needs: [ resolve, pack ]
138
+ runs-on: ubuntu-24.04
139
+ steps:
140
+ - uses: actions/checkout@v4
141
+ with:
142
+ fetch-depth: 0
143
+
144
+ # A release build packs the validated release tag, not the dispatching
145
+ # commit (release.yml bumps the version after this run's commit).
146
+ - name: Check out the release tag
147
+ if: needs.resolve.outputs.tag != ''
148
+ env:
149
+ TAG: ${{ needs.resolve.outputs.tag }}
150
+ run: git checkout --detach "refs/tags/$TAG"
151
+
152
+ - uses: actions/download-artifact@v4
153
+ with:
154
+ pattern: fontist-linux-*
155
+ path: out
156
+ merge-multiple: true
157
+
158
+ - name: Install nfpm
159
+ env:
160
+ GH_TOKEN: ${{ github.token }}
161
+ run: |
162
+ gh release download "v${NFPM_VERSION}" --repo goreleaser/nfpm --dir /tmp/nfpm \
163
+ --pattern "nfpm_${NFPM_VERSION}_Linux_x86_64.tar.gz" --pattern checksums.txt
164
+ (cd /tmp/nfpm && sha256sum --ignore-missing -c checksums.txt)
165
+ tar -xzf "/tmp/nfpm/nfpm_${NFPM_VERSION}_Linux_x86_64.tar.gz" -C /tmp/nfpm nfpm
166
+ sudo install /tmp/nfpm/nfpm /usr/local/bin/nfpm
167
+
168
+ - name: Build packages
169
+ run: |
170
+ script/tebako/package.sh amd64 out/fontist-linux-x86_64 pkg
171
+ script/tebako/package.sh arm64 out/fontist-linux-arm64 pkg
172
+
173
+ - uses: actions/upload-artifact@v4
174
+ with:
175
+ name: fontist-linux-packages
176
+ path: pkg/*
177
+ if-no-files-found: error
178
+
179
+ package-smoke:
180
+ name: install on ${{ matrix.image }} ${{ matrix.arch }}
181
+ needs: [ resolve, packages ]
182
+ runs-on: ${{ matrix.runner }}
183
+ container: ${{ matrix.image }}
184
+ strategy:
185
+ fail-fast: false
186
+ matrix:
187
+ # Distros whose git meets the git gem's >= 2.43; older ones refuse
188
+ # the package on its git dependency.
189
+ # ubuntu:22.04 ships an older git and first gets a newer one the
190
+ # documented way (git-prep.sh, see README.adoc). debian:12 has no leg:
191
+ # bookworm-backports carries no git package, so no >= 2.43 exists there.
192
+ image: [ 'ubuntu:24.04', 'debian:13', 'fedora:latest', 'rockylinux:9', 'ubuntu:22.04' ]
193
+ arch: [ amd64 ]
194
+ runner: [ ubuntu-24.04 ]
195
+ include:
196
+ - { image: 'ubuntu:24.04', arch: arm64, runner: ubuntu-24.04-arm }
197
+ steps:
198
+ # Only the smoke scripts are used here, so the dispatching commit is
199
+ # enough (these containers have no git to check out a tag with).
200
+ - uses: actions/checkout@v4
201
+
202
+ - uses: actions/download-artifact@v4
203
+ with:
204
+ name: fontist-linux-packages
205
+ path: pkg
206
+
207
+ - name: Keep only this architecture
208
+ run: |
209
+ if [ "${{ matrix.arch }}" = amd64 ]; then
210
+ find pkg \( -name '*arm64*' -o -name '*aarch64*' \) -delete
211
+ else
212
+ find pkg \( -name '*amd64*' -o -name '*x86_64*' \) -delete
213
+ fi
214
+ ls -l pkg
215
+
216
+ - name: Get git 2.43 or newer
217
+ if: matrix.image == 'ubuntu:22.04'
218
+ run: script/tebako/git-prep.sh
219
+
220
+ - name: Install, use, remove
221
+ run: script/tebako/package-smoke.sh pkg
222
+
223
+ # Test-only: the packed executables again, on runners other than the ones
224
+ # that packed them. No macOS leg: macos-14 is not offered to this repo
225
+ # (run 42989415969: "The configuration 'macos-14-arm64-us-default' is not
226
+ # supported") and macos-13 is a label GitHub has retired; the macOS
227
+ # binaries are smoke-tested on their packing runners in `pack`.
228
+ binary-smoke:
229
+ name: run ${{ matrix.name }} on ${{ matrix.os }}
230
+ needs: pack
28
231
  runs-on: ${{ matrix.os }}
29
232
  strategy:
30
233
  fail-fast: false
31
- # macos-11 runner is deadly slow because brew is not supported on this version anymore
32
- # so it is practically impossible to use it for tests anymore
33
234
  matrix:
34
- os: [ubuntu-20.04, macos-12]
235
+ include:
236
+ - { os: ubuntu-24.04, name: linux-x86_64 }
35
237
  steps:
36
- - uses: actions/checkout@v4
37
- with:
38
- fetch-depth: 1
39
-
40
- - name: Setup Tebako
41
- uses: tamatebako/tebako/.github/actions/setup-tebako@main
42
- with:
43
- cache: build
44
- ruby_version: ${{ env.TEBAKO_RUBY_VER }}
45
-
46
- - name: Pack Fontist
47
- run: |
48
- tebako press -R "$PACKAGE_RUBY_VER" --root="." --entry-point="fontist" --output="fontist"
49
- if [ ${{ matrix.os }} -ne "macos-12" ]; then
50
- strip fontist
51
- fi
52
- ./fontist help || echo "fontist help exits with status 1"
53
- cp ./fontist ./fontist-${{ runner.os }}
54
-
55
- - if: github.event_name != 'workflow_dispatch'
56
- uses: softprops/action-gh-release@v1
57
- with:
58
- files: |
59
- fontist-${{ runner.os }}
60
-
61
- - if: github.event_name == 'workflow_dispatch'
62
- uses: actions/upload-artifact@v4
63
- with:
64
- name: fontist-${{ matrix.os }}
65
- path: fontist-${{ runner.os }}
238
+ - uses: actions/checkout@v4
239
+
240
+ - uses: actions/download-artifact@v4
241
+ with:
242
+ name: fontist-${{ matrix.name }}
243
+ path: out
244
+
245
+ - name: Smoke test
246
+ run: |
247
+ chmod +x "out/fontist-${{ matrix.name }}"
248
+ git_dir="$(dirname "$(command -v git)")"
249
+ env -i HOME="$HOME" PATH="$git_dir:/usr/bin:/bin:/usr/sbin:/sbin" \
250
+ script/tebako/smoke.sh "out/fontist-${{ matrix.name }}"
251
+
252
+ publish:
253
+ name: attach to release
254
+ if: needs.resolve.outputs.tag != ''
255
+ needs: [ resolve, pack, package-smoke, binary-smoke ]
256
+ runs-on: ubuntu-24.04
257
+ permissions:
258
+ contents: write
259
+ steps:
260
+ - uses: actions/download-artifact@v4
261
+ with:
262
+ path: dist
263
+ merge-multiple: true
264
+
265
+ - name: Name executables by version and upload
266
+ env:
267
+ GH_TOKEN: ${{ github.token }}
268
+ TAG: ${{ needs.resolve.outputs.tag }}
269
+ run: |
270
+ version="${TAG#v}"
271
+ cd dist
272
+ for name in linux-x86_64 linux-arm64 macos-arm64 macos-x86_64; do
273
+ mv "fontist-$name" "fontist-$version-$name"
274
+ done
275
+ # Executables and .rpm files are fontist-*, .deb files fontist_*.
276
+ sha256sum fontist-* fontist_* > SHA256SUMS
277
+ gh release upload "$TAG" --repo "$GITHUB_REPOSITORY" --clobber \
278
+ fontist-* fontist_* SHA256SUMS
data/Gemfile CHANGED
@@ -18,11 +18,10 @@ gem "simplecov"
18
18
  gem "vcr"
19
19
  gem "webmock"
20
20
 
21
- # Optional YAML engine (consumer-side dependency; needs Ruby >= 3.0,
22
- # which is above fontist's gemspec floor, so it stays out of the
23
- # gemspec). Activated with FONTIST_YAML=yeptris; off by default
24
- # pending leptris/yeptris#863 (linux scalar-parity fix).
25
- gem "yeptris", require: false
21
+ # yeptris is a runtime dependency (see the gemspec): the JSON backend in
22
+ # lib/fontist/json.rb loads it unconditionally. The optional YAML engine
23
+ # activated with FONTIST_YAML=yeptris stays off by default pending
24
+ # leptris/yeptris#863 (linux scalar-parity fix).
26
25
 
27
26
  # Profiling tools (development only)
28
27
  # gem "ruby-prof", "~> 1.7"
data/README.adoc CHANGED
@@ -42,6 +42,64 @@ And then execute:
42
42
  bundle install
43
43
  ----
44
44
 
45
+ === Install without Ruby
46
+
47
+ Each release on the
48
+ https://github.com/fontist/fontist/releases[GitHub Releases] page has a
49
+ self-contained `fontist` executable. It does not need a Ruby installation.
50
+ Linux and macOS are supported.
51
+
52
+ Download the file for your system, check it, and make it executable. The
53
+ names are `fontist-<version>-linux-x86_64`, `-linux-arm64`, `-macos-arm64`
54
+ and `-macos-x86_64`.
55
+
56
+ [source,sh]
57
+ ----
58
+ curl -LO https://github.com/fontist/fontist/releases/download/v<version>/fontist-<version>-linux-x86_64
59
+ curl -LO https://github.com/fontist/fontist/releases/download/v<version>/SHA256SUMS
60
+ sha256sum --ignore-missing -c SHA256SUMS # on macOS: shasum -a 256 -c --ignore-missing SHA256SUMS
61
+ chmod +x fontist-<version>-linux-x86_64
62
+ ./fontist-<version>-linux-x86_64 version
63
+ ----
64
+
65
+ The executables are not signed. On macOS, remove the quarantine flag before
66
+ the first run:
67
+
68
+ [source,sh]
69
+ ----
70
+ xattr -d com.apple.quarantine ./fontist-<version>-macos-arm64
71
+ ----
72
+
73
+ Each run prints a notice from the packager that the executable is unsigned.
74
+ It is harmless.
75
+
76
+ fontist needs git 2.43 or newer to fetch formulas. The git that ships with
77
+ macOS is older, so install a current one first (for example
78
+ `brew install git`).
79
+
80
+ On Debian and Ubuntu, install the `.deb` package. On Fedora and RHEL, install
81
+ the `.rpm` package. Both install the executable to `/usr/lib/fontist/fontist` and link it from
82
+ `/usr/local/bin/fontist` (the link is removed with the package). They depend on
83
+ git 2.43 or newer, which Ubuntu 24.04, Debian 13, Fedora and RHEL 9 provide.
84
+
85
+ Ubuntu 22.04 ships an older git, so get a newer one once before installing the
86
+ `.deb`: `sudo add-apt-repository ppa:git-core/ppa && sudo apt-get update && sudo apt-get install git`.
87
+ Debian 12 has no git 2.43 or newer in its archive or in bookworm-backports, so
88
+ the package cannot be installed there.
89
+
90
+ `script/tebako/git-prep.sh` does exactly this and is what CI runs.
91
+
92
+ [source,sh]
93
+ ----
94
+ sudo apt install ./fontist_<version>_amd64.deb
95
+ sudo dnf install ./fontist-<version>-1.x86_64.rpm
96
+ ----
97
+
98
+ For ARM64, use `_arm64.deb` and `.aarch64.rpm`.
99
+
100
+ This build uses the same home directory as the gem (`~/.fontist`, or
101
+ `FONTIST_PATH` if set), so the two can be used side by side.
102
+
45
103
  === Fetch formulas
46
104
 
47
105
  After installation, please fetch formulas via the `fontist` command:
@@ -248,7 +248,7 @@ export default defineConfig({
248
248
  ],
249
249
 
250
250
  footer: {
251
- message: `Fontist is <a href="https://open.ribose.com/">riboseopen</a>`,
251
+ message: `Fontist is <a href="https://www.ribose.com/">riboseopen</a>`,
252
252
  copyright: `Copyright &copy; 2026 Ribose Group Inc. All rights reserved.`,
253
253
  },
254
254
  },
data/fontist.gemspec CHANGED
@@ -33,7 +33,7 @@ Gem::Specification.new do |spec|
33
33
 
34
34
  spec.add_dependency "down", "~> 5.0"
35
35
  spec.add_dependency "excavate", "~> 1.0", ">= 1.0.3"
36
- spec.add_dependency "fontisan", "~> 0.4", ">= 0.4.47"
36
+ spec.add_dependency "fontisan", "~> 0.4", ">= 0.4.48"
37
37
  spec.add_dependency "fuzzy_match", "~> 2.1"
38
38
  spec.add_dependency "git", "~> 6.0"
39
39
  spec.add_dependency "lutaml-model", "~> 0.8.164"
@@ -46,4 +46,5 @@ Gem::Specification.new do |spec|
46
46
  spec.add_dependency "socksify", "~> 1.7"
47
47
  spec.add_dependency "thor", "~> 1.4"
48
48
  spec.add_dependency "unibuf", "~> 0.1"
49
+ spec.add_dependency "yeptris", "~> 0.6.55"
49
50
  end
data/lib/fontist/cli.rb CHANGED
@@ -564,7 +564,7 @@ module Fontist
564
564
  styles.each do |style, installed|
565
565
  opts = []
566
566
  opts << "manual" if formula.manual?
567
- opts << (installed ? "installed" : "not installed")
567
+ opts << install_label(installed)
568
568
  msg = " #{style.type} (#{opts.join(', ')})"
569
569
 
570
570
  if installed
@@ -578,6 +578,14 @@ module Fontist
578
578
  end
579
579
  # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
580
580
 
581
+ def install_label(status)
582
+ case status
583
+ when true then "installed"
584
+ when false then "not installed"
585
+ else "installed (system)"
586
+ end
587
+ end
588
+
581
589
  def print_find_results(results)
582
590
  if results.empty?
583
591
  Fontist.ui.say("No fonts found matching criteria")
data/lib/fontist/font.rb CHANGED
@@ -446,8 +446,9 @@ module Fontist
446
446
  def list_styles(formulas)
447
447
  map_to_hash(formulas) do |formula|
448
448
  map_to_hash(requested_fonts(formula.all_fonts)) do |font|
449
+ external = external_paths_by_type(font)
449
450
  map_to_hash(font.styles) do |style|
450
- installed(style)
451
+ installed(style, external)
451
452
  end
452
453
  end
453
454
  end
@@ -465,8 +466,25 @@ module Fontist
465
466
  end
466
467
  end
467
468
 
468
- def installed(style)
469
- path(style) ? true : false
469
+ # A font found only outside the fontist directory reports its paths
470
+ # instead of true, so callers can tell the copies fontist cannot
471
+ # update or remove from the managed ones.
472
+ def installed(style, external)
473
+ return true if path(style)
474
+
475
+ external.fetch(style.type.to_s.downcase, false)
476
+ end
477
+
478
+ # One index lookup per font name, grouped by lower-cased style type.
479
+ def external_paths_by_type(font)
480
+ entries = SystemFont.find_styles(font.name) || []
481
+ entries.reject { |entry| in_fontist_dir?(entry.path) }
482
+ .group_by { |entry| entry.type.to_s.downcase }
483
+ .transform_values { |group| group.map(&:path) }
484
+ end
485
+
486
+ def in_fontist_dir?(path)
487
+ path.start_with?(Fontist.fonts_path.to_s)
470
488
  end
471
489
 
472
490
  def raise_non_supported_font
@@ -39,9 +39,7 @@ module Fontist
39
39
 
40
40
  def run(source, target, output)
41
41
  FileUtils.mkdir_p(File.dirname(output))
42
- Fontisan::Commands::ConvertCommand.new(
43
- source, to: target, output: output, quiet: true
44
- ).run
42
+ Fontisan::Reference.convert(source, to: target, output: output)
45
43
  end
46
44
 
47
45
  def verify!(path, target)
@@ -18,9 +18,9 @@ module Fontist
18
18
  end
19
19
 
20
20
  def unpack(collection_path, index, output_dir)
21
- Fontisan::Commands::UnpackCommand.new(
22
- collection_path, output_dir: output_dir, font_index: index
23
- ).run[:extracted_files].first
21
+ Fontisan::Reference.extract(
22
+ collection_path, index: index, output_dir: output_dir
23
+ )
24
24
  end
25
25
 
26
26
  def check_index!(path, index)
@@ -59,13 +59,17 @@ module Fontist
59
59
  "#{File.basename(source)} is not a variable font"
60
60
  end
61
61
 
62
- instancer = Fontisan::Variable::Instancer.new(font)
63
- validate!(instancer, coords, File.basename(source))
62
+ validate!(Fontisan::Variable::Instancer.new(font), coords,
63
+ File.basename(source))
64
64
  FileUtils.mkdir_p(File.dirname(output))
65
- File.binwrite(output, instancer.instance(coords))
65
+ File.binwrite(output, instance_bytes(source, coords))
66
66
  output
67
67
  end
68
68
 
69
+ def instance_bytes(source, coords)
70
+ Fontisan::Reference.instance(source, coords: coords)
71
+ end
72
+
69
73
  def validate!(instancer, coords, name)
70
74
  axes = instancer.axes.to_h { |axis| [axis.tag, axis] }
71
75
  coords.each do |tag, value|
@@ -4,6 +4,7 @@ module Fontist
4
4
  module FontOperations
5
5
  # Keeps only the glyphs for the given characters.
6
6
  module Subset
7
+ NO_GLYPHS = "None of the requested characters exist in".freeze
7
8
  UNICODE_PART = /\A(u\+)?\h+(-(u\+)?\h+)?\z/i
8
9
 
9
10
  module_function
@@ -28,21 +29,16 @@ module Fontist
28
29
  end
29
30
 
30
31
  def write(source, output, codepoints)
31
- font = Fontisan::FontLoader.load(source)
32
- gids = glyph_ids(font, codepoints, File.basename(source))
33
- options = Fontisan::Subset::Options.new(profile: "web")
34
- binary = Fontisan::Subset::Builder.new(font, gids, options).build
32
+ binary = Fontisan::Reference.subset(
33
+ source, unicodes: codepoints, profile: "web"
34
+ )
35
35
  FileUtils.mkdir_p(File.dirname(output))
36
36
  File.binwrite(output, binary)
37
37
  output
38
- end
39
-
40
- def glyph_ids(font, codepoints, name)
41
- mappings = font.table("cmap").unicode_mappings
42
- gids = codepoints.uniq.filter_map { |cp| mappings[cp] }.uniq.sort
43
- return gids if gids.any?
38
+ rescue Fontisan::Error => e
39
+ raise unless e.message.start_with?(NO_GLYPHS)
44
40
 
45
- raise Error, "None of the requested characters exist in #{name}"
41
+ raise Error, e.message
46
42
  end
47
43
 
48
44
  # "U+0020-007E,U+00E9" => [32..126, 233].flatten