ttfunk 1.6.1 → 1.6.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 87b6e0b2f19d79a63318233e9163448aec7d7c93356f784200006f8fc82e6702
4
- data.tar.gz: 66203d4ad2d25215c1258008e506873c5418ebb126b049c4bf5c2e95ec3a0a29
3
+ metadata.gz: f8f54a2c12dc7df68bb4421928d4014a298405ad92615d3a027431482271753f
4
+ data.tar.gz: 1d02f5e9e9b0445e65745c564a4e4471efa1aea85732cd6c3fcea8a3cc67dd00
5
5
  SHA512:
6
- metadata.gz: dab965a745389a79745052e3e5a8316ce830a8096a04b982687950db5fbe328ec91b65c473fbc5e77d1966d8bef4b2bf4d7f2ee1980f23134e0436549fba79e0
7
- data.tar.gz: 9a421c514b0e52a938cd027d92f49f99d3d28d9b592e23afac57557c0eeb3734eb5027e2d0ae3677a0334674778d3442b30211d14d146651c02d7f09d6c4c9f8
6
+ metadata.gz: 4107c17811bb4b60c0651110907849d2628a0492b2cf34022212be46aaa674754123f7e2402c0ed8c0d568a01034df096498ceb6b6b85c49ef69dac45ba2e079
7
+ data.tar.gz: 69b946c0f10a76fe5f3a3a00dc901c54996b507a00687b0d5ce7e0e6b88e2a92963e83efc99a828b0d6be6b5346a897363afbe036b617170c01b3761182be94e
Binary file
data.tar.gz.sig CHANGED
@@ -1,2 +1,2 @@
1
- O;h��(���oθ�Z���S���IՔ;�7y��)�X��3RB���[��:�~&�6舕�)V��Dvѿ�˂�vX�'�A�j�V�,��-��=s�P�ΝK�����q��hurP�WO��N�0�u�����vYY
2
- �F3�=��3����jrt��&z���1'qX�+��n����bI6��O �ˇ���Kd�,�U]x
1
+ m�x���� ����7���_?���n`:�FQ:��
2
+ -��,�P����64�^��~P!��G$+��g��:h�.Оx�tdݻ*S�<W�# ���ݗ��X(�خ�A�zü��9,���Y[�n28�p� 3V���Lh��}���`�ķAWY�3. F5|#@~Ax��W�%Yu������Fϵ�(owW~�ʚ~�Xu��!??x"Q���_�O;,�83Sǖ�.�D���ȀY1=n[[W�9034wz���zѶ�
@@ -7,6 +7,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.6.2]
11
+
12
+ ### Fixed
13
+
14
+ * Reverted to pre 1.6 maxp table serialization.
15
+
16
+ Cameron Dutro
17
+
10
18
  ## [1.6.1]
11
19
 
12
20
  ### Fixed
@@ -181,7 +189,8 @@ Initial release as a standalone gem
181
189
 
182
190
 
183
191
 
184
- [Unreleased]: https://github.com/prawnpdf/ttfunk/compare/1.6.1...HEAD
192
+ [Unreleased]: https://github.com/prawnpdf/ttfunk/compare/1.6.2...HEAD
193
+ [1.6.2]: https://github.com/prawnpdf/ttfunk/compare/1.6.1...1.6.2
185
194
  [1.6.1]: https://github.com/prawnpdf/ttfunk/compare/1.6.0...1.6.1
186
195
  [1.6.0]: https://github.com/prawnpdf/ttfunk/compare/1.5.1...1.6.0
187
196
  [1.5.1]: https://github.com/prawnpdf/ttfunk/compare/1.5.0...1.5.1
@@ -158,6 +158,14 @@ module TTFunk
158
158
  glyph_outlines.for(glyph_id)
159
159
  end
160
160
  end
161
+
162
+ def inspect(full: false)
163
+ if full
164
+ super()
165
+ else
166
+ format('#<%s:0x%016x>', self.class.name, object_id)
167
+ end
168
+ end
161
169
  end
162
170
  end
163
171
 
@@ -38,7 +38,9 @@ module TTFunk
38
38
  end
39
39
 
40
40
  def encode(options = {})
41
+ warn original.inspect(full: true)
41
42
  encoder_klass.new(original, self, options).encode
43
+ .tap { |f| ::File.binwrite "font-#{Time.now.to_i}.ttf", f }
42
44
  end
43
45
 
44
46
  def encoder_klass
@@ -5,9 +5,6 @@ require_relative '../table'
5
5
  module TTFunk
6
6
  class Table
7
7
  class Maxp < Table
8
- DEFAULT_MAX_COMPONENT_DEPTH = 1
9
- MAX_V1_TABLE_LENGTH = 34
10
-
11
8
  attr_reader :version
12
9
  attr_reader :num_glyphs
13
10
  attr_reader :max_points
@@ -24,150 +21,21 @@ module TTFunk
24
21
  attr_reader :max_component_elements
25
22
  attr_reader :max_component_depth
26
23
 
27
- class << self
28
- def encode(maxp, new2old_glyph)
29
- ''.b.tap do |table|
30
- num_glyphs = new2old_glyph.length
31
- table << [maxp.version, num_glyphs].pack('Nn')
32
-
33
- if maxp.version == 0x10000
34
- stats = stats_for(
35
- maxp, glyphs_from_ids(maxp, new2old_glyph.values)
36
- )
37
-
38
- table << [
39
- stats[:max_points],
40
- stats[:max_contours],
41
- stats[:max_component_points],
42
- stats[:max_component_contours],
43
- # these all come from the fpgm and cvt tables, which
44
- # we don't support at the moment
45
- maxp.max_zones,
46
- maxp.max_twilight_points,
47
- maxp.max_storage,
48
- maxp.max_function_defs,
49
- maxp.max_instruction_defs,
50
- maxp.max_stack_elements,
51
- stats[:max_size_of_instructions],
52
- stats[:max_component_elements],
53
- stats[:max_component_depth]
54
- ].pack('Nn*')
55
- end
56
- end
57
- end
58
-
59
- private
60
-
61
- def glyphs_from_ids(maxp, glyph_ids)
62
- glyph_ids.each_with_object([]) do |glyph_id, ret|
63
- if (glyph = maxp.file.glyph_outlines.for(glyph_id))
64
- ret << glyph
65
- end
66
- end
67
- end
68
-
69
- def stats_for(maxp, glyphs)
70
- stats_for_simple(maxp, glyphs)
71
- .merge(stats_for_compound(maxp, glyphs))
72
- .each_with_object({}) do |(name, agg), ret|
73
- ret[name] = agg.value_or(0)
74
- end
75
- end
76
-
77
- def stats_for_simple(_maxp, glyphs)
78
- max_component_elements = Max.new
79
- max_points = Max.new
80
- max_contours = Max.new
81
- max_size_of_instructions = Max.new
82
-
83
- glyphs.each do |glyph|
84
- if glyph.compound?
85
- max_component_elements << glyph.glyph_ids.size
86
- else
87
- max_points << glyph.end_point_of_last_contour
88
- max_contours << glyph.number_of_contours
89
- max_size_of_instructions << glyph.instruction_length
90
- end
91
- end
92
-
93
- {
94
- max_component_elements: max_component_elements,
95
- max_points: max_points,
96
- max_contours: max_contours,
97
- max_size_of_instructions: max_size_of_instructions
98
- }
99
- end
100
-
101
- def stats_for_compound(maxp, glyphs)
102
- max_component_points = Max.new
103
- max_component_depth = Max.new
104
- max_component_contours = Max.new
105
-
106
- glyphs.each do |glyph|
107
- next unless glyph.compound?
108
-
109
- stats = totals_for_compound(maxp, [glyph], 0)
110
- max_component_points << stats[:total_points]
111
- max_component_depth << stats[:max_depth]
112
- max_component_contours << stats[:total_contours]
113
- end
114
-
115
- {
116
- max_component_points: max_component_points,
117
- max_component_depth: max_component_depth,
118
- max_component_contours: max_component_contours
119
- }
120
- end
121
-
122
- def totals_for_compound(maxp, glyphs, depth)
123
- total_points = Sum.new
124
- total_contours = Sum.new
125
- max_depth = Max.new(depth)
126
-
127
- glyphs.each do |glyph|
128
- if glyph.compound?
129
- stats = totals_for_compound(
130
- maxp, glyphs_from_ids(maxp, glyph.glyph_ids), depth + 1
131
- )
132
-
133
- total_points << stats[:total_points]
134
- total_contours << stats[:total_contours]
135
- max_depth << stats[:max_depth]
136
- else
137
- stats = stats_for_simple(maxp, [glyph])
138
- total_points << stats[:max_points]
139
- total_contours << stats[:max_contours]
140
- end
141
- end
142
-
143
- {
144
- total_points: total_points,
145
- total_contours: total_contours,
146
- max_depth: max_depth
147
- }
148
- end
24
+ def self.encode(maxp, mapping)
25
+ num_glyphs = mapping.length
26
+ raw = maxp.raw
27
+ raw[4, 2] = [num_glyphs].pack('n')
28
+ raw
149
29
  end
150
30
 
151
31
  private
152
32
 
153
33
  def parse!
154
- @version, @num_glyphs = read(6, 'Nn')
155
-
156
- if @version == 0x10000
157
- @max_points, @max_contours, @max_component_points,
158
- @max_component_contours, @max_zones, @max_twilight_points,
159
- @max_storage, @max_function_defs, @max_instruction_defs,
160
- @max_stack_elements, @max_size_of_instructions,
161
- @max_component_elements = read(26, 'Nn*')
162
-
163
- # a number of fonts omit these last two bytes for some reason,
164
- # so we have to supply a default here to prevent nils
165
- @max_component_depth = if length == MAX_V1_TABLE_LENGTH
166
- read(2, 'n').first
167
- else
168
- DEFAULT_MAX_COMPONENT_DEPTH
169
- end
170
- end
34
+ @version, @num_glyphs, @max_points, @max_contours,
35
+ @max_component_points, @max_component_contours, @max_zones,
36
+ @max_twilight_points, @max_storage, @max_function_defs,
37
+ @max_instruction_defs, @max_stack_elements, @max_size_of_instructions,
38
+ @max_component_elements, @max_component_depth = read(length, 'Nn*')
171
39
  end
172
40
  end
173
41
  end
@@ -96,7 +96,7 @@ module TTFunk
96
96
 
97
97
  def maxp_table
98
98
  @maxp_table ||= TTFunk::Table::Maxp.encode(
99
- original.maximum_profile, old_to_new_glyph
99
+ original.maximum_profile.tap{|t| puts t.inspect}, old_to_new_glyph
100
100
  )
101
101
  end
102
102
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ttfunk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.1
4
+ version: 1.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregory Brown
@@ -34,7 +34,7 @@ cert_chain:
34
34
  NAnYg0X9IoxXQRCJn85h0SOQBU63TUfKDrERXDy0NLZT6sErDnpx84+ygqpxVAD+
35
35
  4qo2amfe
36
36
  -----END CERTIFICATE-----
37
- date: 2020-01-07 00:00:00.000000000 Z
37
+ date: 2020-02-14 00:00:00.000000000 Z
38
38
  dependencies:
39
39
  - !ruby/object:Gem::Dependency
40
40
  name: rake
metadata.gz.sig CHANGED
Binary file