fontisan 0.4.47 → 0.4.49
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/BENCHMARKS.md +56 -0
- data/CHANGELOG.md +12 -0
- data/Cargo.lock +550 -0
- data/Cargo.toml +12 -0
- data/Gemfile +10 -0
- data/README.adoc +69 -0
- data/Rakefile +5 -1
- data/benchmark/baseline.json +5 -0
- data/benchmark/ci_gate.rb +217 -0
- data/benchmark/corpus/harness.rb +175 -0
- data/benchmark/corpus/ops.rb +150 -0
- data/benchmark/corpus/run.rb +182 -0
- data/benchmark/corpus/scan_child.rb +8 -0
- data/benchmark/corpus/tiers.rb +176 -0
- data/benchmark/tier_baseline.json +12 -0
- data/build_mingw32_stub.rb +15 -0
- data/docs/.vitepress/config.ts +2 -1
- data/docs/guide/engines.md +117 -0
- data/docs/reference-facade.md +130 -0
- data/ext/fontisan_cdylib/Cargo.lock +313 -0
- data/ext/fontisan_cdylib/Cargo.toml +18 -0
- data/ext/fontisan_cdylib/build.rs +22 -0
- data/ext/fontisan_cdylib/extconf.rb +36 -0
- data/ext/fontisan_cdylib/src/lib.rs +13 -0
- data/ext/fontisan_native/Cargo.toml +21 -0
- data/ext/fontisan_native/build.rs +22 -0
- data/ext/fontisan_native/clippy.toml +10 -0
- data/ext/fontisan_native/extconf.rb +59 -0
- data/ext/fontisan_native/src/lib.rs +478 -0
- data/lib/fontisan/audit/checks/cmap_check.rb +7 -0
- data/lib/fontisan/audit/checks/hinting_check.rb +1 -1
- data/lib/fontisan/audit/checks/maxp_check.rb +1 -1
- data/lib/fontisan/audit/checks/opentype_conformance_check.rb +5 -2
- data/lib/fontisan/base_collection.rb +30 -0
- data/lib/fontisan/byte_ops.rb +314 -0
- data/lib/fontisan/cli.rb +11 -5
- data/lib/fontisan/commands/audit_command.rb +38 -43
- data/lib/fontisan/commands/convert_command.rb +55 -1
- data/lib/fontisan/commands/instance_command.rb +75 -0
- data/lib/fontisan/commands/multi_format_output.rb +6 -1
- data/lib/fontisan/commands/subset_command.rb +43 -0
- data/lib/fontisan/commands/unpack_command.rb +56 -0
- data/lib/fontisan/converters/cff_table_builder.rb +1 -1
- data/lib/fontisan/converters/collection_converter.rb +13 -5
- data/lib/fontisan/converters/format_converter.rb +1 -1
- data/lib/fontisan/converters/woff2_encoder.rb +8 -6
- data/lib/fontisan/converters/woff_writer.rb +6 -5
- data/lib/fontisan/engine.rb +393 -0
- data/lib/fontisan/ffi/client.rb +123 -0
- data/lib/fontisan/ffi.rb +387 -0
- data/lib/fontisan/ffi_platform.rb +24 -0
- data/lib/fontisan/font_loader.rb +5 -1
- data/lib/fontisan/font_writer.rb +13 -1
- data/lib/fontisan/native.rb +235 -0
- data/lib/fontisan/output_guard.rb +40 -0
- data/lib/fontisan/reference/table_digests.rb +251 -0
- data/lib/fontisan/reference.rb +663 -0
- data/lib/fontisan/scan.rb +372 -0
- data/lib/fontisan/sfnt_directory.rb +41 -0
- data/lib/fontisan/sfnt_font.rb +16 -6
- data/lib/fontisan/subset/builder.rb +2 -1
- data/lib/fontisan/tables/cff/charstring.rb +16 -0
- data/lib/fontisan/tables/cff.rb +15 -5
- data/lib/fontisan/tables/cmap.rb +11 -1
- data/lib/fontisan/tables/gpos.rb +7 -0
- data/lib/fontisan/tables/gsub.rb +7 -0
- data/lib/fontisan/tables/layout_common.rb +172 -0
- data/lib/fontisan/tables/name.rb +10 -4
- data/lib/fontisan/utilities/brotli_wrapper.rb +39 -4
- data/lib/fontisan/validators/opentype_validator.rb +2 -0
- data/lib/fontisan/variable/instancer.rb +1 -0
- data/lib/fontisan/variable/static_font_builder.rb +4 -1
- data/lib/fontisan/variable/table_updater.rb +4 -2
- data/lib/fontisan/variation/instancing/axis_space.rb +1 -1
- data/lib/fontisan/variation/instancing/true_type_instancer.rb +14 -6
- data/lib/fontisan/version.rb +1 -1
- data/lib/fontisan/woff2/collection_decoder.rb +15 -1
- data/lib/fontisan/woff2/collection_encoder.rb +29 -6
- data/lib/fontisan/woff2/encoder_rules.rb +12 -4
- data/lib/fontisan/woff2/glyf_loca_reconstruct.rb +1 -1
- data/lib/fontisan/woff2_collection.rb +7 -5
- data/lib/fontisan/woff2_font.rb +12 -3
- data/lib/fontisan/woff_container.rb +83 -0
- data/lib/fontisan/woff_font.rb +24 -20
- data/lib/fontisan.rb +25 -1
- data/rakelib/bench.rake +9 -0
- data/rakelib/cdylib.rake +39 -0
- data/rakelib/corpus.rake +272 -0
- data/rakelib/corpus_convert.rake +43 -0
- data/rakelib/corpus_goldens.rake +22 -0
- data/rakelib/corpus_malformed.rake +20 -0
- data/rakelib/corpus_scan.rake +24 -0
- data/rakelib/java.rake +61 -0
- data/rakelib/native.rake +43 -0
- data/scripts/build-woff2.sh +57 -0
- data/scripts/corpus/generate_convert_goldens.rb +478 -0
- data/scripts/corpus/generate_goldens.rb +282 -0
- data/scripts/corpus/generate_malformed_goldens.rb +254 -0
- data/scripts/corpus/generate_scan_goldens.rb +98 -0
- data/scripts/tier_fallback.rb +228 -0
- data/scripts/tier_smoke.rb +72 -0
- metadata +71 -7
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Tier fallback checks with strict mode OFF (fontist/fontisan#156 card 3a).
|
|
4
|
+
#
|
|
5
|
+
# ruby scripts/tier_fallback.rb TIERS [CORPUS_ROOT [SCENARIO]] [--gem GEM_NAME]
|
|
6
|
+
#
|
|
7
|
+
# TIERS is the comma list of non-Ruby tiers this platform is expected to have
|
|
8
|
+
# (native,ffi | ffi | none). Without SCENARIO it runs every scenario below, each
|
|
9
|
+
# in a fresh child process (a tier cannot be un-loaded), against the ci-tier
|
|
10
|
+
# corpus with FONTISAN_ENGINE_STRICT unset:
|
|
11
|
+
#
|
|
12
|
+
# no_native, no_ffi the forced tier removed -> every row served by
|
|
13
|
+
# ruby, rows equal the scan goldens
|
|
14
|
+
# native_missing_symbol, the extension / library lacks a symbol, or speaks
|
|
15
|
+
# native_abi_mismatch, another ABI: the tier probes unavailable, nothing
|
|
16
|
+
# ffi_missing_symbol, raises (no NameError) and ruby serves golden rows
|
|
17
|
+
# ffi_abi_mismatch
|
|
18
|
+
# mixed dfont and Type 1 rows are served by ruby, the
|
|
19
|
+
# rest by the forced tier
|
|
20
|
+
# auto_all, auto_no_native, `auto` resolves to the first Engine::AUTO_ORDER tier
|
|
21
|
+
# auto_none still present (ruby until the #160 gates flip it)
|
|
22
|
+
#
|
|
23
|
+
# A scenario about a tier the platform lacks is skipped. Run it against an
|
|
24
|
+
# INSTALLED gem on the CI matrix (outside the checkout), or locally with
|
|
25
|
+
# `bundle exec ruby scripts/tier_fallback.rb ...` from a checkout.
|
|
26
|
+
# Exit status 0 only when every scenario holds.
|
|
27
|
+
require "json"
|
|
28
|
+
require "rbconfig"
|
|
29
|
+
require "tmpdir"
|
|
30
|
+
require "fileutils"
|
|
31
|
+
|
|
32
|
+
SCENARIOS = %w[no_native no_ffi native_missing_symbol native_abi_mismatch
|
|
33
|
+
ffi_missing_symbol ffi_abi_mismatch mixed
|
|
34
|
+
auto_all auto_no_native auto_none].freeze
|
|
35
|
+
|
|
36
|
+
usage = "usage: tier_fallback.rb native,ffi|ffi|none [corpus root [scenario]] [--gem GEM_NAME]"
|
|
37
|
+
arguments = ARGV.dup
|
|
38
|
+
gem_option = arguments.index("--gem")
|
|
39
|
+
gem_name = "fontisan"
|
|
40
|
+
if gem_option
|
|
41
|
+
gem_name = arguments.fetch(gem_option + 1) { abort usage }
|
|
42
|
+
arguments.slice!(gem_option, 2)
|
|
43
|
+
end
|
|
44
|
+
tiers = arguments.fetch(0) { abort usage }.split(",") - ["none"]
|
|
45
|
+
root = File.expand_path(arguments.fetch(1, File.join(__dir__, "..", "corpus")))
|
|
46
|
+
scenario = arguments[2]
|
|
47
|
+
abort "unknown tiers #{tiers.inspect}" unless (tiers - %w[native ffi]).empty?
|
|
48
|
+
|
|
49
|
+
unless scenario
|
|
50
|
+
results = SCENARIOS.to_h do |name|
|
|
51
|
+
[name, system(RbConfig.ruby, __FILE__, tiers.join(",").then { |t| t.empty? ? "none" : t }, root, name,
|
|
52
|
+
"--gem", gem_name)]
|
|
53
|
+
end
|
|
54
|
+
failed = results.reject { |_, ok| ok }.keys
|
|
55
|
+
puts failed.empty? ? "all #{SCENARIOS.size} fallback scenarios hold" : "FAILED: #{failed.join(', ')}"
|
|
56
|
+
exit(failed.empty? ? 0 : 1)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
abort "unknown scenario #{scenario.inspect}" unless SCENARIOS.include?(scenario)
|
|
60
|
+
|
|
61
|
+
# --- sabotage that must happen before the gem loads -----------------------
|
|
62
|
+
|
|
63
|
+
module Sabotage
|
|
64
|
+
# Takes the native extension away through the probe's own require.
|
|
65
|
+
module BlockNative
|
|
66
|
+
def require(name)
|
|
67
|
+
raise LoadError, "native extension removed for the test" if name.to_s.include?("fontisan_native")
|
|
68
|
+
|
|
69
|
+
super
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# A library lacking the fontisan_call symbol.
|
|
74
|
+
module MissingFfiSymbol
|
|
75
|
+
def attach_function(name, *rest)
|
|
76
|
+
raise FFI::NotFoundError.new(name.to_s, "library") if name == :fontisan_call
|
|
77
|
+
|
|
78
|
+
super
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
ENV["FONTISAN_ENGINE"] = "auto"
|
|
84
|
+
ENV.delete("FONTISAN_ENGINE_STRICT")
|
|
85
|
+
gem gem_name
|
|
86
|
+
case scenario
|
|
87
|
+
when "no_native", "auto_no_native", "auto_none" then Object.prepend(Sabotage::BlockNative)
|
|
88
|
+
end
|
|
89
|
+
case scenario
|
|
90
|
+
when "no_ffi", "auto_none" then ENV["FONTISAN_CDYLIB"] = File.join(Dir.tmpdir, "fontisan-no-such-dir", "libfontisan_cdylib.none")
|
|
91
|
+
end
|
|
92
|
+
require "ffi" if scenario == "ffi_missing_symbol" && tiers.include?("ffi")
|
|
93
|
+
FFI::Library.prepend(Sabotage::MissingFfiSymbol) if defined?(FFI::Library) && scenario == "ffi_missing_symbol"
|
|
94
|
+
require "fontisan"
|
|
95
|
+
Fontisan::Reference # autoloading it installs the engine gates
|
|
96
|
+
|
|
97
|
+
needs = { "no_native" => "native", "native_missing_symbol" => "native", "native_abi_mismatch" => "native",
|
|
98
|
+
"no_ffi" => "ffi", "ffi_missing_symbol" => "ffi", "ffi_abi_mismatch" => "ffi",
|
|
99
|
+
"auto_no_native" => "native" }[scenario]
|
|
100
|
+
if needs && !tiers.include?(needs)
|
|
101
|
+
puts "skip #{scenario}: no #{needs} tier on this platform"
|
|
102
|
+
exit 0
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
case scenario
|
|
106
|
+
when "native_missing_symbol"
|
|
107
|
+
Fontisan::Native.send(:load_extension)
|
|
108
|
+
Fontisan::Native.singleton_class.send(:undef_method, :extension_abi_version)
|
|
109
|
+
when "native_abi_mismatch"
|
|
110
|
+
Fontisan::Native.send(:remove_const, :ABI_VERSION)
|
|
111
|
+
Fontisan::Native.const_set(:ABI_VERSION, 999)
|
|
112
|
+
when "ffi_abi_mismatch"
|
|
113
|
+
require "fontisan/ffi/client"
|
|
114
|
+
Fontisan::Ffi::Client.send(:remove_const, :ABI_VERSION)
|
|
115
|
+
Fontisan::Ffi::Client.const_set(:ABI_VERSION, 999)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# --- checks ---------------------------------------------------------------
|
|
119
|
+
|
|
120
|
+
HANDED_TO_RUBY = %w[.dfont .pfa .pfb].freeze
|
|
121
|
+
manifest = JSON.parse(File.read(File.join(root, "manifest.json"))).fetch("fonts")
|
|
122
|
+
entries = manifest.select { |f| f["tier"] == "ci" }.sort_by { |f| f["id"] }
|
|
123
|
+
problems = []
|
|
124
|
+
|
|
125
|
+
font_path = lambda do |entry|
|
|
126
|
+
File.join(root, entry["type"] == "derived" ? "derived" : File.join("fonts", entry["id"]), entry["file"])
|
|
127
|
+
end
|
|
128
|
+
golden = lambda do |entry|
|
|
129
|
+
JSON.parse(File.read(File.join(root, "goldens", "scan", "#{entry['id']}.json"))).fetch("rows")
|
|
130
|
+
end
|
|
131
|
+
plain = lambda do |rows|
|
|
132
|
+
JSON.parse(JSON.generate(rows.map { |r| r.except("served_by").merge("path" => File.basename(r["path"])) }))
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
# Scan every font; rows equal the goldens, served_by is in allowed.(path).
|
|
136
|
+
scan_corpus = lambda do |allowed|
|
|
137
|
+
served = Hash.new(0)
|
|
138
|
+
entries.each do |entry|
|
|
139
|
+
path = font_path.call(entry)
|
|
140
|
+
# The java gem has no brotli: with the ffi tier sabotaged nothing can read a WOFF2,
|
|
141
|
+
# and the engine says so instead of falling back to a Ruby that cannot serve it.
|
|
142
|
+
if File.extname(path).casecmp?(".woff2") && allowed.call(path) == ["ruby"] && !Fontisan::Utilities::BrotliWrapper.available?
|
|
143
|
+
begin
|
|
144
|
+
Fontisan::Engine.scan([path])
|
|
145
|
+
problems << "#{entry['id']}: WOFF2 scan with no ffi tier and no brotli did not raise Woff2Unavailable"
|
|
146
|
+
rescue Fontisan::Engine::Woff2Unavailable
|
|
147
|
+
served["unavailable"] += 1
|
|
148
|
+
end
|
|
149
|
+
next
|
|
150
|
+
end
|
|
151
|
+
rows = Fontisan::Engine.scan([path])
|
|
152
|
+
problems << "#{entry['id']}: rows differ from the golden" unless plain.call(rows) == golden.call(entry)
|
|
153
|
+
rows.each do |row|
|
|
154
|
+
served[row["served_by"]] += 1
|
|
155
|
+
want = allowed.call(path)
|
|
156
|
+
problems << "#{entry['id']}: served_by #{row['served_by']}, expected #{want.join('|')}" unless want.include?(row["served_by"])
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
served
|
|
160
|
+
end
|
|
161
|
+
resolved = lambda do
|
|
162
|
+
Fontisan::Engine.resolve(:scan, font_path.call(entries.find { |e| e["id"] == "fonttools-test-ttf" })).to_s
|
|
163
|
+
end
|
|
164
|
+
all_ruby = ->(_path) { ["ruby"] }
|
|
165
|
+
|
|
166
|
+
# The scenarios that sabotage nothing first check the platform has the tiers it claims.
|
|
167
|
+
if %w[mixed auto_all].include?(scenario)
|
|
168
|
+
ENV["FONTISAN_ENGINE"] = "auto"
|
|
169
|
+
Fontisan::Engine.reset!
|
|
170
|
+
have = %w[native ffi].select { |t| Fontisan::Engine.send(:available?, t.to_sym) }
|
|
171
|
+
problems << "available tiers are #{have.inspect}, expected #{tiers.inspect}" unless have == tiers
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
begin
|
|
175
|
+
case scenario
|
|
176
|
+
when "no_native", "no_ffi", "native_missing_symbol", "native_abi_mismatch", "ffi_missing_symbol", "ffi_abi_mismatch"
|
|
177
|
+
tier = scenario[/native|ffi/]
|
|
178
|
+
ENV["FONTISAN_ENGINE"] = tier
|
|
179
|
+
Fontisan::Engine.reset!
|
|
180
|
+
problems << "#{tier} probes available" if Fontisan::Engine.send(:available?, tier.to_sym)
|
|
181
|
+
served = scan_corpus.call(all_ruby)
|
|
182
|
+
problems << "no ruby row served" if served["ruby"].zero?
|
|
183
|
+
when "mixed"
|
|
184
|
+
tiers.each do |tier|
|
|
185
|
+
ENV["FONTISAN_ENGINE"] = tier
|
|
186
|
+
Fontisan::Engine.reset!
|
|
187
|
+
# dfont and PFB must be ruby's. Ruby's detect_format does not recognise a
|
|
188
|
+
# PFA (nil), so the tier may take it; its error row equals the golden either way.
|
|
189
|
+
# Anything detect_format cannot name (empty or garbage bytes) is Ruby's too.
|
|
190
|
+
scan_corpus.call(lambda { |path|
|
|
191
|
+
case File.extname(path).downcase
|
|
192
|
+
when ".dfont", ".pfb" then ["ruby"]
|
|
193
|
+
when ".pfa" then ["ruby", tier]
|
|
194
|
+
else Fontisan::FontLoader.detect_format(path).nil? ? ["ruby"] : [tier]
|
|
195
|
+
end
|
|
196
|
+
})
|
|
197
|
+
end
|
|
198
|
+
# dfont and Type 1 in one audit_dir: ruby serves those entries, the tier the rest.
|
|
199
|
+
Dir.mktmpdir("fontisan-mixed") do |dir|
|
|
200
|
+
%w[fonttools-test-ttf fonttools-test-dfont fonttools-test-t1-pfb].each do |id|
|
|
201
|
+
entry = entries.find { |e| e["id"] == id }
|
|
202
|
+
FileUtils.cp(font_path.call(entry), dir)
|
|
203
|
+
end
|
|
204
|
+
tiers.each do |tier|
|
|
205
|
+
ENV["FONTISAN_ENGINE"] = tier
|
|
206
|
+
Fontisan::Engine.reset!
|
|
207
|
+
by_file = Fontisan::Engine.audit_dir(dir).to_h { |e| [e["path"], e["served_by"]] }
|
|
208
|
+
want = { "TestTTF.ttf" => tier, "TestDFONT.dfont" => "ruby", "TestT1-Regular.pfb" => "ruby" }
|
|
209
|
+
problems << "#{tier} audit_dir served #{by_file.inspect}, expected #{want.inspect}" unless by_file == want
|
|
210
|
+
end
|
|
211
|
+
end
|
|
212
|
+
problems << "mixed scenario needs a native or ffi tier" if tiers.empty?
|
|
213
|
+
when "auto_all", "auto_no_native", "auto_none"
|
|
214
|
+
ENV["FONTISAN_ENGINE"] = "auto"
|
|
215
|
+
Fontisan::Engine.reset!
|
|
216
|
+
present = { "auto_all" => tiers, "auto_no_native" => tiers - ["native"], "auto_none" => [] }.fetch(scenario)
|
|
217
|
+
want = Fontisan::Engine::AUTO_ORDER.map(&:to_s).find { |t| t == "ruby" || present.include?(t) }
|
|
218
|
+
problems << "auto resolved #{resolved.call}, expected #{want}" unless resolved.call == want
|
|
219
|
+
served = scan_corpus.call(->(path) { [want, *("ruby" if HANDED_TO_RUBY.include?(File.extname(path).downcase))] })
|
|
220
|
+
problems << "no #{want} row served" if served[want].zero?
|
|
221
|
+
end
|
|
222
|
+
rescue StandardError => e # NameError included: a fallback must never raise it
|
|
223
|
+
problems << "raised #{e.class}: #{e.message[0, 200]}"
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
puts "#{problems.empty? ? 'ok ' : 'FAIL'} #{scenario} (tiers: #{tiers.join(',')})"
|
|
227
|
+
problems.each { |p| puts " #{p}" }
|
|
228
|
+
exit(problems.empty? ? 0 : 1)
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Installed-gem smoke test (fontist/fontisan#156 card 2e).
|
|
4
|
+
#
|
|
5
|
+
# ruby scripts/tier_smoke.rb EXPECTED_TIER [CORPUS_ROOT]
|
|
6
|
+
#
|
|
7
|
+
# Run it against an INSTALLED fontisan gem (never the checkout's lib/). It scans
|
|
8
|
+
# every `ci`-tier corpus font through Fontisan::Engine with FONTISAN_ENGINE=EXPECTED_TIER (strict off),
|
|
9
|
+
# then checks that
|
|
10
|
+
# * auto resolves to the first tier of Engine::AUTO_ORDER this gem has (ruby until the
|
|
11
|
+
# phase-3 gates flip it, fontist/fontisan#160);
|
|
12
|
+
# * every row equals the committed scan golden (minus the served_by key);
|
|
13
|
+
# * served_by is EXPECTED_TIER, except for files the engine hands to Ruby
|
|
14
|
+
# (dfont, Type 1), which may say ruby; with EXPECTED_TIER=ruby nothing else.
|
|
15
|
+
# Exit status 0 only when all hold.
|
|
16
|
+
require "json"
|
|
17
|
+
|
|
18
|
+
expected = ARGV.fetch(0) { abort "usage: tier_smoke.rb native|ffi|ruby [corpus root]" }
|
|
19
|
+
root = File.expand_path(ARGV.fetch(1, File.join(__dir__, "..", "corpus")))
|
|
20
|
+
abort "unknown tier #{expected.inspect}" unless %w[native ffi ruby].include?(expected)
|
|
21
|
+
|
|
22
|
+
ENV["FONTISAN_ENGINE"] = expected # the bundled tier is what is under test
|
|
23
|
+
ENV.delete("FONTISAN_ENGINE_STRICT")
|
|
24
|
+
require "fontisan"
|
|
25
|
+
Fontisan::Reference # autoloading it installs the engine gates
|
|
26
|
+
|
|
27
|
+
lib_dir = Gem.loaded_specs.fetch("fontisan").full_gem_path
|
|
28
|
+
abort "smoke must run an installed gem, loaded #{lib_dir}" unless File.basename(File.dirname(lib_dir)) == "gems"
|
|
29
|
+
|
|
30
|
+
HANDED_TO_RUBY = %w[.dfont .pfa .pfb].freeze
|
|
31
|
+
|
|
32
|
+
manifest = JSON.parse(File.read(File.join(root, "manifest.json"))).fetch("fonts")
|
|
33
|
+
entries = manifest.select { |f| f["tier"] == "ci" }.sort_by { |f| f["id"] }
|
|
34
|
+
problems = []
|
|
35
|
+
served = Hash.new(0)
|
|
36
|
+
|
|
37
|
+
entries.each do |entry|
|
|
38
|
+
dir = entry["type"] == "derived" ? "derived" : File.join("fonts", entry["id"])
|
|
39
|
+
path = File.join(root, dir, entry["file"])
|
|
40
|
+
golden = JSON.parse(File.read(File.join(root, "goldens", "scan", "#{entry['id']}.json"))).fetch("rows")
|
|
41
|
+
rows = Fontisan::Engine.scan([path])
|
|
42
|
+
rows.each { |row| served[row["served_by"]] += 1 }
|
|
43
|
+
|
|
44
|
+
actual = rows.map { |r| r.except("served_by").merge("path" => File.basename(r["path"])) }
|
|
45
|
+
problems << "#{entry['id']}: rows differ from golden" unless JSON.parse(JSON.generate(actual)) == golden
|
|
46
|
+
|
|
47
|
+
allowed = [expected]
|
|
48
|
+
handed = HANDED_TO_RUBY.include?(File.extname(path).downcase) || Fontisan::FontLoader.detect_format(path).nil?
|
|
49
|
+
allowed << "ruby" if expected != "ruby" && handed
|
|
50
|
+
rows.each do |row|
|
|
51
|
+
problems << "#{entry['id']}: served_by #{row['served_by']}, expected #{allowed.join('|')}" unless allowed.include?(row["served_by"])
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
ttf = File.join(root, "fonts", "fonttools-test-ttf", "TestTTF.ttf")
|
|
56
|
+
resolved = Fontisan::Engine.resolve(:scan, ttf).to_s
|
|
57
|
+
problems << "#{expected} resolves scan to #{resolved}" unless resolved == expected
|
|
58
|
+
ENV["FONTISAN_ENGINE"] = "auto"
|
|
59
|
+
Fontisan::Engine.reset!
|
|
60
|
+
auto_want = Fontisan::Engine::AUTO_ORDER.find { |t| t == :ruby || t.to_s == expected }.to_s
|
|
61
|
+
auto = Fontisan::Engine.resolve(:scan, ttf).to_s
|
|
62
|
+
problems << "auto resolves scan to #{auto}, expected #{auto_want}" unless auto == auto_want
|
|
63
|
+
problems << "no #{expected} row served" if served[expected].zero?
|
|
64
|
+
|
|
65
|
+
puts "fontisan #{Fontisan::VERSION} from #{lib_dir}"
|
|
66
|
+
puts "ruby #{RUBY_VERSION} #{RUBY_PLATFORM}; fonts scanned: #{entries.size}; served_by: #{served.inspect}"
|
|
67
|
+
if problems.empty?
|
|
68
|
+
puts "OK: #{expected} served the corpus, auto resolved to #{auto}; rows equal the goldens"
|
|
69
|
+
else
|
|
70
|
+
warn problems
|
|
71
|
+
exit 1
|
|
72
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fontisan
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.49
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: base64
|
|
@@ -94,6 +93,20 @@ dependencies:
|
|
|
94
93
|
- - "~>"
|
|
95
94
|
- !ruby/object:Gem::Version
|
|
96
95
|
version: '1.16'
|
|
96
|
+
- !ruby/object:Gem::Dependency
|
|
97
|
+
name: rb_sys
|
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
|
99
|
+
requirements:
|
|
100
|
+
- - "~>"
|
|
101
|
+
- !ruby/object:Gem::Version
|
|
102
|
+
version: '0.9'
|
|
103
|
+
type: :runtime
|
|
104
|
+
prerelease: false
|
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
106
|
+
requirements:
|
|
107
|
+
- - "~>"
|
|
108
|
+
- !ruby/object:Gem::Version
|
|
109
|
+
version: '0.9'
|
|
97
110
|
- !ruby/object:Gem::Dependency
|
|
98
111
|
name: thor
|
|
99
112
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -119,16 +132,20 @@ email:
|
|
|
119
132
|
- open.source@ribose.com
|
|
120
133
|
executables:
|
|
121
134
|
- fontisan
|
|
122
|
-
extensions:
|
|
135
|
+
extensions:
|
|
136
|
+
- ext/fontisan_native/extconf.rb
|
|
123
137
|
extra_rdoc_files: []
|
|
124
138
|
files:
|
|
125
139
|
- ".rspec"
|
|
126
140
|
- ".rubocop.yml"
|
|
127
141
|
- ".rubocop_todo.yml"
|
|
142
|
+
- BENCHMARKS.md
|
|
128
143
|
- BUG-stitcher-drops-isolated-cps.md
|
|
129
144
|
- BUG-stitcher-drops-plane1-codepoints.md
|
|
130
145
|
- BUG-stitcher-gid-cap-65535.md
|
|
131
146
|
- CHANGELOG.md
|
|
147
|
+
- Cargo.lock
|
|
148
|
+
- Cargo.toml
|
|
132
149
|
- Gemfile
|
|
133
150
|
- LICENSE
|
|
134
151
|
- README.adoc
|
|
@@ -180,8 +197,17 @@ files:
|
|
|
180
197
|
- TODO.improvements/14-rubocop-baseline-chip.md
|
|
181
198
|
- TODO.improvements/15-cff-cff2-subsetter-strategy.md
|
|
182
199
|
- TODO.improvements/README.md
|
|
200
|
+
- benchmark/baseline.json
|
|
201
|
+
- benchmark/ci_gate.rb
|
|
183
202
|
- benchmark/compile_benchmark.rb
|
|
203
|
+
- benchmark/corpus/harness.rb
|
|
204
|
+
- benchmark/corpus/ops.rb
|
|
205
|
+
- benchmark/corpus/run.rb
|
|
206
|
+
- benchmark/corpus/scan_child.rb
|
|
207
|
+
- benchmark/corpus/tiers.rb
|
|
208
|
+
- benchmark/tier_baseline.json
|
|
184
209
|
- benchmark/variation_quick_bench.rb
|
|
210
|
+
- build_mingw32_stub.rb
|
|
185
211
|
- docs/.gitignore
|
|
186
212
|
- docs/.vitepress/config.ts
|
|
187
213
|
- docs/.vitepress/theme/components/ApiMethod.vue
|
|
@@ -268,6 +294,7 @@ files:
|
|
|
268
294
|
- docs/guide/conversion/ttf-otf.md
|
|
269
295
|
- docs/guide/conversion/type1.md
|
|
270
296
|
- docs/guide/conversion/web.md
|
|
297
|
+
- docs/guide/engines.md
|
|
271
298
|
- docs/guide/formats/collections.md
|
|
272
299
|
- docs/guide/formats/dfont.md
|
|
273
300
|
- docs/guide/formats/index.md
|
|
@@ -320,8 +347,19 @@ files:
|
|
|
320
347
|
- docs/public/site.webmanifest
|
|
321
348
|
- docs/public/web-app-manifest-192x192.png
|
|
322
349
|
- docs/public/web-app-manifest-512x512.png
|
|
350
|
+
- docs/reference-facade.md
|
|
323
351
|
- docs/scripts/post-build.mjs
|
|
324
352
|
- exe/fontisan
|
|
353
|
+
- ext/fontisan_cdylib/Cargo.lock
|
|
354
|
+
- ext/fontisan_cdylib/Cargo.toml
|
|
355
|
+
- ext/fontisan_cdylib/build.rs
|
|
356
|
+
- ext/fontisan_cdylib/extconf.rb
|
|
357
|
+
- ext/fontisan_cdylib/src/lib.rs
|
|
358
|
+
- ext/fontisan_native/Cargo.toml
|
|
359
|
+
- ext/fontisan_native/build.rs
|
|
360
|
+
- ext/fontisan_native/clippy.toml
|
|
361
|
+
- ext/fontisan_native/extconf.rb
|
|
362
|
+
- ext/fontisan_native/src/lib.rs
|
|
325
363
|
- lib/fontisan.rb
|
|
326
364
|
- lib/fontisan/audit.rb
|
|
327
365
|
- lib/fontisan/audit/check.rb
|
|
@@ -352,6 +390,7 @@ files:
|
|
|
352
390
|
- lib/fontisan/binary.rb
|
|
353
391
|
- lib/fontisan/binary/base_record.rb
|
|
354
392
|
- lib/fontisan/binary/structures.rb
|
|
393
|
+
- lib/fontisan/byte_ops.rb
|
|
355
394
|
- lib/fontisan/cli.rb
|
|
356
395
|
- lib/fontisan/collection.rb
|
|
357
396
|
- lib/fontisan/collection/builder.rb
|
|
@@ -411,6 +450,7 @@ files:
|
|
|
411
450
|
- lib/fontisan/converters/woff2_encoder.rb
|
|
412
451
|
- lib/fontisan/converters/woff_writer.rb
|
|
413
452
|
- lib/fontisan/dfont_collection.rb
|
|
453
|
+
- lib/fontisan/engine.rb
|
|
414
454
|
- lib/fontisan/error.rb
|
|
415
455
|
- lib/fontisan/export.rb
|
|
416
456
|
- lib/fontisan/export/exporter.rb
|
|
@@ -425,6 +465,9 @@ files:
|
|
|
425
465
|
- lib/fontisan/export/transformers/post_transformer.rb
|
|
426
466
|
- lib/fontisan/export/ttx_generator.rb
|
|
427
467
|
- lib/fontisan/export/ttx_parser.rb
|
|
468
|
+
- lib/fontisan/ffi.rb
|
|
469
|
+
- lib/fontisan/ffi/client.rb
|
|
470
|
+
- lib/fontisan/ffi_platform.rb
|
|
428
471
|
- lib/fontisan/font_loader.rb
|
|
429
472
|
- lib/fontisan/font_writer.rb
|
|
430
473
|
- lib/fontisan/formatters.rb
|
|
@@ -482,6 +525,7 @@ files:
|
|
|
482
525
|
- lib/fontisan/models/unicode_mappings.rb
|
|
483
526
|
- lib/fontisan/models/validation_report.rb
|
|
484
527
|
- lib/fontisan/models/variable_font_info.rb
|
|
528
|
+
- lib/fontisan/native.rb
|
|
485
529
|
- lib/fontisan/open_type_collection.rb
|
|
486
530
|
- lib/fontisan/open_type_font.rb
|
|
487
531
|
- lib/fontisan/open_type_font_extensions.rb
|
|
@@ -493,6 +537,7 @@ files:
|
|
|
493
537
|
- lib/fontisan/optimizers/subroutine_generator.rb
|
|
494
538
|
- lib/fontisan/optimizers/subroutine_optimizer.rb
|
|
495
539
|
- lib/fontisan/outline_extractor.rb
|
|
540
|
+
- lib/fontisan/output_guard.rb
|
|
496
541
|
- lib/fontisan/parsers.rb
|
|
497
542
|
- lib/fontisan/parsers/dfont_parser.rb
|
|
498
543
|
- lib/fontisan/parsers/tag.rb
|
|
@@ -506,7 +551,11 @@ files:
|
|
|
506
551
|
- lib/fontisan/pipeline/strategies/preserve_strategy.rb
|
|
507
552
|
- lib/fontisan/pipeline/transformation_pipeline.rb
|
|
508
553
|
- lib/fontisan/pipeline/variation_resolver.rb
|
|
554
|
+
- lib/fontisan/reference.rb
|
|
555
|
+
- lib/fontisan/reference/table_digests.rb
|
|
556
|
+
- lib/fontisan/scan.rb
|
|
509
557
|
- lib/fontisan/sfnt_builder.rb
|
|
558
|
+
- lib/fontisan/sfnt_directory.rb
|
|
510
559
|
- lib/fontisan/sfnt_font.rb
|
|
511
560
|
- lib/fontisan/sfnt_source.rb
|
|
512
561
|
- lib/fontisan/sfnt_table.rb
|
|
@@ -864,9 +913,26 @@ files:
|
|
|
864
913
|
- lib/fontisan/woff2/uint255.rb
|
|
865
914
|
- lib/fontisan/woff2_collection.rb
|
|
866
915
|
- lib/fontisan/woff2_font.rb
|
|
916
|
+
- lib/fontisan/woff_container.rb
|
|
867
917
|
- lib/fontisan/woff_font.rb
|
|
918
|
+
- rakelib/bench.rake
|
|
919
|
+
- rakelib/cdylib.rake
|
|
920
|
+
- rakelib/corpus.rake
|
|
921
|
+
- rakelib/corpus_convert.rake
|
|
922
|
+
- rakelib/corpus_goldens.rake
|
|
923
|
+
- rakelib/corpus_malformed.rake
|
|
924
|
+
- rakelib/corpus_scan.rake
|
|
925
|
+
- rakelib/java.rake
|
|
926
|
+
- rakelib/native.rake
|
|
927
|
+
- scripts/build-woff2.sh
|
|
868
928
|
- scripts/compare_stack_aware.rb
|
|
929
|
+
- scripts/corpus/generate_convert_goldens.rb
|
|
930
|
+
- scripts/corpus/generate_goldens.rb
|
|
931
|
+
- scripts/corpus/generate_malformed_goldens.rb
|
|
932
|
+
- scripts/corpus/generate_scan_goldens.rb
|
|
869
933
|
- scripts/measure_optimization.rb
|
|
934
|
+
- scripts/tier_fallback.rb
|
|
935
|
+
- scripts/tier_smoke.rb
|
|
870
936
|
homepage: https://github.com/fontist/fontisan
|
|
871
937
|
licenses:
|
|
872
938
|
- BSD-2-Clause
|
|
@@ -875,7 +941,6 @@ metadata:
|
|
|
875
941
|
source_code_uri: https://github.com/fontist/fontisan
|
|
876
942
|
changelog_uri: https://github.com/fontist/fontisan/blob/main/CHANGELOG.md
|
|
877
943
|
rubygems_mfa_required: 'true'
|
|
878
|
-
post_install_message:
|
|
879
944
|
rdoc_options: []
|
|
880
945
|
require_paths:
|
|
881
946
|
- lib
|
|
@@ -890,8 +955,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
890
955
|
- !ruby/object:Gem::Version
|
|
891
956
|
version: '0'
|
|
892
957
|
requirements: []
|
|
893
|
-
rubygems_version: 3.
|
|
894
|
-
signing_key:
|
|
958
|
+
rubygems_version: 3.6.9
|
|
895
959
|
specification_version: 4
|
|
896
960
|
summary: Font analysis tools and utilities for OpenType fonts
|
|
897
961
|
test_files: []
|