fontisan 0.4.16 → 0.4.17
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/lib/fontisan/version.rb +1 -1
- data/lib/fontisan/woff2/glyf_loca_reconstruct.rb +18 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b874b7ec1a441c955ee5e1a75d0477ddac875cfbb109cd4111919a94210f5ee3
|
|
4
|
+
data.tar.gz: ef33acdcc6c296877c745852032a315588da42cfa1017e885bcf41e9fd66f474
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c3ce64b5b2cdf9a2c2604a638b8aaf0c1b681f2dab67377acf61f187960c68891920026fe9474ddc334ac8c4fdc491dcbe635f99e5e4f4cc31342def2d55f3b4
|
|
7
|
+
data.tar.gz: fa84952690ed773f7b38a40059bacf1efadc591c5cd2077a56e07854682c03c28228efc5e623b248302237fa2352336834feea77fe817ab655293cd3ebda0242
|
data/lib/fontisan/version.rb
CHANGED
|
@@ -48,6 +48,14 @@ module Fontisan
|
|
|
48
48
|
|
|
49
49
|
# Reconstruct glyf and loca tables.
|
|
50
50
|
#
|
|
51
|
+
# Per OpenType glyf table spec, loca offsets must be even (short
|
|
52
|
+
# format) or multiples of 4 (long format). Each reconstructed glyph
|
|
53
|
+
# is padded to the loca-format alignment boundary so the next
|
|
54
|
+
# glyph starts at a valid offset. Without this padding, Chrome's
|
|
55
|
+
# OTS rejects the font with "Failed to convert WOFF 2.0 font to
|
|
56
|
+
# SFNT" because glyf.origLength understates the padded size every
|
|
57
|
+
# conformant decoder produces.
|
|
58
|
+
#
|
|
51
59
|
# @return [Hash{Symbol => String}] `{ glyf:, loca: }`
|
|
52
60
|
def reconstruct
|
|
53
61
|
header = parse_header
|
|
@@ -55,10 +63,20 @@ module Fontisan
|
|
|
55
63
|
|
|
56
64
|
glyf = String.new(encoding: Encoding::BINARY)
|
|
57
65
|
offsets = [0]
|
|
66
|
+
# Short loca (indexFormat=0) stores offset/2 as uint16, so glyph
|
|
67
|
+
# offsets must be even — pad to 2-byte boundary. Long loca
|
|
68
|
+
# (indexFormat=1) has no alignment requirement (fontTools does
|
|
69
|
+
# not pad). Matching fontTools exactly is required: Chrome OTS
|
|
70
|
+
# rejects when glyf.origLength doesn't equal the decoder's output.
|
|
71
|
+
align = @index_format.zero? ? 2 : 1
|
|
58
72
|
|
|
59
73
|
num_glyphs.times do |glyph_id|
|
|
60
74
|
glyph = decode_glyph(glyph_id, streams)
|
|
61
75
|
glyf << glyph
|
|
76
|
+
if align > 1
|
|
77
|
+
remainder = glyf.bytesize % align
|
|
78
|
+
glyf << ("\x00" * (align - remainder)) if remainder.positive?
|
|
79
|
+
end
|
|
62
80
|
offsets << glyf.bytesize
|
|
63
81
|
end
|
|
64
82
|
|