Class: TTFunk::Table::Glyf::Simple

Inherits:
Object
  • Object
show all
Defined in:
lib/ttfunk/table/glyf/simple.rb

Overview

Simple TrueType glyph

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, raw) ⇒ Simple

Returns a new instance of Simple.

Parameters:

  • id (Integer)

    glyph ID.

  • raw (String)


52
53
54
55
56
57
58
59
60
61
62
63
64
65
# 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

Instance Attribute Details

#end_points_of_contoursArray<Integer> (readonly)

Point indices for the last point of each contour.

Returns:

  • (Array<Integer>)


40
41
42
# File 'lib/ttfunk/table/glyf/simple.rb', line 40

def end_points_of_contours
  @end_points_of_contours
end

#idInteger (readonly)

Glyph ID.

Returns:

  • (Integer)


12
13
14
# File 'lib/ttfunk/table/glyf/simple.rb', line 12

def id
  @id
end

#instruction_lengthInteger (readonly)

Total number of bytes for instructions.

Returns:

  • (Integer)


44
45
46
# File 'lib/ttfunk/table/glyf/simple.rb', line 44

def instruction_length
  @instruction_length
end

#instructionsArray<Integer> (readonly)

Instruction byte code.

Returns:

  • (Array<Integer>)


48
49
50
# File 'lib/ttfunk/table/glyf/simple.rb', line 48

def instructions
  @instructions
end

#number_of_contoursInteger (readonly)

Number of contours in this glyph.

Returns:

  • (Integer)


20
21
22
# File 'lib/ttfunk/table/glyf/simple.rb', line 20

def number_of_contours
  @number_of_contours
end

#rawString (readonly)

Binary serialization of this glyph.

Returns:

  • (String)


16
17
18
# File 'lib/ttfunk/table/glyf/simple.rb', line 16

def raw
  @raw
end

#x_maxInteger (readonly)

Maximum x for coordinate.

Returns:

  • (Integer)


32
33
34
# File 'lib/ttfunk/table/glyf/simple.rb', line 32

def x_max
  @x_max
end

#x_minInteger (readonly)

Minimum x for coordinate.

Returns:

  • (Integer)


24
25
26
# File 'lib/ttfunk/table/glyf/simple.rb', line 24

def x_min
  @x_min
end

#y_maxInteger (readonly)

Maximum y for coordinate.

Returns:

  • (Integer)


36
37
38
# File 'lib/ttfunk/table/glyf/simple.rb', line 36

def y_max
  @y_max
end

#y_minInteger (readonly)

Minimum y for coordinate.

Returns:

  • (Integer)


28
29
30
# File 'lib/ttfunk/table/glyf/simple.rb', line 28

def y_min
  @y_min
end

Instance Method Details

#compound?false

Is this glyph compound?

Returns:

  • (false)


69
70
71
# File 'lib/ttfunk/table/glyf/simple.rb', line 69

def compound?
  false
end

#end_point_of_last_contourInteger

End point index of last contour.

Returns:

  • (Integer)


83
84
85
# File 'lib/ttfunk/table/glyf/simple.rb', line 83

def end_point_of_last_contour
  end_points_of_contours.last + 1
end

#recode(_mapping) ⇒ String

Recode glyph.

Parameters:

  • _mapping

    Unused, here for API compatibility.

Returns:

  • (String)


77
78
79
# File 'lib/ttfunk/table/glyf/simple.rb', line 77

def recode(_mapping)
  raw
end