fontist 3.0.3 → 3.0.4

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: ef31ff4d5c017fd86187db92ab8eb9c428e694731d9bb7eb9be4dadbcb7ac210
4
- data.tar.gz: 87f038f05b151bb64f31fc0592d2b2b6e883414852623232c23e2cff12d37df3
3
+ metadata.gz: 5b2847a2098f7dc8ca7652bf08d8e01d5f2a0e826230631bbba3d7cc01831933
4
+ data.tar.gz: 777c69708edc12acfaee0f01d492e9c3eb573822e428da489726fed8a52e4ac7
5
5
  SHA512:
6
- metadata.gz: bad74c88e0eeb2d2cd12fb8e7c0f9e09663c9fc98ddbebdf0ab54b8f3eb90895414fa7fc5fb699356ff590f7f1ea1cb66cce11917415ecbe9d70112bc5f312e0
7
- data.tar.gz: 4c843a8d911ce97ff680fb3ac85d440e80f617982a77c82e6bc8cc6c40b32a050ff2daf50a109c73b174c7ec851e0999f4a6df77148546b9f44838b80205e83d
6
+ metadata.gz: da58a8c87b799c5db8241c5e951b26bd17a2e17d8bea327a4c479de1679c40feb6272bdc71a024e0fad6e4dd16743278e57a370c9d6ef021784a07968d6814a6
7
+ data.tar.gz: 22bb4499aa794f0534f850932df74aca65724e7019760fb7f6517233d1290cb2f5c2d3697e6046288acde4d21cb128b787f1d153aaaf50e1791c81a272d60b64
@@ -60,6 +60,14 @@ module Fontist
60
60
  self
61
61
  end
62
62
 
63
+ # Disable read-only mode, restoring normal index_changed? checks.
64
+ #
65
+ # @return [self] Returns self for chaining
66
+ def disable_read_only_mode
67
+ collection.disable_read_only_mode
68
+ self
69
+ end
70
+
63
71
  # Returns all fonts in the index
64
72
  #
65
73
  # @return [Array<SystemIndexFont>] All indexed fonts
@@ -33,9 +33,15 @@ module Fontist
33
33
  def style_paths(locations: false)
34
34
  ary = Array(styles)
35
35
  (ary.empty? ? [nil] : ary).flat_map do |style|
36
- find_font_with_name(name, style).tap do |x|
37
- raise Errors::MissingFontError.new(name, style) if x.nil? && locations
36
+ paths = find_font_with_name(name, style)
37
+
38
+ if paths.nil? && locations
39
+ try_install_missing_font
40
+ paths = find_font_with_name(name, style)
41
+ raise Errors::MissingFontError.new(name, style) if paths.nil?
38
42
  end
43
+
44
+ paths
39
45
  end.compact
40
46
  end
41
47
 
@@ -96,6 +102,27 @@ module Fontist
96
102
 
97
103
  private
98
104
 
105
+ def try_install_missing_font
106
+ Fontist.ui.debug("self-healing install attempt for #{name.inspect}")
107
+ Fontist::Font.install(
108
+ name,
109
+ force: true,
110
+ confirmation: "no",
111
+ no_progress: true,
112
+ hide_licenses: true,
113
+ format_spec: format_spec,
114
+ )
115
+ rescue Fontist::Errors::FontError,
116
+ Fontist::Errors::LicensingError,
117
+ Fontist::Errors::PlatformMismatchError,
118
+ Fontist::Errors::FormulaIndexNotFoundError => e
119
+ Fontist.ui.debug(
120
+ "self-healing install for #{name.inspect} " \
121
+ "failed: #{e.class}: #{e.message}",
122
+ )
123
+ nil
124
+ end
125
+
99
126
  def validate_location_parameter!(location)
100
127
  return unless location
101
128
  return if location.is_a?(Symbol)
@@ -183,7 +210,11 @@ module Fontist
183
210
 
184
211
  yield
185
212
  ensure
186
- # Always disable caching after the operation
213
+ # Always restore normal mode after the operation so the read-only flag
214
+ # does not leak across calls and turn the singletons effectively stale.
215
+ Fontist::Indexes::FontistIndex.instance.disable_read_only_mode
216
+ Fontist::Indexes::UserIndex.instance.disable_read_only_mode
217
+ Fontist::Indexes::SystemIndex.instance.disable_read_only_mode
187
218
  Fontist::SystemFont.disable_find_styles_cache
188
219
  end
189
220
 
@@ -229,11 +229,12 @@ module Fontist
229
229
  end
230
230
 
231
231
  def index
232
- # Fast path: if read_only mode is set, skip index_changed? check entirely
233
- # But we still need to build if fonts is nil (first time access)
234
- if @read_only_mode && !fonts.nil?
232
+ # Fast path: if read_only mode is set, skip index_changed? check entirely.
233
+ # But we still need to build on first access treat an empty fonts list
234
+ # the same as nil, since Lutaml initializes `instances :fonts` to `[]`
235
+ # rather than nil when the on-disk index file is absent.
236
+ if @read_only_mode && !fonts.nil? && !fonts.empty?
235
237
  return fonts
236
- # Fall through to build the index on first access
237
238
  end
238
239
 
239
240
  return fonts unless index_changed?
@@ -257,6 +258,14 @@ module Fontist
257
258
  self
258
259
  end
259
260
 
261
+ # Disable read-only mode so future `index` calls go through
262
+ # `index_changed?` again. Paired with `read_only_mode` to scope the
263
+ # optimization to a single block (see Manifest.with_performance_optimizations).
264
+ def disable_read_only_mode
265
+ @read_only_mode = false
266
+ self
267
+ end
268
+
260
269
  def index_changed?
261
270
  return true if fonts.nil? || fonts.empty?
262
271
  return false if @index_check_done # Skip if already verified in this session
data/lib/fontist/utils.rb CHANGED
@@ -71,7 +71,7 @@ module Fontist
71
71
 
72
72
  # On case-insensitive filesystems (Windows, macOS), use simple patterns
73
73
  # On case-sensitive filesystems (Linux), use character class patterns
74
- if %i[windows macosx].include?(Fontist::Utils::System.user_os)
74
+ if %i[windows macos].include?(Fontist::Utils::System.user_os)
75
75
  # Case-insensitive filesystem - simple patterns work fine
76
76
  extensions.map { |ext| File.join(prefix, "*.#{ext}") }
77
77
  else
@@ -1,3 +1,3 @@
1
1
  module Fontist
2
- VERSION = "3.0.3".freeze
2
+ VERSION = "3.0.4".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.3
4
+ version: 3.0.4
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-05-05 00:00:00.000000000 Z
11
+ date: 2026-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: down