For debugging purposes
# File lib/ttfunk/reader.rb, line 29 def hexdump(string) bytes = string.unpack("C*") bytes.each_with_index do |c, i| print "%02X" % c if (i+1) % 16 == 0 puts elsif (i+1) % 8 == 0 print " " else print " " end end puts unless bytes.length % 16 == 0 end
# File lib/ttfunk/reader.rb, line 5 def io @file.contents end
# File lib/ttfunk/reader.rb, line 21 def parse_from(position) saved, io.pos = io.pos, position result = yield position io.pos = saved return result end
# File lib/ttfunk/reader.rb, line 9 def read(bytes, format) io.read(bytes).unpack(format) end
# File lib/ttfunk/reader.rb, line 13 def read_signed(count) read(count*2, "n*").map { |i| to_signed(i) } end
# File lib/ttfunk/reader.rb, line 17 def to_signed(n) (n>=0x8000) ? -((n ^ 0xFFFF) + 1) : n end