fontisan 0.4.51-java → 0.4.52-java

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: b2a75a79d142a84db29cdf6fc713dd4e5fbaaa78060d44b5313e49bf3535562f
4
- data.tar.gz: 59791f20c18ad2f14baf9483e1b9f425c40ee145d85df15bab27b2287a800b1f
3
+ metadata.gz: 6da29f815bd38495314d5414cc6862358e09d2d6fa1e343f510fc1b5cc3df65c
4
+ data.tar.gz: 143de0bd18fae1ac8a34bfde12a09281e38b62607066a765ca9b514a4c9b1479
5
5
  SHA512:
6
- metadata.gz: 38b68b95d2b2e763db44d194c1f1fa54d1ac7fa7d28e106eb0cfc22a9e4645dcb98ea069f0a0d9c837ea249f436831050a1450265d7fc9b776c3ea78abeb0930
7
- data.tar.gz: 3274daceec582e533843c740965c7f9b84f1115b5ce38cf0a1b1c03a93b514d7c3717bec9b83a77f36bb5871bf5fc41799914e98309b8bb9f96f930de33ab4ed
6
+ metadata.gz: c9d2d9c95f615cbfc503f7bac1acd88660ef905edc5ae17dec1842499696488bb82aa96360d8c8d38399453ca3d7d499cc597aab60e46baf28696a5dacd62b2b
7
+ data.tar.gz: da0cde06d6ca8cb5fcee97c5bf63a21378597dc99cb87d86255fbb2672d3f9eaa1d887d9d12e743286119d24ca17986eb4043637d59f068b914a1c6de943e4e9
data/Cargo.lock CHANGED
@@ -185,7 +185,7 @@ dependencies = [
185
185
  [[package]]
186
186
  name = "fontisan"
187
187
  version = "0.0.0"
188
- source = "git+https://github.com/fontist/fontisan-rs?rev=8de6ac6bc838d2bf796a032c76cee78fe32ec671#8de6ac6bc838d2bf796a032c76cee78fe32ec671"
188
+ source = "git+https://github.com/fontist/fontisan-rs?rev=eedd92987b6d08a62b3451a7c03757d0340ebc79#eedd92987b6d08a62b3451a7c03757d0340ebc79"
189
189
  dependencies = [
190
190
  "brotli",
191
191
  "brotli-decompressor",
@@ -72,15 +72,15 @@ The full capability matrix (a 2026-11 audit of the engine tier, `lib/fontisan/na
72
72
 
73
73
  | Operation | native / ffi serve | Ruby only |
74
74
  |---|---|---|
75
- | `read` (metadata/full, lazy) | every format the engine reads, dfont included | Type 1 (PFB/PFA) |
76
- | `audit`, `audit_dir` (+ `validate`) | engine-readable files and directories | entries the engine cannot read |
77
- | `scan` | engine-readable files | non-font files |
78
- | `convert` to ttf/otf/woff/woff2/svg; collections to ttc/otc/woff2 | engine-readable inputs; an `.otc` input carries the caller's source hint (#192 gap 7) | Type 1 conversions; a single font to a collection format |
75
+ | `read` (metadata/full, lazy) | every format the engine reads, dfont included; a Type 1 file serves the facade's own measured surface — the loader parses the PFB segments, then the read raises the `Type1Font` `NoMethodError` (#192 gap 4) | |
76
+ | `audit`, `audit_dir` (+ `validate`) | engine-readable files and directories; a Type 1 file serves the same surface, and an `audit_dir` walk serves through the tier with its Type 1 rows handed back to Ruby (each tagged `served_by: "ruby"`) | |
77
+ | `scan` | engine-readable files | Type 1 and non-font files |
78
+ | `convert` to ttf/otf/woff/woff2/svg; collections to ttc/otc/woff2 | engine-readable inputs; an `.otc` input carries the caller's source hint (#192 gap 7); a Type 1 input serves the facade's conversion error | a single font to a collection format |
79
79
  | `extract` (collection member) | collections | |
80
80
  | `instance` (TTF variable font) | single fonts | |
81
81
  | `subset` (web/pdf/minimal) | engine-readable single fonts and collections | |
82
- | `glyph_ids` | single fonts, dfonts and collections on both tiers | Type 1 |
83
- | `outline_hashes` | single fonts, dfonts and collections on both tiers | Type 1 |
82
+ | `glyph_ids` | single fonts, dfonts and collections on both tiers; Type 1 serves the facade's `table` surface (#192 gap 4) | |
83
+ | `outline_hashes` | single fonts, dfonts and collections on both tiers; Type 1 serves the facade's `has_table?` surface (#192 gap 4) | |
84
84
 
85
85
  An SVG font as a *source* is not a format fontisan reads at all (there is no `from: svg` conversion), so it is not a tier question.
86
86
 
@@ -88,6 +88,7 @@ Also always on Ruby, whichever engine is selected — strict mode does not raise
88
88
 
89
89
  - The object-based API: `Fontisan::Subset::Builder.new(font, ...)` and `Fontisan::Variable::Instancer`. Only the path-based `Reference.subset` and `Reference.instance` can use another tier.
90
90
  - A FIFO, device or socket as an input path (the engine's released read would block uninterruptibly; Ruby's read is interruptible).
91
+ - A file the format detector cannot name: every operation keeps it with Ruby.
91
92
  - CLI commands other than `convert`, `unpack`, `subset` and `instance`, and the non-plain convert cases listed above (several targets, instance coordinates, conversion options, hinting, a font index).
92
93
 
93
94
  ## Platforms
@@ -138,15 +138,32 @@ module Fontisan
138
138
  Array(options[:unicodes]).all? { |cp| cp.is_a?(Integer) && cp.between?(0, MAX_CODEPOINT) }
139
139
  end
140
140
 
141
- # One Integer face index on an engine-readable single font or
142
- # collection; Type 1 files stay with the Ruby tier.
141
+ # One Integer face index on any detected input; Type 1 included (its
142
+ # surface serves through the engine, #192 gap 4).
143
143
  def outline_hashes_options?(options, path)
144
144
  return false unless options.keys.sort == %i[index]
145
145
  return false unless options[:index].is_a?(Integer) && options[:index].between?(0, MAX_FONT_INDEX)
146
146
  return false unless path.is_a?(String)
147
147
 
148
+ !FontLoader.detect_format(path).nil?
149
+ rescue StandardError
150
+ false
151
+ end
152
+
153
+ # A file the shared detector cannot name: the byte operations keep it
154
+ # with Ruby — detector parity is the serving contract, and the engine
155
+ # tier's own supports check declines unknown bytes (native) just the same.
156
+ def undetectable?(path)
157
+ FontLoader.detect_format(path).nil?
158
+ rescue StandardError
159
+ true
160
+ end
161
+
162
+ # A detected PFB segment file or PFA header (#192 gap 4): scan keeps
163
+ # these with Ruby; the op surfaces serve through the tiers.
164
+ def type1_file?(path)
148
165
  format = FontLoader.detect_format(path)
149
- !format.nil? && !%i[pfa pfb].include?(format)
166
+ !format.nil? && %i[pfa pfb].include?(format)
150
167
  rescue StandardError
151
168
  false
152
169
  end
@@ -156,6 +173,7 @@ module Fontisan
156
173
  def glyph_ids_options?(options, path)
157
174
  return false unless options.keys.all? { |key| %i[unicodes text].include?(key) }
158
175
  return false if path.nil?
176
+ return false if undetectable?(path)
159
177
 
160
178
  text = options[:text]
161
179
  return false unless text.nil? || text.is_a?(String)
@@ -275,11 +293,30 @@ module Fontisan
275
293
  raised, text = public_failure(klass, message)
276
294
  # The leaked Ruby error stays as the cause, as the Ruby tier's does.
277
295
  causes = [[class_name, message], *causes] unless raised == klass
296
+ causes = with_wrapper_cause(raised, text, causes)
278
297
  cause = nil
279
298
  causes.reverse_each { |name, detail| cause = build_exception(name, detail, cause) }
280
299
  raise build_instance(raised, text), cause: cause
281
300
  end
282
301
 
302
+ # Ruby raises the malformed-font wrapper ({Reference.malformed_font})
303
+ # inside the leaked parser error's rescue, so the live exception chains
304
+ # that leak as its cause. The engine's wrapper message carries the same
305
+ # pair, so the tiers rebuild the cause from it whenever the engine's own
306
+ # cause list does not already end in it.
307
+ def with_wrapper_cause(klass, message, causes)
308
+ return causes unless klass == InvalidFontError
309
+
310
+ match = /\AMalformed font data \(([^)]+)\): (.+)\z/m.match(message) or return causes
311
+ leak = Object.const_get(match[1])
312
+ return causes unless Reference::PARSER_LEAKS.any? { |l| leak <= l }
313
+
314
+ pair = [leak.name, match[2]]
315
+ causes.last == pair ? causes : [*causes, pair]
316
+ rescue NameError
317
+ causes
318
+ end
319
+
283
320
  # An engine error that mirrors a Ruby parser leak (EOFError, NoMethodError,
284
321
  # ...) is raised as the Ruby tier raises it now: InvalidFontError.
285
322
  def public_failure(klass, message)
data/lib/fontisan/ffi.rb CHANGED
@@ -37,7 +37,8 @@ module Fontisan
37
37
  LIBRARY = "fontisan_cdylib"
38
38
  OPERATIONS = %i[read audit audit_dir scan convert extract instance subset
39
39
  glyph_ids outline_hashes].freeze
40
- # dfont is served since #192 gap 5; Type 1 stays Ruby until gap 4.
40
+ # Type 1 is served through the op surfaces (#192 gap 4) — but scan keeps
41
+ # Type 1 rows with Ruby, whose rows the scan goldens record byte for byte.
41
42
  RUBY_ONLY_FORMATS = %i[pfa pfb].freeze
42
43
 
43
44
  OP_CONVERT = 1
@@ -79,11 +80,22 @@ module Fontisan
79
80
  def supports?(operation, path = nil)
80
81
  return false unless available? && OPERATIONS.include?(operation)
81
82
 
83
+ # A file the detector cannot name stays with Ruby on every operation
84
+ # (the regular-file check comes first: detection reads bytes, and
85
+ # reading a FIFO would block). scan keeps Type 1 with Ruby — its rows
86
+ # are what the scan goldens record byte for byte; audit_dir serves the
87
+ # walk and hands the Type 1 rows back (ruby_entry); the other
88
+ # operations serve the Type 1 surface (#192 gap 4).
89
+ if path.is_a?(String)
90
+ return false if File.file?(path) && undetectable?(path)
91
+
92
+ return false if operation == :scan && File.file?(path) && type1_file?(path)
93
+ end
94
+
82
95
  case operation
83
- when *ByteOps::BYTE_OPERATIONS then path.is_a?(String) && File.file?(path) && !ruby_only?(path)
96
+ when *ByteOps::BYTE_OPERATIONS then path.is_a?(String) && File.file?(path)
84
97
  when :audit_dir then path.nil? || File.directory?(path)
85
- when :scan then path.nil? || File.file?(path) && !ruby_only?(path)
86
- else path.nil? || File.file?(path) && !ruby_only?(path)
98
+ else path.nil? || File.file?(path)
87
99
  end
88
100
  end
89
101
 
@@ -150,11 +162,11 @@ module Fontisan
150
162
  bundled && File.file?(bundled) ? bundled : File.expand_path("ffi/#{file}", __dir__)
151
163
  end
152
164
 
153
- # dfont, Type 1 and anything that is not a font (the native tier hands
154
- # those to Ruby too, so auto never lands them on this tier).
155
- def ruby_only?(path)
165
+ # Type 1 (a detected PFB segment file or PFA header): scan hands those
166
+ # to Ruby; the op surfaces serve through here.
167
+ def type1_file?(path)
156
168
  format = FontLoader.detect_format(path)
157
- format.nil? || RUBY_ONLY_FORMATS.include?(format)
169
+ !format.nil? && RUBY_ONLY_FORMATS.include?(format)
158
170
  rescue StandardError
159
171
  false
160
172
  end
@@ -385,6 +397,9 @@ module Fontisan
385
397
  klass, message = public_failure(exception_class(head["class"]), head["message"])
386
398
  chain = [head, *Array(report["causes"])]
387
399
  chain.unshift({ "class" => klass.name, "message" => message }) if klass == InvalidFontError && head["class"] != klass.name
400
+ chain = with_wrapper_cause(klass, chain.first["message"],
401
+ chain.map { |info| [info["class"], info["message"]] })
402
+ .map { |(name, detail)| { "class" => name, "message" => detail } }
388
403
  raise_chain(chain)
389
404
  end
390
405
 
@@ -26,7 +26,7 @@ module Fontisan
26
26
  # engine pin in ext/*/Cargo.toml, which each build embeds. ABI_VERSION does
27
27
  # not move on a repin, so this is what keeps a stale binary from serving old
28
28
  # behaviour. A repin seds it with the Cargo files (repin-push162.sh).
29
- ENGINE_REV = "8de6ac6bc838d2bf796a032c76cee78fe32ec671"
29
+ ENGINE_REV = "eedd92987b6d08a62b3451a7c03757d0340ebc79"
30
30
 
31
31
  # Operations served natively. Convert, extract, instance and subset are
32
32
  # path-based only (card 2f): the object-based entry points
@@ -63,21 +63,38 @@ module Fontisan
63
63
  end
64
64
 
65
65
  # @return [Boolean] whether the extension serves +operation+ for +path+.
66
- # dfont and Type 1 files, missing files and non-directories (for
67
- # audit_dir) stay with the Ruby tier.
66
+ # Type 1 stays with the Ruby tier for scan and audit_dir (its rows are
67
+ # what the scan goldens record; #192 gap 4); missing files and
68
+ # non-directories (for audit_dir) stay with the Ruby tier too.
68
69
  def supports?(operation, path = nil)
69
70
  return false unless available? && OPERATIONS.include?(operation)
70
71
  return false unless path.is_a?(String)
71
72
 
73
+ # The regular-file check comes first: detection reads bytes, and
74
+ # reading a FIFO would block. scan keeps Type 1 with Ruby (its rows
75
+ # are what the scan goldens record); audit_dir serves the walk and
76
+ # hands the Type 1 rows back (audit_with_ruby). Undetectable bytes
77
+ # decline through native_supports_file.
78
+ regular = File.file?(path)
79
+ return false if operation == :scan && regular && path_is_type1?(path)
80
+
72
81
  case operation
73
82
  when :audit_dir then File.directory?(path)
74
83
  # A FIFO, device or socket is never handed to the extension: it would
75
84
  # block in the engine's read with the GVL released, where no signal or
76
85
  # Timeout can interrupt it. Ruby's read is interruptible.
77
- else File.file?(path) && native_supports_file(path)
86
+ else regular && native_supports_file(path)
78
87
  end
79
88
  end
80
89
 
90
+ # A detected PFB segment file or PFA header.
91
+ def path_is_type1?(path)
92
+ format = FontLoader.detect_format(path)
93
+ !format.nil? && %i[pfa pfb].include?(format)
94
+ rescue StandardError
95
+ false
96
+ end
97
+
81
98
  # Options the extension honours; anything else is served by Ruby.
82
99
  # +path+ is the call's input path (the Engine passes it when this method
83
100
  # takes a third argument): collection inputs and the `.otc` hint decide
@@ -221,8 +238,8 @@ module Fontisan
221
238
  end
222
239
 
223
240
  # Same entries as Reference.audit_dir. A file the engine leaves to Ruby
224
- # (dfont, Type 1) is audited through the gate, so it is served and
225
- # recorded as :ruby.
241
+ # (Type 1) is handed back: audited on the Ruby tier and recorded as
242
+ # :ruby.
226
243
  def audit_dir(dir, validate: false)
227
244
  dir = File.path(dir)
228
245
  native_audit_dir_rows(dir, validate ? true : false).filter_map do |row|
@@ -246,11 +263,18 @@ module Fontisan
246
263
  end
247
264
  end
248
265
 
266
+ # A file the engine does not read (Type 1): the Ruby tier audits it.
249
267
  def audit_with_ruby(file, rel, validate)
250
- { "faces" => Fontisan::Reference.audit(file, validate: validate), "path" => rel }
268
+ seen_by(file, :ruby)
269
+ { "faces" => Engine.ruby_call(:audit, file, validate: validate), "path" => rel }
251
270
  rescue StandardError => e
252
271
  { "error" => { "class" => e.class.name, "message" => e.message }, "path" => rel }
253
272
  end
273
+
274
+ def seen_by(file, tier)
275
+ recorder = Thread.current[Engine::ROW_RECORDER]
276
+ recorder[file] = tier if recorder
277
+ end
254
278
  end
255
279
  end
256
280
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Fontisan
4
- VERSION = "0.4.51"
4
+ VERSION = "0.4.52"
5
5
  end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Corrupt-PFB surface probe: which inputs fail at PFB-parse time vs reach the
4
+ # Type1Font object (and its post-parse NoMethodError surface).
5
+ require "fontisan"
6
+
7
+ def surf(name, bytes)
8
+ File.binwrite("/tmp/probe.pfb", bytes)
9
+ Fontisan::Reference.read("/tmp/probe.pfb")
10
+ puts "#{name}: OK?!"
11
+ rescue StandardError => e
12
+ puts "#{name}: #{e.class}: #{e.message[0, 130]}"
13
+ end
14
+
15
+ orig = File.binread("corpus/fonts/fonttools-test-t1-pfb/TestT1-Regular.pfb")
16
+
17
+ bad = orig.dup
18
+ bad.setbyte(0, 0x7F)
19
+ surf("bad marker", bad)
20
+ surf("truncated-10", orig[0, 10])
21
+ surf("truncated-half", orig[0, orig.bytesize / 2])
22
+ surf("header-only", orig[0, 6])
23
+ surf("binary-seg-claimed-past-eof", orig[0, 6] + [0x80, 0x02, 0xFF, 0xFF, 0x00, 0x00].pack("C6"))
@@ -0,0 +1,112 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Type 1 surface validation (#192 gap 4 stage 1): every op on the corpus PFB
4
+ # raises the measured Ruby surface through both tiers, byte-identical.
5
+ require "fontisan"
6
+
7
+ FONT = File.expand_path("../../fontisan-rs/.corpus/fontisan/corpus/fonts/TestT1-Regular.pfb", __dir__)
8
+ failures = []
9
+
10
+ EXPECTED = {
11
+ read: ["Fontisan::InvalidFontError",
12
+ /Malformed font data \(NoMethodError\): undefined method 'has_table\?' for an instance of Fontisan::Type1Font/],
13
+ audit: ["Fontisan::InvalidFontError",
14
+ /undefined method 'has_table\?' for an instance of Fontisan::Type1Font/],
15
+ outline_hashes: ["Fontisan::InvalidFontError",
16
+ /undefined method 'has_table\?' for an instance of Fontisan::Type1Font/],
17
+ glyph_ids: ["Fontisan::InvalidFontError",
18
+ /undefined method 'table' for an instance of Fontisan::Type1Font/],
19
+ subset: ["Fontisan::InvalidFontError",
20
+ /undefined method 'table' for an instance of Fontisan::Type1Font/],
21
+ instance: ["Fontisan::InvalidFontError",
22
+ /undefined method 'table_data' for an instance of Fontisan::Type1Font/],
23
+ }.freeze
24
+
25
+ def outcome(tier, operation, path, **)
26
+ ENV["FONTISAN_ENGINE"] = tier
27
+ Fontisan::Engine.reset!
28
+ Fontisan::Reference.public_send(operation, path, **)
29
+ :ok
30
+ rescue StandardError, ScriptError => e
31
+ "#{e.class}: #{e.message}"
32
+ end
33
+
34
+ def served_scan(tier, path)
35
+ ENV["FONTISAN_ENGINE"] = tier
36
+ Fontisan::Engine.reset!
37
+ Fontisan::Engine.scan([path])
38
+ Fontisan::Engine.served_by(:scan).to_s
39
+ end
40
+
41
+ # Returns [served_by(:audit_dir), row_ok]: the walk serves through the tier
42
+ # and its single Type 1 row is handed back to Ruby (Ruby's audit raises, the
43
+ # walk records the error row, the tag reads :ruby).
44
+ def served_audit_dir(tier, path)
45
+ ENV["FONTISAN_ENGINE"] = tier
46
+ Fontisan::Engine.reset!
47
+ require "tmpdir"
48
+ require "fileutils"
49
+ entries = Dir.mktmpdir("t1-audit") do |dir|
50
+ FileUtils.cp(path, dir)
51
+ Fontisan::Engine.audit_dir(dir)
52
+ end
53
+ entry = entries.first || {}
54
+ ok = entry["served_by"] == "ruby" &&
55
+ entry.dig("error", "message").to_s.include?("undefined method 'has_table?'")
56
+ [Fontisan::Engine.served_by(:audit_dir).to_s, ok]
57
+ end
58
+
59
+ %w[native ffi].each do |tier|
60
+ EXPECTED.each do |operation, (klass, message)|
61
+ opts = if %i[glyph_ids subset].include?(operation)
62
+ { text: "AB" }
63
+ elsif operation == :instance
64
+ { coords: { "wght" => 500 } }
65
+ elsif operation == :outline_hashes
66
+ { index: 0 }
67
+ else
68
+ {}
69
+ end
70
+ got = outcome(tier, operation, FONT, **opts)
71
+ ok = got.start_with?(klass) && got.match?(message)
72
+ failures << "#{tier} #{operation}: #{got[0, 140]}" unless ok
73
+ next if operation == :read
74
+
75
+ served = if %i[glyph_ids subset].include?(operation)
76
+ ENV["FONTISAN_ENGINE"] = tier
77
+ Fontisan::Engine.reset!
78
+ begin
79
+ Fontisan::Reference.public_send(operation, FONT, **opts)
80
+ rescue StandardError
81
+ nil
82
+ end
83
+ Fontisan::Engine.served_by(operation).to_s
84
+ else
85
+ tier
86
+ end
87
+ failures << "#{tier} #{operation} served_by #{served}" unless served == tier
88
+ end
89
+
90
+ got = outcome(tier, :convert, FONT, to: :ttf, output: "/tmp/t1-v-#{tier}.ttf")
91
+ ok = got.start_with?("Fontisan::Error") &&
92
+ got.include?("undefined method 'table_data' for an instance of Fontisan::Type1Font")
93
+ failures << "#{tier} convert: #{got[0, 110]}" unless ok
94
+
95
+ # scan keeps its Ruby rows (the goldens record Ruby's); audit_dir serves
96
+ # the walk through the tier and hands the Type 1 row back to Ruby.
97
+ outcome(tier, :scan, [FONT])
98
+ served = served_scan(tier, FONT)
99
+ failures << "#{tier} scan served_by #{served}" unless served == "ruby"
100
+
101
+ served, row_ok = served_audit_dir(tier, FONT)
102
+ failures << "#{tier} audit_dir served_by #{served}" unless served == tier
103
+ failures << "#{tier} audit_dir row not handed back to Ruby" unless row_ok
104
+ end
105
+
106
+ if failures.empty?
107
+ puts "TYPE 1 SURFACES PASS (native + ffi)"
108
+ else
109
+ puts "FAILURES (#{failures.length}):"
110
+ failures.first(10).each { |f| puts " #{f}" }
111
+ exit 1
112
+ end
@@ -0,0 +1,93 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Post-release content assertions (operational rule: the shipped artifact must
4
+ # CONTAIN its expected elements — install the published gem and prove the new
5
+ # engine capabilities serve through the engine tier, not the Ruby tier).
6
+ #
7
+ # Usage: gem install fontisan -v 0.4.51 --no-document (in a scratch dir), then
8
+ # FONTISAN_PROBE_VERSION=0.4.51 ruby scripts/verify_release.rb
9
+ # (with GEM_PATH pointed at the scratch install — the SHIPPED lib must load,
10
+ # never the checkout's lib/)
11
+ require "fontisan"
12
+ require "tmpdir"
13
+ require "fileutils"
14
+
15
+ version = ENV.fetch("FONTISAN_PROBE_VERSION")
16
+ spec = Gem::Specification.find_by_name("fontisan", version)
17
+ puts "installed gem: #{spec.full_gem_path}"
18
+
19
+ failures = []
20
+ fonts = File.expand_path("../../fontisan-rs/.corpus/fontisan/corpus/fonts", __dir__)
21
+
22
+ # 1. Platform gem shape: the native extension + the bundled cdylib ship.
23
+ has_native = spec.files.any? { |f| f.include?("fontisan_native") } ||
24
+ File.exist?(File.join(spec.full_gem_path, "lib/fontisan/native"))
25
+ failures << "no native extension in the gem" unless has_native
26
+ ffi_libs = Dir[File.join(spec.full_gem_path, "lib/fontisan/ffi/**/*.dylib")] +
27
+ Dir[File.join(spec.full_gem_path, "lib/fontisan/ffi/**/*.so")]
28
+ failures << "no bundled cdylib in the gem" if ffi_libs.empty?
29
+
30
+ # 2. The flip: with FONTISAN_ENGINE unset, glyph_ids + outline_hashes serve
31
+ # through native/ffi (NOT ruby).
32
+ %w[glyph_ids outline_hashes].each do |op|
33
+ ENV.delete("FONTISAN_ENGINE")
34
+ Fontisan::Engine.reset!
35
+ if op == "glyph_ids"
36
+ Fontisan::Reference.glyph_ids(File.join(fonts, "NotoSans-Regular.ttf"), text: "AB")
37
+ else
38
+ Fontisan::Reference.outline_hashes(File.join(fonts, "NotoSans-Regular.ttf"), index: 0)
39
+ end
40
+ tier = Fontisan::Engine.served_by(op.to_sym).to_s
41
+ failures << "auto #{op} served by #{tier} (want native or ffi)" unless %w[native ffi].include?(tier)
42
+ end
43
+
44
+ # 3. The new capabilities through the engine tier.
45
+ ENV["FONTISAN_ENGINE"] = "native"
46
+ Fontisan::Engine.reset!
47
+ oh = Fontisan::Reference.outline_hashes(File.join(fonts, "NotoSans-Regular.ttf"))
48
+ failures << "outline_hashes kind #{oh['kind'].inspect}" unless oh["kind"] == "glyf"
49
+ begin
50
+ gid = Fontisan::Reference.glyph_ids(File.join(fonts, "TestTTC.ttc"), text: "AB")
51
+ failures << "collection glyph_ids not an Array: #{gid.inspect[0, 40]}" unless gid.is_a?(Array)
52
+ rescue Fontisan::Error
53
+ # The face-0 cmap lookup ran (TestTTC face 0 has no A/B): the engine
54
+ # served the collection, and its no-match error equals Ruby's.
55
+ end
56
+ d = Fontisan::Reference.read(File.join(fonts, "TestDFONT.dfont"))
57
+ failures << "dfont read format #{d[0]['format'].inspect}" unless d[0]["format"] == "dfont"
58
+
59
+ Dir.mktmpdir do |dir|
60
+ r = Fontisan::Reference.convert(File.join(fonts, "TestTTF.ttf"), to: :svg,
61
+ output: File.join(dir, "o.svg"))
62
+ failures << "convert svg failed" unless r[:success]
63
+ svg = File.binread(File.join(dir, "o.svg"))
64
+ failures << "svg missing glyphs" unless svg.include?("<glyph ") && svg.start_with?("<?xml")
65
+ end
66
+
67
+ # 4. Type 1 surfaces (#192 gap 4): the corpus PFB serves the measured
68
+ # NoMethodError-shaped surface through the engine tier; scan keeps Ruby.
69
+ pfb = File.join(fonts, "fonttools-test-t1-pfb/TestT1-Regular.pfb")
70
+ begin
71
+ Fontisan::Reference.read(pfb)
72
+ failures << "t1 read did not raise"
73
+ rescue Fontisan::InvalidFontError => e
74
+ failures << "t1 read surface: #{e.message[0, 80]}" unless
75
+ e.message.include?("undefined method 'has_table?' for an instance of Fontisan::Type1Font")
76
+ unless e.cause.is_a?(NoMethodError)
77
+ failures << "t1 read cause #{e.cause.class}"
78
+ end
79
+ end
80
+ Fontisan::Reference.scan([pfb])
81
+ failures << "t1 scan served_by #{Fontisan::Engine.served_by(:scan)} (want ruby)" unless
82
+ Fontisan::Engine.served_by(:scan) == :ruby
83
+ Fontisan::Reference.audit(pfb)
84
+ failures << "t1 audit served_by #{Fontisan::Engine.served_by(:audit)} (want native)" unless
85
+ Fontisan::Engine.served_by(:audit) == :native
86
+
87
+ if failures.empty?
88
+ puts "RELEASE CONTENT ASSERTIONS PASS (#{version})"
89
+ else
90
+ puts "FAILURES:"
91
+ failures.each { |f| puts " #{f}" }
92
+ exit 1
93
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fontisan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.51
4
+ version: 0.4.52
5
5
  platform: java
6
6
  authors:
7
7
  - Ribose Inc.
@@ -927,9 +927,12 @@ files:
927
927
  - scripts/dfont_ground_truth.rb
928
928
  - scripts/measure_optimization.rb
929
929
  - scripts/probe_jruby_glyph_ids.rb
930
+ - scripts/t1_surface_probe.rb
930
931
  - scripts/tier_fallback.rb
931
932
  - scripts/tier_smoke.rb
932
933
  - scripts/validate_gap_campaign.rb
934
+ - scripts/validate_t1_surfaces.rb
935
+ - scripts/verify_release.rb
933
936
  homepage: https://github.com/fontist/fontisan
934
937
  licenses:
935
938
  - BSD-2-Clause