fontist 3.0.23 → 3.0.24
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 954fe79bde0fb84cf7b2fcc96b686820a7c2f4fd6ec822abd4067b1c0d8c288e
|
|
4
|
+
data.tar.gz: ac7eb9f594dd5a9be155e2893c4a07bad197743e107a92f16786b45f47000224
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9616ce9f46708c5acb1dc4643688f8ab0a43eeb5eafc7ee8259e9d5a110e415c738514cc00739d937b41d05d1b64868256419f3303d32159aeb41f462f260207
|
|
7
|
+
data.tar.gz: ba15c400a1fed88380cd28f8669c7272e6d52cf0dcf4df09f42166cc0b95cf55db36dcf5456bd3704981550308e087b2074f3aaaa9419567e75733ff96099bbf
|
|
@@ -209,15 +209,29 @@ module Fontist
|
|
|
209
209
|
def create_and_add_entry(key, paths)
|
|
210
210
|
entry = FormulaKeyToPath.new(key: key, formula_path: paths)
|
|
211
211
|
entries << entry
|
|
212
|
+
@entries_lookup_id = nil
|
|
212
213
|
@index_build_cache[key] = entry if @index_build_cache
|
|
213
214
|
end
|
|
214
215
|
|
|
216
|
+
# O(1) key lookup over the entries; rebuilt whenever the entries
|
|
217
|
+
# array identity changes (rebuilds parse fresh instances, and
|
|
218
|
+
# in-place additions drop the cached hash)
|
|
219
|
+
def entries_lookup
|
|
220
|
+
entries_id = Array(entries).object_id
|
|
221
|
+
if @entries_lookup_id != entries_id
|
|
222
|
+
@entries_lookup_id = entries_id
|
|
223
|
+
@entries_lookup = Array(entries)
|
|
224
|
+
.group_by { |entry| normalize_key(entry.key) }
|
|
225
|
+
end
|
|
226
|
+
@entries_lookup
|
|
227
|
+
end
|
|
228
|
+
|
|
215
229
|
def index_formula(key)
|
|
216
230
|
Array(entries).detect { |f| normalize_key(f.key) == normalize_key(key) }
|
|
217
231
|
end
|
|
218
232
|
|
|
219
233
|
def index_formulas(key)
|
|
220
|
-
|
|
234
|
+
entries_lookup[normalize_key(key)] || []
|
|
221
235
|
end
|
|
222
236
|
|
|
223
237
|
def relative_formula_path(path)
|
data/lib/fontist/system_index.rb
CHANGED
|
@@ -209,15 +209,13 @@ module Fontist
|
|
|
209
209
|
|
|
210
210
|
return nil if current_fonts.nil? || current_fonts.empty?
|
|
211
211
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
file.family_name&.casecmp?(font) && file.type&.casecmp?(style)
|
|
212
|
+
bucket = family_lookup(current_fonts)[font.to_s.downcase] || []
|
|
213
|
+
found_fonts =
|
|
214
|
+
if style.nil?
|
|
215
|
+
bucket
|
|
216
|
+
else
|
|
217
|
+
bucket.select { |file| file.type&.casecmp?(style) }
|
|
219
218
|
end
|
|
220
|
-
end
|
|
221
219
|
|
|
222
220
|
# Apply format filtering if specified
|
|
223
221
|
if format_spec&.has_constraints? && found_fonts
|
|
@@ -229,6 +227,25 @@ module Fontist
|
|
|
229
227
|
found_fonts.empty? ? nil : found_fonts
|
|
230
228
|
end
|
|
231
229
|
|
|
230
|
+
# Drops the cached family lookup; called when fonts are removed in
|
|
231
|
+
# place (a rebuild replaces the fonts array, which re-keys the
|
|
232
|
+
# lookup by itself)
|
|
233
|
+
def invalidate_lookups!
|
|
234
|
+
@family_lookup_fonts_id = nil
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
# O(1) family-name lookup over the indexed fonts; rebuilt whenever
|
|
238
|
+
# the fonts array identity changes
|
|
239
|
+
def family_lookup(current_fonts)
|
|
240
|
+
fonts_id = Array(current_fonts).object_id
|
|
241
|
+
if @family_lookup_fonts_id != fonts_id
|
|
242
|
+
@family_lookup_fonts_id = fonts_id
|
|
243
|
+
@family_lookup = Array(current_fonts)
|
|
244
|
+
.group_by { |file| file.family_name&.downcase }
|
|
245
|
+
end
|
|
246
|
+
@family_lookup
|
|
247
|
+
end
|
|
248
|
+
|
|
232
249
|
def index
|
|
233
250
|
if @read_only_mode && !fonts.nil?
|
|
234
251
|
return fonts
|
data/lib/fontist/version.rb
CHANGED