lib/ttfunk/table/sbix.rb in ttfunk-1.4.0 vs lib/ttfunk/table/sbix.rb in ttfunk-1.5.0

- old
+ new

@@ -19,13 +19,15 @@ if glyph_offset && next_glyph_offset bytes = next_glyph_offset - glyph_offset if bytes > 0 parse_from(offset + strike[:offset] + glyph_offset) do - x, y, type = read(8, "s2A4") + x, y, type = read(8, 's2A4') data = StringIO.new(io.read(bytes - 8)) - BitmapData.new(x, y, type, data, strike[:ppem], strike[:resolution]) + BitmapData.new( + x, y, type, data, strike[:ppem], strike[:resolution] + ) end end end end @@ -35,20 +37,27 @@ end.compact end private - def parse! - @version, @flags, @num_strikes = read(8, "n2N") - strike_offsets = num_strikes.times.map { read(4, "N").first } + def parse! + @version, @flags, @num_strikes = read(8, 'n2N') + strike_offsets = Array.new(num_strikes) { read(4, 'N').first } - @strikes = strike_offsets.map do |strike_offset| - parse_from(offset + strike_offset) do - ppem, resolution = read(4, "n2") - data_offsets = (file.maximum_profile.num_glyphs + 1).times.map { read(4, "N").first } - { ppem: ppem, resolution: resolution, offset: strike_offset, glyph_data_offset: data_offsets } + @strikes = strike_offsets.map do |strike_offset| + parse_from(offset + strike_offset) do + ppem, resolution = read(4, 'n2') + data_offsets = Array.new(file.maximum_profile.num_glyphs + 1) do + read(4, 'N').first end + { + ppem: ppem, + resolution: resolution, + offset: strike_offset, + glyph_data_offset: data_offsets + } end end + end end end end