fontisan 0.4.52-java → 0.4.53-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 +4 -4
- data/docs/guide/engines.md +1 -1
- data/lib/fontisan/byte_ops.rb +14 -0
- data/lib/fontisan/config/conversion_matrix.yml +14 -12
- data/lib/fontisan/converters/cff_table_builder.rb +26 -46
- data/lib/fontisan/converters/type1_converter.rb +177 -63
- data/lib/fontisan/ffi/windows-x86_64/fontisan_cdylib.dll +0 -0
- data/lib/fontisan/ffi.rb +8 -7
- data/lib/fontisan/native.rb +6 -5
- data/lib/fontisan/pipeline/output_writer.rb +16 -0
- data/lib/fontisan/pipeline/transformation_pipeline.rb +30 -3
- data/lib/fontisan/tables/cff/charstring_parser.rb +8 -0
- data/lib/fontisan/type1/cff_to_type1_converter.rb +33 -15
- data/lib/fontisan/type1/charstrings.rb +2 -1
- data/lib/fontisan/type1/decryptor.rb +6 -6
- data/lib/fontisan/type1/pfb_generator.rb +90 -241
- data/lib/fontisan/type1/pfb_writer.rb +153 -0
- data/lib/fontisan/type1/ttf_to_type1_converter.rb +7 -1
- data/lib/fontisan/type1.rb +1 -0
- data/lib/fontisan/version.rb +1 -1
- data/scripts/corpus/generate_convert_goldens.rb +46 -6
- data/scripts/validate_t1_surfaces.rb +14 -4
- data/scripts/verify_release.rb +10 -2
- metadata +2 -17
- data/TODO.improvements/01-cbdt-cblc-gid-stable-propagation.md +0 -73
- data/TODO.improvements/02-collection-outline-priority.md +0 -48
- data/TODO.improvements/03-fontisan-audit-command.md +0 -219
- data/TODO.improvements/04-ufo-composite-glyph-encoding.md +0 -46
- data/TODO.improvements/05-otf-compiler-real-cff.md +0 -63
- data/TODO.improvements/06-cff2-blend-vsindex-operators.md +0 -51
- data/TODO.improvements/07-cpal-v1-header-fields.md +0 -71
- data/TODO.improvements/08-cff-standard-string-table.md +0 -52
- data/TODO.improvements/09-type1-seac-expansion.md +0 -57
- data/TODO.improvements/10-ufo-image-set-feature-writers.md +0 -71
- data/TODO.improvements/11-kern-groups-plist.md +0 -49
- data/TODO.improvements/12-cbdt-fixture-bindata-conversion.md +0 -68
- data/TODO.improvements/13-split-octokit-fetcher.md +0 -45
- data/TODO.improvements/14-rubocop-baseline-chip.md +0 -62
- data/TODO.improvements/15-cff-cff2-subsetter-strategy.md +0 -78
- data/TODO.improvements/README.md +0 -58
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Fontisan
|
|
4
|
+
module Type1
|
|
5
|
+
# Assembles the canonical Adobe Type 1 PFB from its parts: the clear-text
|
|
6
|
+
# header, the eexec-encrypted private dictionary and CharStrings, and the
|
|
7
|
+
# clear-text trailer. The layout mirrors what fontTools and t1utils emit
|
|
8
|
+
# (the vocabulary our own {PFBParser} and {CharStrings} read), and every
|
|
9
|
+
# encryption step is deterministic, so conversions are reproducible
|
|
10
|
+
# byte for byte.
|
|
11
|
+
#
|
|
12
|
+
# @example Assemble a PFB
|
|
13
|
+
# pfb = Type1::PFBWriter.new(
|
|
14
|
+
# psname: "TestT1-Regular",
|
|
15
|
+
# bbox: [50, 0, 668, 750],
|
|
16
|
+
# fontinfo: { version: "1.0", FullName: "Test T1" },
|
|
17
|
+
# private_entries: { "BlueValues" => [0, 0], "password" => 5839 },
|
|
18
|
+
# charstrings: { ".notdef" => plain_bytes },
|
|
19
|
+
# ).write
|
|
20
|
+
class PFBWriter
|
|
21
|
+
# PFB chunk markers (Constants carries the reader's names).
|
|
22
|
+
ASCII_SEGMENT = 0x01
|
|
23
|
+
BINARY_SEGMENT = 0x02
|
|
24
|
+
END_SEGMENT = 0x03
|
|
25
|
+
PFB_MARKER = 0x80
|
|
26
|
+
|
|
27
|
+
# The number of zero bytes that follow the eexec data.
|
|
28
|
+
TRAILER_ZEROS = 512
|
|
29
|
+
|
|
30
|
+
# @param psname [String] PostScript name
|
|
31
|
+
# @param version [String] Font version string
|
|
32
|
+
# @param fontinfo [Hash<Symbol, Object>] FontInfo entries
|
|
33
|
+
# (:version, :Notice, :Copyright, :FullName, :FamilyName, :Weight,
|
|
34
|
+
# :ItalicAngle, :isFixedPitch)
|
|
35
|
+
# @param bbox [Array<Numeric>] FontBBox (4 numbers)
|
|
36
|
+
# @param charstrings [Hash<String, String>] glyph name => PLAIN
|
|
37
|
+
# (unencrypted) Type 1 CharString bytes
|
|
38
|
+
# @param private_entries [Hash<String, Object>] Private dictionary
|
|
39
|
+
# entries written in order ("/BlueValues" => [...], ...)
|
|
40
|
+
def initialize(psname:, charstrings:, version: "1.0", fontinfo: {},
|
|
41
|
+
bbox: [0, 0, 0, 0], private_entries: {})
|
|
42
|
+
@psname = psname
|
|
43
|
+
@version = version
|
|
44
|
+
@fontinfo = fontinfo
|
|
45
|
+
@bbox = bbox
|
|
46
|
+
@charstrings = charstrings
|
|
47
|
+
@private_entries = private_entries
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# @return [String] the PFB bytes
|
|
51
|
+
def write
|
|
52
|
+
[
|
|
53
|
+
segment(ASCII_SEGMENT, clear_text),
|
|
54
|
+
segment(BINARY_SEGMENT, Decryptor.eexec_encrypt(encrypted_payload)),
|
|
55
|
+
segment(ASCII_SEGMENT, trailer),
|
|
56
|
+
segment(END_SEGMENT, ""),
|
|
57
|
+
].join
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
private
|
|
61
|
+
|
|
62
|
+
def segment(marker, data)
|
|
63
|
+
[PFB_MARKER, marker, data.bytesize].pack("CCV") + data.b
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# The clear-text header, ending at the eexec handoff.
|
|
67
|
+
def clear_text
|
|
68
|
+
<<~CLEAR
|
|
69
|
+
%!PS-AdobeFont-1.0: #{@psname} #{@version}
|
|
70
|
+
%%BeginResource: font #{@psname}
|
|
71
|
+
12 dict dup begin
|
|
72
|
+
/FontType 1 def
|
|
73
|
+
/FontName /#{@psname} def
|
|
74
|
+
/FontInfo #{fontinfo_count} dict dup begin
|
|
75
|
+
#{fontinfo_text}end def
|
|
76
|
+
/PaintType 0 def
|
|
77
|
+
/FontMatrix [0.001 0 0 0.001 0 0] def
|
|
78
|
+
/Encoding 256 array
|
|
79
|
+
0 1 255 {1 index exch /.notdef put} for
|
|
80
|
+
def
|
|
81
|
+
/FontBBox {#{@bbox.join(' ')}} def
|
|
82
|
+
end
|
|
83
|
+
currentfile eexec
|
|
84
|
+
CLEAR
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def fontinfo_count
|
|
88
|
+
keys = %i[version Notice Copyright FullName FamilyName Weight
|
|
89
|
+
ItalicAngle isFixedPitch UnderlinePosition UnderlineThickness
|
|
90
|
+
FSType]
|
|
91
|
+
keys.count { |k| @fontinfo.key?(k) }
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def fontinfo_text
|
|
95
|
+
@fontinfo.filter_map do |key, value|
|
|
96
|
+
next unless key
|
|
97
|
+
|
|
98
|
+
case key
|
|
99
|
+
when :ItalicAngle, :UnderlinePosition, :UnderlineThickness
|
|
100
|
+
"/#{key} #{format('%<v>.6f', v: value)} def\n"
|
|
101
|
+
when :isFixedPitch, :FSType
|
|
102
|
+
"/#{key} #{value} def\n"
|
|
103
|
+
else
|
|
104
|
+
"/#{key} (#{value}) def\n"
|
|
105
|
+
end
|
|
106
|
+
end.join
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# The eexec-encrypted body: private dictionary, then CharStrings.
|
|
110
|
+
def encrypted_payload
|
|
111
|
+
<<~BODY
|
|
112
|
+
dup /Private
|
|
113
|
+
8 dict dup begin
|
|
114
|
+
/-| {string currentfile exch readstring pop} def
|
|
115
|
+
/|- {def} def
|
|
116
|
+
/| {put} def
|
|
117
|
+
#{private_text}end
|
|
118
|
+
/CharStrings
|
|
119
|
+
#{@charstrings.size} dict dup begin
|
|
120
|
+
#{charstrings_text}end put
|
|
121
|
+
end
|
|
122
|
+
dup /FontName get exch definefont pop
|
|
123
|
+
mark
|
|
124
|
+
currentfile closefile
|
|
125
|
+
BODY
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def private_text
|
|
129
|
+
@private_entries.filter_map do |key, value|
|
|
130
|
+
case value
|
|
131
|
+
when Array then "/#{key} [#{value.join(' ')}] def\n"
|
|
132
|
+
when true, false then "/#{key} #{value} def\n"
|
|
133
|
+
else "/#{key} #{value} def\n"
|
|
134
|
+
end
|
|
135
|
+
end.join
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def charstrings_text
|
|
139
|
+
@charstrings.filter_map do |name, plain|
|
|
140
|
+
encrypted = Decryptor.charstring_encrypt(plain)
|
|
141
|
+
next if encrypted.empty?
|
|
142
|
+
|
|
143
|
+
"/#{name} #{encrypted.bytesize} -| #{encrypted} |-\n"
|
|
144
|
+
end.join
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def trailer
|
|
148
|
+
zeros = ("0" * 64) << "\n"
|
|
149
|
+
"#{zeros * (TRAILER_ZEROS / 64)}cleartomark\n%%EndResource\n%%EOF\n"
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
end
|
|
@@ -64,10 +64,16 @@ module Fontisan
|
|
|
64
64
|
|
|
65
65
|
loca_table = @font.table(Constants::LOCA_TAG)
|
|
66
66
|
head_table = @font.table(Constants::HEAD_TAG)
|
|
67
|
-
|
|
68
67
|
maxp = @font.table(Constants::MAXP_TAG)
|
|
69
68
|
num_glyphs = maxp&.num_glyphs || 0
|
|
70
69
|
|
|
70
|
+
# The loca table only parses once it knows its index format and the
|
|
71
|
+
# glyph count; hmtx needs the hhea metric count (see GlyphAccessor).
|
|
72
|
+
loca_table&.parse_with_context(head_table.index_to_loc_format, num_glyphs)
|
|
73
|
+
@font.table(Constants::HMTX_TAG)&.parse_with_context(
|
|
74
|
+
@font.table(Constants::HHEA_TAG)&.number_of_h_metrics || 0, num_glyphs
|
|
75
|
+
)
|
|
76
|
+
|
|
71
77
|
num_glyphs.times do |gid|
|
|
72
78
|
@charstrings[gid] =
|
|
73
79
|
convert_glyph(glyf_table, loca_table, head_table, gid)
|
data/lib/fontisan/type1.rb
CHANGED
|
@@ -38,6 +38,7 @@ module Fontisan
|
|
|
38
38
|
autoload :PFAParser, "fontisan/type1/pfa_parser"
|
|
39
39
|
autoload :PFBGenerator, "fontisan/type1/pfb_generator"
|
|
40
40
|
autoload :PFBParser, "fontisan/type1/pfb_parser"
|
|
41
|
+
autoload :PFBWriter, "fontisan/type1/pfb_writer"
|
|
41
42
|
autoload :PFMGenerator, "fontisan/type1/pfm_generator"
|
|
42
43
|
autoload :PFMParser, "fontisan/type1/pfm_parser"
|
|
43
44
|
autoload :PrivateDict, "fontisan/type1/private_dict"
|
data/lib/fontisan/version.rb
CHANGED
|
@@ -39,11 +39,11 @@ module ConvertGoldens
|
|
|
39
39
|
"\x00\x01\x00\x00".b => "ttf", "true" => "ttf", "OTTO" => "otf",
|
|
40
40
|
"wOFF" => "woff", "wOF2" => "woff2", "ttcf" => "ttc"
|
|
41
41
|
}.freeze
|
|
42
|
-
# Not convert subjects: malformed inputs are card 0e's
|
|
43
|
-
# routing-only rows.
|
|
42
|
+
# Not convert subjects: malformed inputs are card 0e's.
|
|
44
43
|
EXCLUDED_ID = /\Amalformed-/
|
|
45
44
|
OUTPUT_EXT = { "ttf" => "ttf", "otf" => "otf", "woff" => "woff", "woff2" => "woff2",
|
|
46
|
-
"ttc" => "ttc", "otc" => "otc" }.freeze
|
|
45
|
+
"ttc" => "ttc", "otc" => "otc", "type1" => "pfb" }.freeze
|
|
46
|
+
TYPE1_FORMATS = %w[pfb pfa].freeze
|
|
47
47
|
|
|
48
48
|
class ToolMissing < StandardError; end
|
|
49
49
|
|
|
@@ -62,7 +62,11 @@ module ConvertGoldens
|
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
def sniff(path)
|
|
65
|
-
|
|
65
|
+
head = File.binread(path, 4)
|
|
66
|
+
return "pfb" if head.byteslice(0, 2) == "\x80\x01".b || head.byteslice(0, 2) == "\x80\x02".b
|
|
67
|
+
return "pfa" if head.lstrip.start_with?("%!PS-AdobeFont", "%!FontType1")
|
|
68
|
+
|
|
69
|
+
MAGICS[head]
|
|
66
70
|
end
|
|
67
71
|
|
|
68
72
|
# Fonts that are convert subjects, with their detected input format.
|
|
@@ -94,6 +98,13 @@ module ConvertGoldens
|
|
|
94
98
|
|
|
95
99
|
# => { "format:ttf" => {op: :format, to: "ttf"}, ... } in a fixed order
|
|
96
100
|
def cases_for(path, format)
|
|
101
|
+
# A Type 1 source converts to the two sfnt outline formats; it has no
|
|
102
|
+
# faces/cmap to sample and no collection handling.
|
|
103
|
+
if TYPE1_FORMATS.include?(format)
|
|
104
|
+
return { "format:otf" => { op: :format, to: "otf" },
|
|
105
|
+
"format:ttf" => { op: :format, to: "ttf" } }
|
|
106
|
+
end
|
|
107
|
+
|
|
97
108
|
faces = read_faces(path)
|
|
98
109
|
cases = {}
|
|
99
110
|
if format == "ttc" || faces.size > 1 || collection?(path)
|
|
@@ -101,7 +112,22 @@ module ConvertGoldens
|
|
|
101
112
|
faces.each_index { |i| cases["extract:#{i}"] = { op: :extract, index: i } }
|
|
102
113
|
return cases
|
|
103
114
|
end
|
|
104
|
-
|
|
115
|
+
# See the woff2 note below: the encode's bytes are implementation-specific.
|
|
116
|
+
SINGLE_TARGETS.each { |to| cases["format:#{to}"] = { op: :format, to: to } unless to == format || to == "woff2" }
|
|
117
|
+
# No format:woff2 case: the Ruby and engine WOFF2 encoders produce
|
|
118
|
+
# different streams on real fonts (they agree on some, diverge on
|
|
119
|
+
# others), so no single committed byte-set is reproducible across
|
|
120
|
+
# environments - a brotli-less JRuby can only ever produce the engine's
|
|
121
|
+
# bytes, a forced-ruby cell only the gem's. The engine's WOFF2 encode is
|
|
122
|
+
# byte-pinned in fontisan-rs's own test suite.
|
|
123
|
+
# The reverse Type 1 conversion is pinned for sfnt sources of reasonable
|
|
124
|
+
# size: woff/woff2 sources have no type1 matrix pair (and a brotli-less
|
|
125
|
+
# JRuby could not even read the woff2), and CJK-scale fonts (10k+ glyphs)
|
|
126
|
+
# would make every regeneration of the suite disproportionately expensive
|
|
127
|
+
# for the same byte-pinning value.
|
|
128
|
+
if %w[ttf otf].include?(format) && !type1_too_large?(path)
|
|
129
|
+
cases["format:type1"] = { op: :format, to: "type1" }
|
|
130
|
+
end
|
|
105
131
|
instance_coords(faces.first).each_with_index do |coords, i|
|
|
106
132
|
cases["instance:#{i}"] = { op: :instance, coords: coords }
|
|
107
133
|
end
|
|
@@ -114,6 +140,17 @@ module ConvertGoldens
|
|
|
114
140
|
File.binread(path, 4) == "ttcf" || (File.binread(path, 4) == "wOF2" && woff2_flavor(path) == "ttcf")
|
|
115
141
|
end
|
|
116
142
|
|
|
143
|
+
# Fonts above this glyph count skip the format:type1 golden case.
|
|
144
|
+
TYPE1_CASE_MAX_GLYPHS = 2000
|
|
145
|
+
|
|
146
|
+
def type1_too_large?(path)
|
|
147
|
+
font = Fontisan::FontLoader.load(path, mode: :metadata)
|
|
148
|
+
maxp = font.table("maxp")
|
|
149
|
+
maxp&.num_glyphs.to_i > TYPE1_CASE_MAX_GLYPHS
|
|
150
|
+
rescue StandardError, ScriptError
|
|
151
|
+
true
|
|
152
|
+
end
|
|
153
|
+
|
|
117
154
|
def woff2_flavor(path)
|
|
118
155
|
File.binread(path, 8).byteslice(4, 4)
|
|
119
156
|
end
|
|
@@ -221,8 +258,11 @@ module ConvertGoldens
|
|
|
221
258
|
end
|
|
222
259
|
|
|
223
260
|
# Collections are sanitised member by member; WOFF2 collections are first
|
|
224
|
-
# decoded by the pinned woff2_decompress.
|
|
261
|
+
# decoded by the pinned woff2_decompress. Raw Type 1 output is not an OTS
|
|
262
|
+
# input at all — the verdict records the skip.
|
|
225
263
|
def ots_verdict(path, format, tmp)
|
|
264
|
+
return { "verdict" => "skip", "detail" => "OTS does not read raw Type 1" } if TYPE1_FORMATS.include?(format)
|
|
265
|
+
|
|
226
266
|
target = path
|
|
227
267
|
if format == "woff2" && woff2_flavor(path) == "ttcf"
|
|
228
268
|
target = File.join(tmp, "ots-decoded.ttf")
|
|
@@ -87,10 +87,20 @@ end
|
|
|
87
87
|
failures << "#{tier} #{operation} served_by #{served}" unless served == tier
|
|
88
88
|
end
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
90
|
+
# convert keeps Type 1 with Ruby, which now converts it for real: the
|
|
91
|
+
# corpus PFB converts to a loadable TTF (sfnt magic 00 01 00 00).
|
|
92
|
+
require "tmpdir"
|
|
93
|
+
ENV["FONTISAN_ENGINE"] = tier
|
|
94
|
+
Fontisan::Engine.reset!
|
|
95
|
+
converted = Dir.mktmpdir("t1-conv") do |dir|
|
|
96
|
+
out = File.join(dir, "out.ttf")
|
|
97
|
+
Fontisan::Reference.convert(FONT, to: :ttf, output: out)
|
|
98
|
+
File.binread(out)
|
|
99
|
+
end
|
|
100
|
+
served = Fontisan::Engine.served_by(:convert).to_s
|
|
101
|
+
failures << "#{tier} convert served_by #{served}" unless served == "ruby"
|
|
102
|
+
failures << "#{tier} convert produced #{converted.bytesize} bytes, head #{converted[0, 4].inspect}" unless
|
|
103
|
+
converted[0, 4] == "\x00\x01\x00\x00"
|
|
94
104
|
|
|
95
105
|
# scan keeps its Ruby rows (the goldens record Ruby's); audit_dir serves
|
|
96
106
|
# the walk through the tier and hands the Type 1 row back to Ruby.
|
data/scripts/verify_release.rb
CHANGED
|
@@ -66,7 +66,11 @@ end
|
|
|
66
66
|
|
|
67
67
|
# 4. Type 1 surfaces (#192 gap 4): the corpus PFB serves the measured
|
|
68
68
|
# NoMethodError-shaped surface through the engine tier; scan keeps Ruby.
|
|
69
|
-
|
|
69
|
+
# The fontisan corpus keeps it under fonttools-test-t1-pfb/, the
|
|
70
|
+
# engine-side corpus snapshot directly under fonts/.
|
|
71
|
+
pfb = [File.join(fonts, "fonttools-test-t1-pfb/TestT1-Regular.pfb"),
|
|
72
|
+
File.join(fonts, "TestT1-Regular.pfb")].find { |f| File.file?(f) }
|
|
73
|
+
failures << "no corpus PFB under #{fonts}" unless pfb
|
|
70
74
|
begin
|
|
71
75
|
Fontisan::Reference.read(pfb)
|
|
72
76
|
failures << "t1 read did not raise"
|
|
@@ -80,7 +84,11 @@ end
|
|
|
80
84
|
Fontisan::Reference.scan([pfb])
|
|
81
85
|
failures << "t1 scan served_by #{Fontisan::Engine.served_by(:scan)} (want ruby)" unless
|
|
82
86
|
Fontisan::Engine.served_by(:scan) == :ruby
|
|
83
|
-
|
|
87
|
+
begin
|
|
88
|
+
Fontisan::Reference.audit(pfb)
|
|
89
|
+
rescue Fontisan::InvalidFontError
|
|
90
|
+
nil
|
|
91
|
+
end
|
|
84
92
|
failures << "t1 audit served_by #{Fontisan::Engine.served_by(:audit)} (want native)" unless
|
|
85
93
|
Fontisan::Engine.served_by(:audit) == :native
|
|
86
94
|
|
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.
|
|
4
|
+
version: 0.4.53
|
|
5
5
|
platform: java
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
@@ -180,22 +180,6 @@ files:
|
|
|
180
180
|
- TODO.bug-fixes/29-strategy-registries.md
|
|
181
181
|
- TODO.bug-fixes/30-eliminate-send-in-specs.md
|
|
182
182
|
- TODO.bug-fixes/README.md
|
|
183
|
-
- TODO.improvements/01-cbdt-cblc-gid-stable-propagation.md
|
|
184
|
-
- TODO.improvements/02-collection-outline-priority.md
|
|
185
|
-
- TODO.improvements/03-fontisan-audit-command.md
|
|
186
|
-
- TODO.improvements/04-ufo-composite-glyph-encoding.md
|
|
187
|
-
- TODO.improvements/05-otf-compiler-real-cff.md
|
|
188
|
-
- TODO.improvements/06-cff2-blend-vsindex-operators.md
|
|
189
|
-
- TODO.improvements/07-cpal-v1-header-fields.md
|
|
190
|
-
- TODO.improvements/08-cff-standard-string-table.md
|
|
191
|
-
- TODO.improvements/09-type1-seac-expansion.md
|
|
192
|
-
- TODO.improvements/10-ufo-image-set-feature-writers.md
|
|
193
|
-
- TODO.improvements/11-kern-groups-plist.md
|
|
194
|
-
- TODO.improvements/12-cbdt-fixture-bindata-conversion.md
|
|
195
|
-
- TODO.improvements/13-split-octokit-fetcher.md
|
|
196
|
-
- TODO.improvements/14-rubocop-baseline-chip.md
|
|
197
|
-
- TODO.improvements/15-cff-cff2-subsetter-strategy.md
|
|
198
|
-
- TODO.improvements/README.md
|
|
199
183
|
- benchmark/baseline.json
|
|
200
184
|
- benchmark/ci_gate.rb
|
|
201
185
|
- benchmark/collection_benchmark.rb
|
|
@@ -735,6 +719,7 @@ files:
|
|
|
735
719
|
- lib/fontisan/type1/pfa_parser.rb
|
|
736
720
|
- lib/fontisan/type1/pfb_generator.rb
|
|
737
721
|
- lib/fontisan/type1/pfb_parser.rb
|
|
722
|
+
- lib/fontisan/type1/pfb_writer.rb
|
|
738
723
|
- lib/fontisan/type1/pfm_generator.rb
|
|
739
724
|
- lib/fontisan/type1/pfm_parser.rb
|
|
740
725
|
- lib/fontisan/type1/private_dict.rb
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
# 01 — CBDT/CBLC GID-stable propagation
|
|
2
|
-
|
|
3
|
-
## Priority
|
|
4
|
-
P0
|
|
5
|
-
|
|
6
|
-
## Problem
|
|
7
|
-
|
|
8
|
-
`Stitcher::CbdtPropagator#propagate_tables_into` (`lib/fontisan/stitcher/cbdt_propagator.rb:147`) copies CBDT/CBLC bytes raw from the CBDT source into the compiled font. CBLC indexes glyphs by **source GID**. But the Stitcher's compile order is:
|
|
9
|
-
|
|
10
|
-
1. `inject_notdef` → compiled GID 0
|
|
11
|
-
2. `copy_outlines` → compiled GIDs 1..N (outline donor glyphs)
|
|
12
|
-
3. `add_placeholder_glyphs` → compiled GIDs N+1..M (CBDT placeholders, often renamed to `"gid{N}.1"` to avoid name collisions per PR #108)
|
|
13
|
-
|
|
14
|
-
So the CBDT source's GID 110 may end up at compiled GID 4027+ — but the raw-bytes CBLC still says "GID 110 → bitmap for source GID 110". The bitmap data dangles, pointing at whatever outline glyph happens to be at compiled GID 110.
|
|
15
|
-
|
|
16
|
-
This is masked in the cited Essenfont use case because FSung-3 (Ext G outlines) and NotoColorEmoji (emoji bitmaps) cover disjoint codepoint ranges. But for any stitch where CBDT and outline donors cover overlapping codepoint ranges (e.g. assembling a combined Latin+emoji font from a single source that has both glyf and CBDT), the bitmap-to-glyph mapping is wrong.
|
|
17
|
-
|
|
18
|
-
Documented as a known limitation in `docs/STITCHER_GUIDE.adoc` (added in PR #110).
|
|
19
|
-
|
|
20
|
-
## Goal
|
|
21
|
-
|
|
22
|
-
After compile, `propagate_tables_into` rebuilds the CBLC by:
|
|
23
|
-
1. Walking the compiled font's cmap to find each compiled GID for every CBDT-covered codepoint.
|
|
24
|
-
2. Mapping source GID → compiled GID via the Stitcher's `GlyphMapping`.
|
|
25
|
-
3. Building a new CBLC whose `BitmapSize.startGlyphIndex`/`endGlyphIndex` and IndexSubTableArray entries reference compiled GIDs.
|
|
26
|
-
4. Building a new CBDT that lays out bitmap blocks in compiled-GID order so each block matches its CBLC offset.
|
|
27
|
-
|
|
28
|
-
The result: any stitch — overlapping codepoint ranges or not — produces a font where CBLC's GID references line up with the compiled GIDs that actually have the right bitmaps.
|
|
29
|
-
|
|
30
|
-
## Approach
|
|
31
|
-
|
|
32
|
-
Reuse the CBDT/CBLC BinData models from PR #106:
|
|
33
|
-
- `Tables::Cblc`, `Tables::CblcBitmapSize`, `Tables::CblcIndexSubTableArrayEntry`, `Tables::CblcIndexSubTable`
|
|
34
|
-
- `Subset::TableStrategy::ColorBitmapSubsetter` and its plan classes — already do the offset-remap math for the subsetter; same algorithm shape, different mapping source
|
|
35
|
-
|
|
36
|
-
New collaborator: `Stitcher::CbdtReindexer`. Sits between compile and table propagation:
|
|
37
|
-
|
|
38
|
-
```
|
|
39
|
-
compile TTF
|
|
40
|
-
↓
|
|
41
|
-
CbdtReindexer.reindex(source_cblc, source_cbdt, glyph_mapping) → new (CBLC, CBDT) bytes
|
|
42
|
-
↓
|
|
43
|
-
FontWriter.write_to_file(tables.merge("CBLC" => new_cblc, "CBDT" => new_cbdt))
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
The reindexer is stateless given inputs — testable in isolation.
|
|
47
|
-
|
|
48
|
-
Update `propagate_tables_into` to call the reindexer instead of raw-bytes copy.
|
|
49
|
-
|
|
50
|
-
Update `docs/STITCHER_GUIDE.adoc` to remove the "known limitation" note.
|
|
51
|
-
|
|
52
|
-
## Out of scope
|
|
53
|
-
|
|
54
|
-
- Handling IndexSubTable format 4 (bit-packed offsets) — already unsupported in the subsetter; same gap.
|
|
55
|
-
- Multi-strike CBLC where each strike has a different glyph range — covered (reindexer iterates strikes).
|
|
56
|
-
- Subsetting the source CBDT before stitching — separate concern (the subsetter already does this for `Subset::Builder`).
|
|
57
|
-
|
|
58
|
-
## Effort
|
|
59
|
-
|
|
60
|
-
~1 day.
|
|
61
|
-
|
|
62
|
-
## Dependencies
|
|
63
|
-
|
|
64
|
-
None. Unblocks TODO 02.
|
|
65
|
-
|
|
66
|
-
## Acceptance criteria
|
|
67
|
-
|
|
68
|
-
- New spec `spec/fontisan/stitcher/cbdt_reindexer_spec.rb` covers:
|
|
69
|
-
- Disjoint-range stitch: CBLC's compiled GID references line up.
|
|
70
|
-
- Overlapping-range stitch: CBDT placeholder at compiled GID N gets the bitmap originally at source GID M (mapping via GlyphMapping).
|
|
71
|
-
- Multi-strike CBLC: every strike's bitmap data lands at the right compiled GID.
|
|
72
|
-
- Existing `spec/fontisan/stitcher/outline_priority_spec.rb` collection-mode test (currently skipped) is unblocked and passes.
|
|
73
|
-
- The "GID-stability limitation" section in `docs/STITCHER_GUIDE.adoc` is removed.
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
# 02 — Collection-mode outline-priority regression
|
|
2
|
-
|
|
3
|
-
## Priority
|
|
4
|
-
P0
|
|
5
|
-
|
|
6
|
-
## Problem
|
|
7
|
-
|
|
8
|
-
`spec/fontisan/stitcher/outline_priority_spec.rb:160` ("write_collection preserves outline-first cmap priority across faces") was unblocked for single-face mode in PR #108 but the **collection variant** is still skipped:
|
|
9
|
-
|
|
10
|
-
```ruby
|
|
11
|
-
skip "Stitcher currently raises on a CBDT source without at least one outline codepoint in each face — " \
|
|
12
|
-
"collection-mode coverage needs CbdtPropagator hardening tracked separately."
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
When the Stitcher builds a TTC/OTC, each face compiles independently. The CBDT source is global — its placeholders need to land in EVERY face that covers any of its codepoints. The current `CbdtPropagator#add_placeholder_glyphs` raises if a face has no outline glyph from any other donor (the CBDT source alone can't seed a face).
|
|
16
|
-
|
|
17
|
-
## Goal
|
|
18
|
-
|
|
19
|
-
The skipped test passes. A CBDT source can be stitched into a collection where some faces cover only CBDT codepoints (no outline donor coverage). Each face gets the CBDT/CBLC tables propagated.
|
|
20
|
-
|
|
21
|
-
## Approach
|
|
22
|
-
|
|
23
|
-
Two pieces:
|
|
24
|
-
|
|
25
|
-
1. **`CbdtPropagator#add_placeholder_glyphs`** — relax the "must have an outline codepoint" precondition. Allow a face to be seeded with just CBDT placeholders (plus the `.notdef` that's always required).
|
|
26
|
-
|
|
27
|
-
2. **`CbdtPropagator#propagate_tables_into`** — for collections, run per-face rather than once. The collection writer already iterates faces; this is a matter of plumbing.
|
|
28
|
-
|
|
29
|
-
This depends on TODO 01 (GID-stable propagation) because the collection case multiplies the GID-mapping complexity — each face has its own compiled GID space.
|
|
30
|
-
|
|
31
|
-
## Out of scope
|
|
32
|
-
|
|
33
|
-
- Multi-CBDT-source support (the `MultipleCbdtSourcesError` guard remains).
|
|
34
|
-
- Cross-face glyph deduplication (already handled by the existing dedup pass).
|
|
35
|
-
|
|
36
|
-
## Effort
|
|
37
|
-
|
|
38
|
-
~2 hours once TODO 01 lands.
|
|
39
|
-
|
|
40
|
-
## Dependencies
|
|
41
|
-
|
|
42
|
-
- TODO 01 (CBDT/CBLC GID-stable propagation).
|
|
43
|
-
|
|
44
|
-
## Acceptance criteria
|
|
45
|
-
|
|
46
|
-
- The skipped test at `outline_priority_spec.rb:160` is unskipped and passes.
|
|
47
|
-
- A new test covers the "CBDT-only face" case (a face with no outline donor coverage, only CBDT placeholders).
|
|
48
|
-
- `MultipleCbdtSourcesError` is still raised when two CBDT sources are declared.
|