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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1d27d25052549a912eab7392f8f0b34e7917fad9e9344d178b853bfe5a9fb476
4
- data.tar.gz: 7fe03e99020f0a628efa4bac17236c455143345dbe4aef1dd1df5a8890cf00ad
3
+ metadata.gz: b874b7ec1a441c955ee5e1a75d0477ddac875cfbb109cd4111919a94210f5ee3
4
+ data.tar.gz: ef33acdcc6c296877c745852032a315588da42cfa1017e885bcf41e9fd66f474
5
5
  SHA512:
6
- metadata.gz: 5ddb0c714d55d9f0e3b6b2ae02322f210d2392391d604368628cf6a789e2c1633645b08d4ee1edca6e05c0dc87e7c6e6ec550bc412bcc79fe751cc21f1e55f62
7
- data.tar.gz: f8a646128fbadfd95df57bffc933a17095b3fb228603c941471198186df112bc517d836d09c567c1456b5aa8caed3aec4c14f8c561ba4cc19a4561bf75124940
6
+ metadata.gz: c3ce64b5b2cdf9a2c2604a638b8aaf0c1b681f2dab67377acf61f187960c68891920026fe9474ddc334ac8c4fdc491dcbe635f99e5e4f4cc31342def2d55f3b4
7
+ data.tar.gz: fa84952690ed773f7b38a40059bacf1efadc591c5cd2077a56e07854682c03c28228efc5e623b248302237fa2352336834feea77fe817ab655293cd3ebda0242
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Fontisan
4
- VERSION = "0.4.16"
4
+ VERSION = "0.4.17"
5
5
  end
@@ -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
 
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.16
4
+ version: 0.4.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.