fontist 3.0.39 → 3.0.41

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: e03c9358f15f7d26cf72315b563b764abe153d5c298829dcebdc8747718f2091
4
- data.tar.gz: dd8324d23bf57a9be39f0e6f9d56c2ffac617ecf54547e8f2cc809b6a0c8a187
3
+ metadata.gz: ddb4f7e4133bb57690d4c0a49d11a6b8474f71be5e16d21ef4dc4e54b64d8a83
4
+ data.tar.gz: 114f37e48e53bc1e1488cdc4542e004efe3e6e130eeaaf471a1863529cfda78f
5
5
  SHA512:
6
- metadata.gz: 8ff07d8998d064496efb6802911f38d0ab579e4ddbaf30edb2ad5a57824db866ca9089b3f5962ef61d6ae77f7ee415730fcd9f26b5aa4813b7b2d85b8423525d
7
- data.tar.gz: 1b1996c3d76481ac58f4ce7de3d1da760e3d148f4e5a077148fb7bf8160fd2f7e7a8aa820ba231ba75ebdb69be5a34ed668ad7beaff12d6bfb256ad6ef278e56
6
+ metadata.gz: 37f053fcd79f2e217b18bd7ba6dbded64dd419be1de9fad4560eb6ef176dde6e10c3ee110101484d3f3f697cc150b5123bde8adb8008c000947d438b72cbcb36
7
+ data.tar.gz: 1d01854ac729bc4838f03513cc90498e5dc3a41820eaac3d2f08a426ec3704c1e47de93f7475bee1df87233e08ebc449b3196c8b2a1a5f3152c5818070dbabd1
@@ -64,8 +64,6 @@ jobs:
64
64
  bundler: ${{ env.BUNDLER_VER }}
65
65
  bundler-cache: true
66
66
 
67
- - uses: metanorma/ci/inkscape-setup-action@main
68
-
69
67
  - name: Configure Git credentials
70
68
  env:
71
69
  GIT_TOKEN: ${{ secrets.FONTIST_CI_PAT_TOKEN }}
data/lib/fontist/font.rb CHANGED
@@ -69,7 +69,7 @@ module Fontist
69
69
  def install
70
70
  return install_formula if @by_formula
71
71
 
72
- (find_system_font unless @force) || download_font || manual_font ||
72
+ (find_installable_font unless @force) || download_font || manual_font ||
73
73
  raise_non_supported_font
74
74
  end
75
75
 
@@ -118,6 +118,38 @@ module Fontist
118
118
  paths # Return paths after printing
119
119
  end
120
120
 
121
+ # Install-time lookup under the static default: a variable font already
122
+ # on disk does not satisfy a plain request when the formula offers
123
+ # static files, so stale variable installs from older fontist versions
124
+ # cannot shadow the statics forever (fontist/fontist#556).
125
+ def find_installable_font
126
+ paths = Fontist::SystemFont.find(name)
127
+ unless paths
128
+ Fontist.ui.say(%(Font "#{name}" not found locally.))
129
+ return
130
+ end
131
+ return if static_variant_shadowed_locally?
132
+
133
+ print_paths(paths)
134
+ paths
135
+ end
136
+
137
+ def static_variant_shadowed_locally?
138
+ return false if @format_spec&.variable_requested?
139
+ return false if @format_spec&.all_variants
140
+ return false unless static_variant_locally?
141
+
142
+ Formula.offers_static_variant?(name)
143
+ end
144
+
145
+ def static_variant_locally?
146
+ located = Fontist::SystemFont.find_styles(name)
147
+ return false if located.nil? || located.empty?
148
+
149
+ located.any?(&:variable_font) &&
150
+ located.none? { |style| !style.variable_font }
151
+ end
152
+
121
153
  def print_paths(paths)
122
154
  Fontist.ui.say("Fonts found at:")
123
155
  paths.each do |path|
@@ -69,8 +69,12 @@ module Fontist
69
69
  # fonts from Fontisan hold no open file to close.
70
70
  variable = font.has_table?("fvar")
71
71
  font.close if font.respond_to?(:close)
72
+ # rubocop:disable Layout/LineLength
72
73
  names[:variable_instances] = extract_variable_instances_from_path(path) if
73
74
  variable && names[:family_name]
75
+ # rubocop:enable Layout/LineLength
76
+ names[:variable] = variable
77
+ names[:format] = detect_font_format(path)
74
78
  names
75
79
  rescue StandardError => e
76
80
  raise_font_file_error(e)
@@ -334,5 +338,16 @@ module Fontist
334
338
  def variable_instances
335
339
  @info[:variable_instances] || []
336
340
  end
341
+
342
+ # Whether the file carries an `fvar` table. The system index persists
343
+ # this per entry, so static-default resolution can tell variable files
344
+ # from static ones.
345
+ def variable
346
+ @info[:variable] || false
347
+ end
348
+
349
+ def format
350
+ @info[:format]
351
+ end
337
352
  end
338
353
  end
@@ -135,6 +135,21 @@ module Fontist
135
135
  Indexes::FontIndex.lookup_index.load_formulas(font_name)
136
136
  end
137
137
 
138
+ # Whether any formula answering to this font name offers a static
139
+ # (non-variable) file. With the static default (fontist/fontist#556),
140
+ # callers use this to decide whether variable files on disk may satisfy
141
+ # a plain request: when statics exist, they must be preferred even if a
142
+ # stale variable install from an older fontist version is present.
143
+ def offers_static_variant?(font_name)
144
+ find_many(font_name).compact.any? do |formula|
145
+ formula.all_fonts.flat_map(&:styles).any? do |style|
146
+ !style.variable_font?
147
+ end
148
+ end
149
+ rescue Errors::FormulaNotFoundError, Errors::FontIndexCorrupted
150
+ false
151
+ end
152
+
138
153
  def find_fonts(font_name)
139
154
  formulas = Indexes::FontIndex.lookup_index.load_formulas(font_name)
140
155
 
@@ -71,11 +71,29 @@ module Fontist
71
71
  # True when every located file fails the font's static/variant spec —
72
72
  # e.g. only a variable font's named instance resolves a variable: false
73
73
  # request — so installation must fetch files that actually match.
74
+ # With the static default, variable files on disk also do not satisfy a
75
+ # plain request when the formula offers static files: stale variable
76
+ # installs from older fontist versions would otherwise shadow the
77
+ # statics forever.
74
78
  def unsatisfied_by_spec?
79
+ located = style_paths
80
+ return true if located.empty?
81
+
82
+ return true if static_default_shadowed_by_variable?(located)
83
+
75
84
  return false unless format_spec.has_constraints?
76
85
 
77
86
  matcher = FormatMatcher.new(format_spec)
78
- style_paths.all? { |indexed| !matcher.matches_indexed_font?(indexed) }
87
+ located.all? { |indexed| !matcher.matches_indexed_font?(indexed) }
88
+ end
89
+
90
+ def static_default_shadowed_by_variable?(located)
91
+ return false if format_spec.variable_requested?
92
+ return false if format_spec.all_variants
93
+
94
+ located.all? { |indexed| indexed.variable_font } &&
95
+ located.any? { |indexed| indexed.variable_font } &&
96
+ Fontist::Formula.offers_static_variant?(name)
79
97
  end
80
98
 
81
99
  def install(confirmation: "no", hide_licenses: false, no_progress: false,
@@ -23,14 +23,26 @@ module Fontist
23
23
  end
24
24
  end
25
25
 
26
- def file_font(row)
26
+ def file_font(row, path)
27
27
  report_validation(row)
28
28
  info = symbolize(row["names"] || {})
29
+ add_variable_metadata(info, row)
30
+ info[:format] = format_for(path)
31
+ FontFile.new(info)
32
+ end
33
+
34
+ def add_variable_metadata(info, row)
29
35
  if row["has_fvar"] && info[:family_name]
30
36
  info[:variable_instances] =
31
37
  row["variable_instances"].map { |i| symbolize(i) }
32
38
  end
33
- FontFile.new(info)
39
+ info[:variable] = row.key?("has_fvar") ? !!row["has_fvar"] : nil
40
+ end
41
+
42
+ def format_for(path)
43
+ Fontisan::FontLoader.detect_format(path)&.to_s
44
+ rescue StandardError
45
+ "unknown"
34
46
  end
35
47
 
36
48
  def collection_face(row)
@@ -209,12 +209,13 @@ module Fontist
209
209
  # Don't rebuild index more frequently than this (in seconds)
210
210
  INDEX_REBUILD_THRESHOLD = 30 * 60 # 30 minutes
211
211
 
212
- # Index entry shape generation. v1 stored one entry per font file;
213
- # v2 stores one entry per named instance of variable fonts (the
214
- # FiraCode[wght].ttf class of files). Bump when the entry shape
215
- # changes again: persisted indexes carrying an older generation
216
- # cannot answer the current lookups and force a rebuild.
217
- INDEX_FORMAT_VERSION = 2
212
+ # Index entry shape generation. v2 stored one entry per named instance
213
+ # of variable fonts but left the `variable_font`/`format` metadata
214
+ # unset; v3 persists both, so static-default resolution can tell
215
+ # variable files from static ones. Bump when the entry shape changes
216
+ # again: persisted indexes carrying an older generation cannot answer
217
+ # the current lookups and force a rebuild.
218
+ INDEX_FORMAT_VERSION = 3
218
219
 
219
220
  def metadata_path
220
221
  "#{@path}.metadata.yml"
@@ -746,12 +747,16 @@ verbose:, stats:)
746
747
  def build_entries_from_rows(path, rows)
747
748
  if rows.first["is_collection"]
748
749
  ScanRowFonts.warn_collection_extension(path)
749
- rows.map { |row| parse_font(ScanRowFonts.collection_face(row), path) }
750
+ rows.map { |row| parse_font(ScanRowFonts.collection_face(row), path,
751
+ format: ScanRowFonts.format_for(path),
752
+ variable_font: false) }
750
753
  else
751
754
  ScanRowFonts.warn_file_extension(path, rows.first)
752
- font_file = ScanRowFonts.file_font(rows.first)
755
+ font_file = ScanRowFonts.file_font(rows.first, path)
753
756
  entries = variable_font_entries(font_file, path)
754
- entries.empty? ? parse_font(font_file, path) : entries
757
+ entries.empty? ? parse_font(font_file, path,
758
+ format: font_file.format,
759
+ variable_font: font_file.variable) : entries
755
760
  end
756
761
  end
757
762
 
@@ -853,7 +858,9 @@ spinner_index = nil)
853
858
  entries = variable_font_entries(font_file, path)
854
859
  return entries unless entries.empty?
855
860
 
856
- parse_font(font_file, path)
861
+ parse_font(font_file, path,
862
+ format: font_file.format,
863
+ variable_font: font_file.variable)
857
864
  end
858
865
 
859
866
  # One index entry per named instance of a variable font: a variable
@@ -888,19 +895,22 @@ spinner_index = nil)
888
895
  preferred_subfamily_name: instance[:style],
889
896
  file_size: file_size,
890
897
  file_mtime: file_mtime,
898
+ format: font_file.format,
899
+ variable_font: font_file.variable,
891
900
  )
892
901
  end
893
902
  end
894
903
 
895
904
  def detect_collection_fonts(path)
905
+ format = Fontisan::FontLoader.detect_format(path)&.to_s
896
906
  CollectionFile.from_path(path) do |collection|
897
907
  collection.map do |font_file|
898
- parse_font(font_file, path)
908
+ parse_font(font_file, path, format: format, variable_font: false)
899
909
  end
900
910
  end
901
911
  end
902
912
 
903
- def parse_font(font_file, path)
913
+ def parse_font(font_file, path, format:, variable_font:)
904
914
  # Skip fonts with incomplete metadata
905
915
  unless font_file.full_name && font_file.family
906
916
  warn_incomplete_metadata(path)
@@ -928,6 +938,8 @@ spinner_index = nil)
928
938
  preferred_subfamily_name: font_file.preferred_subfamily_name,
929
939
  file_size: file_size,
930
940
  file_mtime: file_mtime,
941
+ format: format,
942
+ variable_font: variable_font,
931
943
  )
932
944
  end
933
945
 
@@ -6,7 +6,12 @@ module Fontist
6
6
  RATE_LIMITED_HTTP_STATUS = 429
7
7
  BACKOFF = {
8
8
  rate_limited: [10, 20, 40, 60, 90].freeze,
9
- transient: [2, 4].freeze,
9
+ # Two quick retries give snappy hosts a second chance, and the
10
+ # slower tail absorbs large shared archives: web.archive.org and
11
+ # similar mirror hosts routinely fail single requests with
12
+ # timeouts or reset connections and recover within seconds
13
+ # (metanorma S-201 builds hit this on EUupdate.EXE).
14
+ transient: [2, 4, 8, 15].freeze,
10
15
  }.freeze
11
16
  MAX_RETRY_AFTER = 120
12
17
  JITTER_RATIO = 0.25
@@ -35,8 +35,13 @@ module Fontist
35
35
  new.say(message, :green) if log_levels.include?(:info)
36
36
  end
37
37
 
38
+ # Errors go to stderr so that callers who redirect stdout — pipelines
39
+ # that capture fontist YAML output into a file — never receive error
40
+ # prose in place of data (metanorma/mn2pdf#466).
38
41
  def self.error(message)
39
- new.say(message, :red) if log_levels.include?(:warn)
42
+ return unless log_levels.include?(:warn)
43
+
44
+ $stderr.puts new.set_color(message, :red)
40
45
  end
41
46
 
42
47
  def self.warn(message)
@@ -1,3 +1,3 @@
1
1
  module Fontist
2
- VERSION = "3.0.39".freeze
2
+ VERSION = "3.0.41".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: 3.0.39
4
+ version: 3.0.41
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-11-23 00:00:00.000000000 Z
11
+ date: 2026-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: down