fontist 3.0.40 → 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/lib/fontist/font_file.rb +15 -0
- data/lib/fontist/scan_row_fonts.rb +14 -2
- data/lib/fontist/system_index.rb +24 -12
- data/lib/fontist/version.rb +1 -1
- metadata +1 -1
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_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
|
|
@@ -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
|
|
data/lib/fontist/version.rb
CHANGED