freetype 0.0.5 → 0.0.6

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
  SHA1:
3
- metadata.gz: 95c2f7532d91429764270bdc7316fc3ee03a4a8d
4
- data.tar.gz: cf42c742f3acbcc1f8cda8a7902e105e119c1adc
3
+ metadata.gz: 099515f5fe4f9754fb7aa4417465c70ac6c12a58
4
+ data.tar.gz: 6d877f7464b31d97bf396af910e3a5f2612c41d2
5
5
  SHA512:
6
- metadata.gz: abe501704c8749c4b2c4adb158bc72fdaf753c7fc96060d6abddc13636cb7122f195e64db7b32c0988e0168e00cd565d928536146c5de7b6ccf2caf6bd8c46d7
7
- data.tar.gz: 426bb5fee8d00fa3724f89d4da492f0be9eb80b5106fef7ce58e22c62227d17944f14a7663a4208478a3cc9863c2b9c79226c8faa2d4be3c779e6c54e44e1d39
6
+ metadata.gz: b054d86d64169dfe0861e19b9a04ff33a6ad2e24e8859f472c03cd8947aeb9eb2d28fb37a4c3748c2c77585f78620f120437c848048d2d4d6e572e3832bb4f8f
7
+ data.tar.gz: 774ead96dff55241ecc59273ab2ea215b6c89fbbaaf8640627db664f59dfa3e3d8a3a153691147483952c31ab18152b829d11ab41a54c40796e73273cd012b9e
@@ -1,7 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.0.0
4
- - 2.1.8
4
+ - 2.1.7 # ffi is not support to 2.1.8
5
5
  - 2.2.4
6
6
  - 2.3.0
7
7
  matrix:
@@ -9,4 +9,4 @@ matrix:
9
9
  - rvm: ruby-head
10
10
  notifications:
11
11
  email: false
12
- before_install: gem install bundler -v 1.10.6
12
+ before_install: gem install bundler -v 1.11.2
@@ -204,6 +204,33 @@ module FreeType
204
204
  return [] if @outline[:n_points] == 0
205
205
  @outline[:tags].get_array_of_char(0, @outline[:n_points])
206
206
  end
207
+
208
+ def svg_path_data
209
+ commands = []
210
+ outline_funcs = FreeType::C::FT_Outline_Funcs.new
211
+ outline_funcs[:move_to] = proc do |to|
212
+ commands << [:M, to[:x], -to[:y]]
213
+ 0
214
+ end
215
+ outline_funcs[:line_to] = proc do |to|
216
+ commands << [:L, to[:x], -to[:y]]
217
+ 0
218
+ end
219
+ outline_funcs[:conic_to] = proc do |ctrl, to|
220
+ commands << [:Q, ctrl[:x], -ctrl[:y], to[:x], -to[:y]]
221
+ 0
222
+ end
223
+ outline_funcs[:cubic_to] = proc do |ctrl1, ctrl2, to|
224
+ commands << [:C, ctrl1[:x], -ctrl1[:y], ctrl2[:x], -ctrl2[:y], to[:x], -to[:y]]
225
+ 0
226
+ end
227
+ err = FreeType::C::FT_Outline_Decompose(@outline, outline_funcs, nil)
228
+ if err != 0
229
+ raise FreeType::Error.find(err)
230
+ end
231
+ commands << [:Z] if commands.empty?.!
232
+ commands
233
+ end
207
234
  end
208
235
 
209
236
  Point = Struct.new(:tag, :x, :y) do
@@ -134,6 +134,10 @@ module FreeTypeApiTest
134
134
  t.error('Got values miss assigned from ffi')
135
135
  end
136
136
 
137
+ unless outline.svg_path_data.empty?.!
138
+ t.error('Could not get svg path data form outline')
139
+ end
140
+
137
141
  table[char] = outline.points.map(&:x)
138
142
  end
139
143
  if table.values.uniq.length != table.length
@@ -78,43 +78,43 @@ module FreeType
78
78
 
79
79
  # http://www.freetype.org/freetype2/docs/reference/ft2-basic_types.html#FT_Bitmap
80
80
  class FT_Bitmap < ::FFI::Struct
81
- layout rows: :uint,
82
- width: :uint,
83
- pitch: :int,
84
- buffer: :pointer,
85
- num_grays: :ushort,
86
- pixel_mode: :char,
81
+ layout rows: :uint,
82
+ width: :uint,
83
+ pitch: :int,
84
+ buffer: :pointer,
85
+ num_grays: :ushort,
86
+ pixel_mode: :char,
87
87
  palette_mode: :char,
88
- palette: :pointer
88
+ palette: :pointer
89
89
  end
90
90
 
91
91
  # http://www.freetype.org/freetype2/docs/reference/ft2-basic_types.html#FT_Generic
92
92
  class FT_Generic < ::FFI::Struct
93
- layout data: :pointer,
93
+ layout data: :pointer,
94
94
  finalizer: :pointer
95
95
  end
96
96
 
97
97
  # http://www.freetype.org/freetype2/docs/reference/ft2-base_interface.html#FT_Glyph_Metrics
98
98
  class FT_Glyph_Metrics < ::FFI::Struct
99
- layout width: :FT_Pos,
100
- height: :FT_Pos,
99
+ layout width: :FT_Pos,
100
+ height: :FT_Pos,
101
101
  horiBearingX: :FT_Pos,
102
102
  horiBearingY: :FT_Pos,
103
- horiAdvance: :FT_Pos,
103
+ horiAdvance: :FT_Pos,
104
104
  vertBearingX: :FT_Pos,
105
105
  vertBearingY: :FT_Pos,
106
- vertAdvance: :FT_Pos
106
+ vertAdvance: :FT_Pos
107
107
  end
108
108
 
109
109
  # http://www.freetype.org/freetype2/docs/reference/ft2-outline_processing.html#FT_Outline
110
110
  class FT_Outline < ::FFI::Struct
111
111
  layout n_contours: :short,
112
- n_points: :short,
113
- points: :pointer, # FT_Vector* (n_points)
114
- tags: :pointer, # char * (n_points)
115
- contours: :pointer, # short * (n_contours)
112
+ n_points: :short,
113
+ points: :pointer, # FT_Vector* (n_points)
114
+ tags: :pointer, # char * (n_points)
115
+ contours: :pointer, # short * (n_contours)
116
116
  # http://www.freetype.org/freetype2/docs/reference/ft2-outline_processing.html#FT_OUTLINE_XXX
117
- flags: :int
117
+ flags: :int
118
118
  end
119
119
 
120
120
  # http://www.freetype.org/freetype2/docs/reference/ft2-basic_types.html#FT_Vector
@@ -132,83 +132,92 @@ module FreeType
132
132
 
133
133
  # http://www.freetype.org/freetype2/docs/reference/ft2-base_interface.html#FT_GlyphSlotRec
134
134
  class FT_GlyphSlotRec < ::FFI::Struct
135
- layout library: :pointer,
136
- face: :pointer,
137
- next: :pointer,
138
- reserved: :uint,
139
- generic: FT_Generic,
140
- metrics: FT_Glyph_Metrics,
135
+ layout library: :pointer,
136
+ face: :pointer,
137
+ next: :pointer,
138
+ reserved: :uint,
139
+ generic: FT_Generic,
140
+ metrics: FT_Glyph_Metrics,
141
141
  linearHoriAdvance: :FT_Fixed,
142
142
  linearVertAdvance: :FT_Fixed,
143
- advance: FT_Vector,
144
- format: FT_Glyph_Format,
145
- bitmap: FT_Bitmap,
146
- bitmap_left: :int,
147
- bitmap_top: :int,
148
- outline: FT_Outline,
149
- num_subglyphs: :uint,
150
- subglyphs: :pointer, # FT_SubGlyph
151
- control_data: :pointer, # void *
152
- control_len: :long,
153
- lsb_delta: :FT_Pos,
154
- rsb_delta: :FT_Pos,
155
- other: :pointer, # void *
156
- internal: :pointer # FT_Slot_Internal
143
+ advance: FT_Vector,
144
+ format: FT_Glyph_Format,
145
+ bitmap: FT_Bitmap,
146
+ bitmap_left: :int,
147
+ bitmap_top: :int,
148
+ outline: FT_Outline,
149
+ num_subglyphs: :uint,
150
+ subglyphs: :pointer, # FT_SubGlyph
151
+ control_data: :pointer, # void *
152
+ control_len: :long,
153
+ lsb_delta: :FT_Pos,
154
+ rsb_delta: :FT_Pos,
155
+ other: :pointer, # void *
156
+ internal: :pointer # FT_Slot_Internal
157
157
  end
158
158
 
159
159
  # http://www.freetype.org/freetype2/docs/reference/ft2-base_interface.html#FT_Size_Metrics
160
160
  class FT_Size_Metrics < ::FFI::Struct
161
- layout x_ppem: :ushort,
162
- y_ppem: :ushort,
163
- x_scale: :FT_Fixed,
164
- y_scale: :FT_Fixed,
165
- ascender: :FT_Pos,
166
- descender: :FT_Pos,
167
- height: :FT_Pos,
161
+ layout x_ppem: :ushort,
162
+ y_ppem: :ushort,
163
+ x_scale: :FT_Fixed,
164
+ y_scale: :FT_Fixed,
165
+ ascender: :FT_Pos,
166
+ descender: :FT_Pos,
167
+ height: :FT_Pos,
168
168
  max_advance: :FT_Pos
169
169
  end
170
170
 
171
171
  # http://www.freetype.org/freetype2/docs/reference/ft2-base_interface.html#FT_SizeRec
172
172
  class FT_SizeRec < ::FFI::Struct
173
- layout face: :pointer, # FT_Face
174
- generic: FT_Generic,
175
- metrics: FT_Size_Metrics,
173
+ layout face: :pointer, # FT_Face
174
+ generic: FT_Generic,
175
+ metrics: FT_Size_Metrics,
176
176
  internal: :pointer # FT_Size_Internal
177
177
  end
178
178
 
179
179
  class FT_CharMapRec < ::FFI::Struct
180
- layout face: :pointer,
181
- encoding: FT_Encoding,
180
+ layout face: :pointer,
181
+ encoding: FT_Encoding,
182
182
  platform_id: :ushort,
183
183
  encoding_id: :ushort
184
184
  end
185
185
 
186
186
  # http://www.freetype.org/freetype2/docs/reference/ft2-base_interface.html#FT_FaceRec
187
187
  class FT_FaceRec < ::FFI::Struct
188
- layout num_faces: :long,
189
- face_index: :long,
190
- face_flags: :long,
191
- style_flags: :long,
192
- num_glyphs: :long,
193
- family_name: :string,
194
- style_name: :string,
195
- num_fixed_sizes: :int,
196
- available_sizes: :pointer, # FT_Bitmap_Size*
197
- num_charmaps: :int,
198
- charmaps: FT_CharMapRec.ptr,
199
- generic: FT_Generic,
200
- bbox: FT_BBox,
201
- units_per_EM: :ushort,
202
- ascender: :short,
203
- descender: :short,
204
- height: :short,
205
- max_advance_width: :short,
206
- max_advance_height: :short,
207
- underline_position: :short,
188
+ layout num_faces: :long,
189
+ face_index: :long,
190
+ face_flags: :long,
191
+ style_flags: :long,
192
+ num_glyphs: :long,
193
+ family_name: :string,
194
+ style_name: :string,
195
+ num_fixed_sizes: :int,
196
+ available_sizes: :pointer, # FT_Bitmap_Size*
197
+ num_charmaps: :int,
198
+ charmaps: FT_CharMapRec.ptr,
199
+ generic: FT_Generic,
200
+ bbox: FT_BBox,
201
+ units_per_EM: :ushort,
202
+ ascender: :short,
203
+ descender: :short,
204
+ height: :short,
205
+ max_advance_width: :short,
206
+ max_advance_height: :short,
207
+ underline_position: :short,
208
208
  underline_thickness: :short,
209
- glyph: FT_GlyphSlotRec.ptr,
210
- size: FT_SizeRec.ptr,
211
- charmap: :pointer
209
+ glyph: FT_GlyphSlotRec.ptr,
210
+ size: FT_SizeRec.ptr,
211
+ charmap: :pointer
212
+ end
213
+
214
+ class FT_Outline_Funcs < ::FFI::Struct
215
+ layout move_to: callback([FT_Vector.ptr, :pointer], :FT_Error), # FT_Outline_MoveToFunc
216
+ line_to: callback([FT_Vector.ptr, :pointer], :FT_Error), # FT_Outline_LineToFunc
217
+ conic_to: callback([FT_Vector.ptr, FT_Vector.ptr, :pointer], :FT_Error), # FT_Outline_ConicToFunc
218
+ cubic_to: callback([FT_Vector.ptr, FT_Vector.ptr, FT_Vector.ptr, :pointer], :FT_Error), # FT_Outline_CubicToFunc
219
+ shift: :int,
220
+ delta: :FT_Pos
212
221
  end
213
222
 
214
223
  class << self
@@ -254,6 +263,8 @@ module FreeType
254
263
 
255
264
  attach_function :FT_GlyphSlot_Embolden, [FT_GlyphSlotRec.ptr], :void
256
265
  attach_function :FT_GlyphSlot_Oblique, [FT_GlyphSlotRec.ptr], :void
266
+
267
+ attach_function :FT_Outline_Decompose, [FT_Outline.ptr, FT_Outline_Funcs.ptr, :pointer], :FT_Error
257
268
  attach_function :FT_Outline_Embolden, [:pointer, :FT_Pos], :FT_Error
258
269
  attach_function :FT_Outline_Transform, [:pointer, FT_Matrix.ptr], :void
259
270
  attach_function :FT_Outline_Reverse, [:pointer], :void
@@ -114,6 +114,39 @@ module FFITest
114
114
  end
115
115
  end
116
116
 
117
+ def test_FT_Outline_Decompose(t)
118
+ libopen do |face|
119
+ t.error('err') if FT_Set_Char_Size(face, 0, 32, 300, 300) != 0
120
+ t.error('err') if FT_Load_Char(face, 'a'.ord, FreeType::C::FT_LOAD_DEFAULT) != 0
121
+
122
+ vectors = []
123
+ outline_funcs = FT_Outline_Funcs.new
124
+ outline_funcs[:move_to] = Proc.new { |to|
125
+ vectors << ['M', to[:x], to[:y]]
126
+ 0
127
+ }
128
+ outline_funcs[:line_to] = Proc.new { |to|
129
+ vectors << ['L', to[:x], to[:y]]
130
+ 0
131
+ }
132
+ outline_funcs[:conic_to] = Proc.new { |ctrl, to|
133
+ vectors << ['Q', ctrl[:x], ctrl[:y], to[:x], to[:y]]
134
+ 0
135
+ }
136
+ outline_funcs[:cubic_to] = Proc.new { |ctrl1, ctrl2, to|
137
+ vectors << ['C', ctrl1[:x], ctrl1[:y], ctrl2[:x], ctrl2[:y], to[:x], to[:y]]
138
+ 0
139
+ }
140
+ err = FT_Outline_Decompose(face[:glyph][:outline], outline_funcs, nil)
141
+ if err != 0
142
+ t.error FreeType::Error.find(err).message
143
+ end
144
+ if vectors.empty?
145
+ t.error "callbacks was not called"
146
+ end
147
+ end
148
+ end
149
+
117
150
  def test_FT_Outline_Embolden(t)
118
151
  libopen do |face|
119
152
  t.error('err') if FT_Set_Char_Size(face, 0, 32, 300, 300) != 0
@@ -1,3 +1,3 @@
1
1
  module FreeType
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: freetype
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - ksss
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-02-17 00:00:00.000000000 Z
11
+ date: 2016-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi