class TTFunk::Table::Glyf::Simple

Simple TrueType glyph

Attributes

end_points_of_contours[R]

Point indices for the last point of each contour. @return [Array<Integer>]

id[R]

Glyph ID. @return [Integer]

instruction_length[R]

Total number of bytes for instructions. @return [Integer]

instructions[R]

Instruction byte code. @return [Array<Integer>]

number_of_contours[R]

Number of contours in this glyph. @return [Integer]

raw[R]

Binary serialization of this glyph. @return [String]

x_max[R]

Maximum x for coordinate. @return [Integer]

x_min[R]

Minimum x for coordinate. @return [Integer]

y_max[R]

Maximum y for coordinate. @return [Integer]

y_min[R]

Minimum y for coordinate. @return [Integer]

Public Class Methods

new(id, raw) click to toggle source

@param id [Integer] glyph ID. @param raw [String]

# File lib/ttfunk/table/glyf/simple.rb, line 52
def initialize(id, raw)
  @id = id
  @raw = raw
  io = StringIO.new(raw)

  @number_of_contours, @x_min, @y_min, @x_max, @y_max =
    io.read(10).unpack('n*').map { |i|
      BinUtils.twos_comp_to_int(i, bit_width: 16)
    }

  @end_points_of_contours = io.read(number_of_contours * 2).unpack('n*')
  @instruction_length = io.read(2).unpack1('n')
  @instructions = io.read(instruction_length).unpack('C*')
end

Public Instance Methods

compound?() click to toggle source

Is this glyph compound? @return [false]

# File lib/ttfunk/table/glyf/simple.rb, line 69
def compound?
  false
end
end_point_of_last_contour() click to toggle source

End point index of last contour. @return [Integer]

# File lib/ttfunk/table/glyf/simple.rb, line 83
def end_point_of_last_contour
  end_points_of_contours.last + 1
end
recode(_mapping) click to toggle source

Recode glyph.

@param _mapping Unused, here for API compatibility. @return [String]

# File lib/ttfunk/table/glyf/simple.rb, line 77
def recode(_mapping)
  raw
end