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.
@@ -0,0 +1,82 @@
1
+ require "fontisan"
2
+
3
+ module Fontist
4
+ # Turns `Fontisan.scan` rows into the font objects the indexes already
5
+ # consume (`FontFile` for single fonts, a `FontFile` over the english-only
6
+ # names for collection faces), so one batch scan can replace the per-path
7
+ # `FontFile.from_path` / `CollectionFile.from_path` loads.
8
+ #
9
+ # Only rows that carry no error are usable; anything else is left to the
10
+ # per-file path so its message stays byte-identical.
11
+ module ScanRowFonts
12
+ SINGLE_FORMATS = %w[ttf otf woff woff2].freeze
13
+ COLLECTION_FORMATS = %w[ttc otc].freeze
14
+
15
+ class << self
16
+ def usable?(rows)
17
+ return false if rows.nil? || rows.empty?
18
+
19
+ if rows.first["is_collection"]
20
+ collection_usable?(rows)
21
+ else
22
+ single_usable?(rows)
23
+ end
24
+ end
25
+
26
+ def file_font(row)
27
+ report_validation(row)
28
+ info = symbolize(row["names"] || {})
29
+ if row["has_fvar"] && info[:family_name]
30
+ info[:variable_instances] =
31
+ row["variable_instances"].map { |i| symbolize(i) }
32
+ end
33
+ FontFile.new(info)
34
+ end
35
+
36
+ def collection_face(row)
37
+ FontFile.new(symbolize(row["english_names"] || {}))
38
+ end
39
+
40
+ def warn_file_extension(path, row)
41
+ FontFile.check_extension_warning(path, row["is_collection"])
42
+ end
43
+
44
+ def warn_collection_extension(path)
45
+ CollectionFile.send(:check_extension_warning, path)
46
+ end
47
+
48
+ private
49
+
50
+ def collection_usable?(rows)
51
+ COLLECTION_FORMATS.include?(rows.first["format"]) &&
52
+ rows.all? { |row| collection_row_ok?(row) }
53
+ end
54
+
55
+ def single_usable?(rows)
56
+ row = rows.first
57
+ rows.size == 1 && SINGLE_FORMATS.include?(row["format"]) &&
58
+ row["errors"]["font_file"].nil? && !row["names"].nil?
59
+ end
60
+
61
+ def symbolize(hash)
62
+ hash.transform_keys(&:to_sym)
63
+ end
64
+
65
+ def collection_row_ok?(row)
66
+ row["is_collection"] && row["num_faces"].to_i.positive? &&
67
+ row["errors"]["collection_file"].nil? &&
68
+ row["errors"]["collection_member"].nil?
69
+ end
70
+
71
+ def report_validation(row)
72
+ validation = row["validation"]
73
+ return if validation.nil? || validation["valid"]
74
+
75
+ name = File.basename(row["path"])
76
+ Fontist.ui.debug(
77
+ "Font validation issues for #{name}: #{validation['error_summary']}",
78
+ )
79
+ end
80
+ end
81
+ end
82
+ end
@@ -403,8 +403,11 @@ module Fontist
403
403
  end
404
404
 
405
405
  def index_changed?
406
+ # Verified first: a location that holds no fonts leaves the index
407
+ # empty after its rebuild, and treating empty as unbuilt would rescan
408
+ # the disk on every lookup. Installs reach the index via add_font.
409
+ return false if @index_check_done # already verified in this session
406
410
  return true if fonts.nil? || fonts.empty?
407
- return false if @index_check_done # Skip if already verified in this session
408
411
 
409
412
  # Quick check: if index was scanned recently, trust it
410
413
  if recently_scanned?
@@ -664,7 +667,8 @@ verbose:, stats:)
664
667
  show_minimal_progress = !verbose && sorted_paths.size > 100
665
668
  progress_interval = sorted_paths.size > 1000 ? 100 : 50
666
669
 
667
- results = sorted_paths.flat_map.with_index do |path, index|
670
+ misses = []
671
+ slots = sorted_paths.each_with_index.map do |path, index|
668
672
  if verbose && stats
669
673
  display_progress(index + 1, sorted_paths.size, path, spinner_chars,
670
674
  spinner_index)
@@ -675,25 +679,66 @@ verbose:, stats:)
675
679
  spinner_index += 1
676
680
 
677
681
  cached = existing_fonts_by_path[path]
678
- detect_font_with_cache(path, cached, stats: stats)
682
+ if reusable_cache?(path, cached, stats: stats)
683
+ cached
684
+ else
685
+ misses << path unless excluded?(path)
686
+ path
687
+ end
688
+ end
689
+
690
+ rows = scan_rows_by_path(misses)
691
+ results = slots.flat_map do |slot|
692
+ slot.is_a?(String) ? entries_for_miss(slot, rows[slot], stats) : slot
679
693
  end.compact
680
694
 
681
695
  clear_progress_line if verbose
682
696
  results
683
697
  end
684
698
 
685
- def detect_font_with_cache(path, cached, stats:)
699
+ def reusable_cache?(path, cached, stats:)
686
700
  # Fast path: reuse cached metadata if file unchanged
687
701
  if cached&.any? && file_unchanged?(path, cached.first)
688
702
  stats&.record_cache_hit
689
- cached
703
+ true
690
704
  else
691
- # Slow path: parse font file
692
705
  stats&.record_cache_miss
706
+ false
707
+ end
708
+ end
709
+
710
+ # One batch scan for every cache miss. The digest and name decoding run
711
+ # inside Fontisan.scan; no forks, no threads here.
712
+ def scan_rows_by_path(paths)
713
+ return {} if paths.empty?
714
+
715
+ Fontisan.scan(paths).group_by { |row| row["path"] }
716
+ end
717
+
718
+ def entries_for_miss(path, rows, stats)
719
+ return if excluded?(path)
720
+
721
+ if ScanRowFonts.usable?(rows)
722
+ build_entries_from_rows(path, rows)
723
+ else
724
+ # A failing or unusual file keeps the per-file path, so its error
725
+ # text and stats are exactly what they were before batching.
693
726
  detect_fonts(path, stats: stats)
694
727
  end
695
728
  end
696
729
 
730
+ def build_entries_from_rows(path, rows)
731
+ if rows.first["is_collection"]
732
+ ScanRowFonts.warn_collection_extension(path)
733
+ rows.map { |row| parse_font(ScanRowFonts.collection_face(row), path) }
734
+ else
735
+ ScanRowFonts.warn_file_extension(path, rows.first)
736
+ font_file = ScanRowFonts.file_font(rows.first)
737
+ entries = variable_font_entries(font_file, path)
738
+ entries.empty? ? parse_font(font_file, path) : entries
739
+ end
740
+ end
741
+
697
742
  def display_progress(current, total, path, spinner_chars,
698
743
  spinner_index = nil)
699
744
  spinner_index ||= (current / 10) % spinner_chars.length
@@ -93,7 +93,7 @@ module Fontist
93
93
 
94
94
  # Build lookup hash for fast O(1) access by path (non-shared state)
95
95
  def to_lookup
96
- entries.index_by(&:path)
96
+ entries.to_h { |entry| [entry.path, entry] }
97
97
  end
98
98
 
99
99
  # Get validation result for a path, checking if file has changed
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "fontisan"
3
4
  require "parallel"
4
5
 
5
6
  module Fontist
@@ -43,14 +44,11 @@ module Fontist
43
44
  # Build read-only lookup from cache (non-shared state)
44
45
  cache_lookup = cache&.to_lookup || {}
45
46
 
46
- # Validate in parallel or sequential
47
- results = if use_parallel && font_paths.size > 10
48
- validate_parallel(font_paths, cache_lookup: cache_lookup,
49
- verbose: verbose)
50
- else
51
- validate_sequential(font_paths, cache_lookup: cache_lookup,
52
- verbose: verbose)
53
- end
47
+ # Cache hits are reused; every miss goes through one batch scan.
48
+ parallel = use_parallel && font_paths.size > 10
49
+ results = validate_batched(font_paths, cache_lookup: cache_lookup,
50
+ parallel: parallel,
51
+ verbose: verbose)
54
52
 
55
53
  @report.results = results
56
54
  @report.calculate_summary!
@@ -78,8 +76,7 @@ module Fontist
78
76
  end
79
77
 
80
78
  # Validate the font
81
- font_file = FontFile.from_path(path, validate: true,
82
- check_extension: false)
79
+ font_file = FontFile.from_path(path)
83
80
 
84
81
  time_taken = Time.now - start_time
85
82
 
@@ -154,41 +151,74 @@ module Fontist
154
151
 
155
152
  private
156
153
 
157
- # Validate fonts in parallel using non-shared state.
158
- # Each thread gets read-only cache_lookup (no shared writes)
159
- def validate_parallel(font_paths, cache_lookup:, verbose:)
160
- num_cores = [Parallel.processor_count, 8].min
154
+ # Reuse unchanged cache entries, then validate the misses with a single
155
+ # Fontisan.scan. Results keep the order of +font_paths+.
156
+ def validate_batched(font_paths, cache_lookup:, parallel:, verbose:)
157
+ hits, misses = font_paths.partition do |path|
158
+ cached = cache_lookup[path]
159
+ cached && file_unchanged?(path, cached)
160
+ end
161
161
 
162
- if verbose
163
- Fontist.ui.say("Using parallel processing with #{num_cores} cores")
162
+ fresh = validate_misses(misses, parallel: parallel, verbose: verbose)
163
+ hit_set = hits.to_set
164
+ font_paths.filter_map do |path|
165
+ hit_set.include?(path) ? cache_lookup[path] : fresh[path]
164
166
  end
167
+ end
165
168
 
166
- # Map: Each thread validates independently (non-shared state)
167
- # cache_lookup is read-only, no mutex needed
168
- Parallel.map(font_paths, in_threads: num_cores) do |path|
169
- validate_with_cache_lookup(path, cache_lookup)
170
- end.compact
169
+ # @return [Hash{String => FontValidationResult}]
170
+ def validate_misses(paths, parallel:, verbose:)
171
+ return {} if paths.empty?
172
+
173
+ fresh = scan_results(paths)
174
+ # Failing files keep the per-file path so their messages are unchanged.
175
+ leftovers = fresh.select { |_, result| result.nil? }.keys
176
+ validate_leftovers(leftovers, parallel: parallel, verbose: verbose)
177
+ .each { |result| fresh[result.path] = result }
178
+ fresh
171
179
  end
172
180
 
173
- # Validate fonts sequentially with cache lookup.
174
- def validate_sequential(font_paths, cache_lookup:, verbose:)
175
- font_paths.filter_map do |path|
176
- validate_with_cache_lookup(path, cache_lookup)
181
+ # One scan for all paths; nil marks a file the scan could not read.
182
+ def scan_results(paths)
183
+ started = Time.now
184
+ rows = Fontisan.scan(paths).group_by { |row| row["path"] }
185
+ share = ((Time.now - started) / paths.size).round(4)
186
+
187
+ paths.to_h do |path|
188
+ [path, result_from_rows(path, rows[path], share)]
177
189
  end
178
190
  end
179
191
 
180
- # Validate single font, using cache if available and file unchanged.
181
- def validate_with_cache_lookup(path, cache_lookup)
182
- cached = cache_lookup[path]
183
-
184
- # Check if cached result is still valid (file unchanged)
185
- if cached && file_unchanged?(path, cached)
186
- # Return cached result without re-validating
187
- return cached
192
+ def validate_leftovers(paths, parallel:, verbose:)
193
+ if parallel && paths.size > 1
194
+ num_cores = [Parallel.processor_count, 8].min
195
+ if verbose
196
+ Fontist.ui.say("Using parallel processing with #{num_cores} cores")
197
+ end
198
+ Parallel.map(paths, in_threads: num_cores) { |p| validate_single(p) }
199
+ else
200
+ paths.map { |path| validate_single(path) }
188
201
  end
202
+ end
203
+
204
+ # A passing result when the scan row for +path+ read cleanly, else nil.
205
+ def result_from_rows(path, rows, time_taken)
206
+ row = rows&.first
207
+ return unless row && row["names"] && row["errors"]["font_file"].nil?
208
+
209
+ names = row["names"]
210
+ FontValidationResult.new(
211
+ path: path, valid: true, time_taken: time_taken,
212
+ family_name: names["family_name"], full_name: names["full_name"],
213
+ file_size: safe_stat { File.size(path) },
214
+ file_mtime: safe_stat { File.mtime(path).to_i }
215
+ )
216
+ end
189
217
 
190
- # No cache or file changed - validate
191
- validate_single(path)
218
+ def safe_stat
219
+ yield
220
+ rescue StandardError
221
+ 0
192
222
  end
193
223
 
194
224
  # Check if file has unchanged metadata compared to cached result.
@@ -1,3 +1,3 @@
1
1
  module Fontist
2
- VERSION = "3.0.36".freeze
2
+ VERSION = "3.0.38".freeze
3
3
  end
data/lib/fontist.rb CHANGED
@@ -50,6 +50,7 @@ module Fontist
50
50
 
51
51
  # Data models
52
52
  autoload :CollectionFile, "#{__dir__}/fontist/collection_file"
53
+ autoload :ScanRowFonts, "#{__dir__}/fontist/scan_row_fonts"
53
54
  autoload :Extract, "#{__dir__}/fontist/extract"
54
55
  autoload :ExtractOptions, "#{__dir__}/fontist/extract"
55
56
  autoload :Resource, "#{__dir__}/fontist/resource"
@@ -0,0 +1,38 @@
1
+ # Linux packages that wrap the tebako-packed fontist executable.
2
+ # Built by script/tebako/package.sh, which sets ARCH, VERSION and BINARY.
3
+ name: fontist
4
+ arch: ${ARCH}
5
+ platform: linux
6
+ version: ${VERSION}
7
+ section: utils
8
+ priority: optional
9
+ maintainer: Ribose Inc. <open.source@ribose.com>
10
+ description: |
11
+ Install openly-licensed fonts on Windows, Linux and Mac.
12
+ Self-contained build: no Ruby installation is needed.
13
+ vendor: Ribose Inc.
14
+ homepage: https://www.fontist.org
15
+ license: BSD-2-Clause
16
+
17
+ # fontist clones its formula repository with git, and its git gem (~> 6.0)
18
+ # refuses a host git older than 2.43. Debian and Ubuntu version git with
19
+ # epoch 1 (1:2.43.0-1), RPM distros do not, hence one dependency per packager.
20
+ overrides:
21
+ deb:
22
+ depends:
23
+ - git (>= 1:2.43)
24
+ rpm:
25
+ depends:
26
+ - git >= 2.43
27
+
28
+ contents:
29
+ - src: ${BINARY}
30
+ dst: /usr/lib/fontist/fontist
31
+ expand: true # nfpm leaves ${BINARY} in src alone without this
32
+ file_info:
33
+ mode: 0755
34
+
35
+ # The postinstall script links the binary into /usr/local/bin.
36
+ scripts:
37
+ postinstall: packaging/scripts/postinstall.sh
38
+ preremove: packaging/scripts/preremove.sh
@@ -0,0 +1,5 @@
1
+ #!/bin/sh
2
+ # The binary lives in /usr/lib/fontist; make it reachable from /usr/local/bin.
3
+ set -e
4
+ mkdir -p /usr/local/bin
5
+ ln -sf /usr/lib/fontist/fontist /usr/local/bin/fontist
@@ -0,0 +1,12 @@
1
+ #!/bin/sh
2
+ # Remove the /usr/local/bin symlink on removal, not on upgrade. dpkg passes
3
+ # "remove" or "purge"; rpm passes the number of copies left (0 on removal).
4
+ set -e
5
+ case "$1" in
6
+ remove|purge|0)
7
+ if [ "$(readlink /usr/local/bin/fontist 2>/dev/null)" = /usr/lib/fontist/fontist ]; then
8
+ rm -f /usr/local/bin/fontist
9
+ fi
10
+ ;;
11
+ esac
12
+ exit 0
@@ -0,0 +1,90 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ # Entry point of the tebako-packed fontist (copied to bin/fontist by
5
+ # script/tebako/stage.sh).
6
+ #
7
+ # tebako installs the locked dependencies as gems inside the package; only
8
+ # fontist itself sits at a path, so it goes on the load path directly.
9
+ # bundler/setup is not used: bundler chdirs into path gems, and the packed
10
+ # filesystem refuses that.
11
+ #
12
+ # Libraries loaded through FFI (yeptris, leptris, ...) are opened with the
13
+ # host's dlopen, which cannot see inside the package. Each one is copied
14
+ # once to a host cache keyed by its content, and FFI is handed that copy.
15
+
16
+ # The packed gems are the only gems this program may see. rubygems also
17
+ # searches the host's GEM_HOME, GEM_PATH and user gem dir (~/.gem/ruby/<abi>),
18
+ # so a Ruby manager such as rvm, or a `gem install --user-install`, would
19
+ # shadow the locked gems. Pin rubygems to the package's gem dir before
20
+ # anything is required.
21
+ packed_gem_dir = Gem.default_dir
22
+ ENV.delete("GEM_HOME")
23
+ ENV.delete("GEM_PATH")
24
+ Gem.use_paths(packed_gem_dir, [packed_gem_dir])
25
+
26
+ require "digest"
27
+ require "fileutils"
28
+ require "ffi"
29
+
30
+ module FontistPackedNativeLibraries
31
+ PACKAGE_ROOT = "/__tfs__/"
32
+
33
+ def self.cache_root
34
+ home = ENV["FONTIST_PATH"] || File.join(Dir.home, ".fontist")
35
+ File.join(home, "tebako-native")
36
+ end
37
+
38
+ def self.host_path(name)
39
+ return name unless name.is_a?(String) && name.start_with?(PACKAGE_ROOT)
40
+ return name unless File.file?(name)
41
+
42
+ bytes = File.binread(name)
43
+ dir = File.join(cache_root, Digest::SHA256.hexdigest(bytes)[0, 16])
44
+ target = File.join(dir, File.basename(name))
45
+ write_once(target, bytes) unless File.file?(target)
46
+ target
47
+ end
48
+
49
+ def self.write_once(target, bytes)
50
+ FileUtils.mkdir_p(File.dirname(target))
51
+ partial = "#{target}.#{Process.pid}.partial"
52
+ File.binwrite(partial, bytes)
53
+ File.chmod(0o755, partial)
54
+ File.rename(partial, target)
55
+ end
56
+
57
+ # An Array argument is a list of alternatives (the first that loads wins),
58
+ # so the nesting is kept: only the names inside are rewritten.
59
+ def self.rewrite(name)
60
+ name.is_a?(Array) ? name.map { |n| rewrite(n) } : host_path(name)
61
+ end
62
+
63
+ def ffi_lib(*names)
64
+ super(*names.map { |name| FontistPackedNativeLibraries.rewrite(name) })
65
+ end
66
+ end
67
+
68
+ FFI::Library.prepend(FontistPackedNativeLibraries)
69
+
70
+ # leptris also opens libleptris from its compiled extension, which consults
71
+ # LEPTRIS_LIB_PATH and then package paths the host cannot open. Two copies
72
+ # of the library loaded side by side crash it, so both loaders are pointed
73
+ # at the same host copy. yeptris reads YEPTRIS_LIB_PATH the same way.
74
+ {
75
+ "leptris" => %w[LEPTRIS_LIB_PATH libleptris],
76
+ "yeptris" => %w[YEPTRIS_LIB_PATH libyeptris],
77
+ }.each do |gem_name, (variable, basename)|
78
+ next if ENV[variable]
79
+
80
+ spec = Gem::Specification.find_all_by_name(gem_name).max_by(&:version)
81
+ next unless spec
82
+
83
+ library = Dir.glob(
84
+ File.join(spec.full_gem_path, "**", "#{basename}.{dylib,so,dll}"),
85
+ ).min
86
+ ENV[variable] = FontistPackedNativeLibraries.host_path(library) if library
87
+ end
88
+
89
+ $LOAD_PATH.unshift(File.expand_path("../vendor/fontist/lib", __dir__))
90
+ load File.expand_path("../vendor/fontist/exe/fontist", __dir__)
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env bash
2
+ # Get git >= 2.43 on Ubuntu 22.04, the documented one-time step
3
+ # before installing the fontist .deb (see README.adoc). Run as root.
4
+ #
5
+ # script/tebako/git-prep.sh
6
+ set -euo pipefail
7
+
8
+ export DEBIAN_FRONTEND=noninteractive
9
+ # shellcheck disable=SC1091
10
+ . /etc/os-release
11
+
12
+ apt-get update -qq
13
+ case "$ID:$VERSION_ID" in
14
+ ubuntu:22.04)
15
+ apt-get install -y -qq ca-certificates software-properties-common
16
+ add-apt-repository -y ppa:git-core/ppa
17
+ apt-get update -qq
18
+ apt-get install -y -qq git
19
+ ;;
20
+ *)
21
+ echo "git-prep: nothing to do on $ID $VERSION_ID" >&2
22
+ exit 1
23
+ ;;
24
+ esac
25
+ git --version
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env bash
2
+ # Install a fontist .deb or .rpm on a fresh distro, use it, then remove it.
3
+ # Runs inside a distro container (see .github/workflows/tebako-pack.yml).
4
+ #
5
+ # script/tebako/package-smoke.sh <package-dir>
6
+ set -euo pipefail
7
+
8
+ dir="${1:?usage: package-smoke.sh <package-dir>}"
9
+ # apt reads a bare relative path as a package name; give it an absolute one.
10
+ dir="$(cd "$dir" && pwd)"
11
+ here="$(cd "$(dirname "$0")" && pwd)"
12
+
13
+ if command -v apt-get >/dev/null; then
14
+ export DEBIAN_FRONTEND=noninteractive
15
+ apt-get update -qq
16
+ apt-get install -y -qq ca-certificates "$dir"/fontist_*.deb
17
+ remove() { apt-get remove -y -qq fontist; }
18
+ else
19
+ dnf install -y -q "$dir"/fontist-*.rpm
20
+ remove() { dnf remove -y -q fontist; }
21
+ fi
22
+
23
+ if command -v ruby >/dev/null; then
24
+ echo "package-smoke: this image has no business carrying ruby" >&2
25
+ exit 1
26
+ fi
27
+ link="$(readlink /usr/local/bin/fontist || true)"
28
+ if [ "$link" != /usr/lib/fontist/fontist ]; then
29
+ echo "package-smoke: /usr/local/bin/fontist links to '$link'" >&2
30
+ exit 1
31
+ fi
32
+ "$here/smoke.sh" "$(command -v fontist)"
33
+ remove
34
+ if [ -e /usr/local/bin/fontist ] || [ -L /usr/local/bin/fontist ] || command -v fontist >/dev/null; then
35
+ echo "package-smoke: fontist still present after removal" >&2
36
+ exit 1
37
+ fi
38
+ echo "package-smoke: ok"
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env bash
2
+ # Wrap a packed Linux fontist executable into .deb and .rpm packages.
3
+ #
4
+ # script/tebako/package.sh <amd64|arm64> <fontist-executable> <out-dir>
5
+ set -euo pipefail
6
+
7
+ usage="usage: package.sh <amd64|arm64> <fontist-executable> <out-dir>"
8
+ arch="${1:?$usage}"
9
+ binary="${2:?$usage}"
10
+ out="${3:?$usage}"
11
+
12
+ root="$(cd "$(dirname "$0")/../.." && pwd)"
13
+ version="$(sed -n 's/.*VERSION = "\(.*\)".*/\1/p' "$root/lib/fontist/version.rb")"
14
+
15
+ mkdir -p "$out"
16
+ BINARY="$(cd "$(dirname "$binary")" && pwd)/$(basename "$binary")"
17
+ out="$(cd "$out" && pwd)"
18
+ # nfpm resolves the script paths in nfpm.yaml against the working directory.
19
+ cd "$root"
20
+ export ARCH="$arch" VERSION="$version" BINARY
21
+
22
+ for packager in deb rpm; do
23
+ nfpm package --config "$root/packaging/nfpm.yaml" \
24
+ --packager "$packager" --target "$out"
25
+ done
26
+ ls -l "$out"
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env bash
2
+ # Press fontist into one self-contained executable with tebako v2.
3
+ #
4
+ # script/tebako/press.sh <tebako-triplet> <output-path>
5
+ #
6
+ # <tebako-triplet> is the tebako release asset suffix: linux-gnu-x86_64,
7
+ # linux-gnu-arm64, macos-arm64 or macos-x86_64. Needs gh, ruby and bundler.
8
+ # GH_TOKEN (or GITHUB_TOKEN) keeps tebako's runtime lookups clear of the
9
+ # anonymous GitHub API limit.
10
+ set -euo pipefail
11
+
12
+ triplet="${1:?usage: press.sh <tebako-triplet> <output-path>}"
13
+ output="${2:?usage: press.sh <tebako-triplet> <output-path>}"
14
+
15
+ tebako_version="${TEBAKO_VERSION:-2.8.68}"
16
+ ruby_version="${PACKAGE_RUBY_VERSION:-3.3.12}"
17
+ here="$(cd "$(dirname "$0")" && pwd)"
18
+ work="$(mktemp -d)"
19
+ trap 'rm -rf "$work"' EXIT
20
+
21
+ export GITHUB_TOKEN="${GITHUB_TOKEN:-${GH_TOKEN:-}}"
22
+
23
+ asset="tebako-${tebako_version}-${triplet}"
24
+ gh release download "v${tebako_version}" --repo tamatebako/tebako \
25
+ --pattern "${asset}" --pattern "${asset}.sha256" --dir "$work"
26
+ (cd "$work" && shasum -a 256 -c "${asset}.sha256")
27
+ chmod +x "$work/$asset"
28
+
29
+ stage="$("$here/stage.sh" "$work/stage")"
30
+
31
+ mkdir -p "$(dirname "$output")"
32
+ output="$(cd "$(dirname "$output")" && pwd)/$(basename "$output")"
33
+
34
+ # tebako appends a trailer to the executable: never strip the result.
35
+ "$work/$asset" press --root "$stage" --entry-point bin/fontist \
36
+ --output "$output" --mode self-contained -R "$ruby_version"
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env bash
2
+ # Check that a packed (or installed) fontist works on its own.
3
+ #
4
+ # script/tebako/smoke.sh <fontist-executable>
5
+ #
6
+ # Uses a throwaway FONTIST_PATH, then a throwaway HOME, so it never touches a
7
+ # real ~/.fontist.
8
+ set -euo pipefail
9
+
10
+ fontist="${1:?usage: smoke.sh <fontist-executable>}"
11
+ font="${SMOKE_FONT:-Overpass}"
12
+
13
+ home="$(mktemp -d)"
14
+ trap 'rm -rf "$home"' EXIT
15
+ export FONTIST_PATH="$home"
16
+
17
+ "$fontist" --version
18
+ "$fontist" version
19
+ "$fontist" install --accept-all-licenses "$font"
20
+
21
+ if ! find "$home/fonts" -type f | grep -q .; then
22
+ echo "smoke: no font file landed under $home/fonts" >&2
23
+ exit 1
24
+ fi
25
+ "$fontist" list "$font" | tee "$home/list.txt"
26
+ grep -qi "installed" "$home/list.txt"
27
+
28
+ # Without FONTIST_PATH, fonts land in ~/.fontist.
29
+ user_home="$(mktemp -d)"
30
+ trap 'rm -rf "$home" "$user_home"' EXIT
31
+ env -u FONTIST_PATH HOME="$user_home" "$fontist" install --accept-all-licenses "$font"
32
+ if ! find "$user_home/.fontist/fonts" -type f | grep -q .; then
33
+ echo "smoke: no font file landed under $user_home/.fontist/fonts" >&2
34
+ exit 1
35
+ fi
36
+ echo "smoke: ok"