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 +4 -4
- data/.github/workflows/rake-metanorma.yaml +0 -2
- data/lib/fontist/font.rb +33 -1
- data/lib/fontist/font_file.rb +15 -0
- data/lib/fontist/formula.rb +15 -0
- data/lib/fontist/manifest.rb +19 -1
- data/lib/fontist/scan_row_fonts.rb +14 -2
- data/lib/fontist/system_index.rb +24 -12
- data/lib/fontist/utils/downloader.rb +6 -1
- data/lib/fontist/utils/ui.rb +6 -1
- data/lib/fontist/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ddb4f7e4133bb57690d4c0a49d11a6b8474f71be5e16d21ef4dc4e54b64d8a83
|
|
4
|
+
data.tar.gz: 114f37e48e53bc1e1488cdc4542e004efe3e6e130eeaaf471a1863529cfda78f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 37f053fcd79f2e217b18bd7ba6dbded64dd419be1de9fad4560eb6ef176dde6e10c3ee110101484d3f3f697cc150b5123bde8adb8008c000947d438b72cbcb36
|
|
7
|
+
data.tar.gz: 1d01854ac729bc4838f03513cc90498e5dc3a41820eaac3d2f08a426ec3704c1e47de93f7475bee1df87233e08ebc449b3196c8b2a1a5f3152c5818070dbabd1
|
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
|
-
(
|
|
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|
|
data/lib/fontist/font_file.rb
CHANGED
|
@@ -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
|
data/lib/fontist/formula.rb
CHANGED
|
@@ -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
|
|
data/lib/fontist/manifest.rb
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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)
|
data/lib/fontist/system_index.rb
CHANGED
|
@@ -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.
|
|
213
|
-
#
|
|
214
|
-
#
|
|
215
|
-
#
|
|
216
|
-
#
|
|
217
|
-
|
|
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
|
|
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
|
-
|
|
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
|
data/lib/fontist/utils/ui.rb
CHANGED
|
@@ -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
|
-
|
|
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)
|
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: 3.0.
|
|
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-
|
|
11
|
+
date: 2026-11-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: down
|