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)
Source Code
lib/ttfunk/table/glyf/simple.rb, line 52
52
def initialize(id, raw)
53
  @id = id
54
  @raw = raw
55
  io = StringIO.new(raw)
56
57
  @number_of_contours, @x_min, @y_min, @x_max, @y_max =
58
    io.read(10).unpack('n*').map { |i|
59
      BinUtils.twos_comp_to_int(i, bit_width: 16)
60
    }
61
62
  @end_points_of_contours = io.read(number_of_contours * 2).unpack('n*')
63
  @instruction_length = io.read(2).unpack1('n')
64
  @instructions = io.read(instruction_length).unpack('C*')
65
end

Instance Attribute Details

#end_points_of_contoursArray<Integer> (readonly)

Point indices for the last point of each contour.

Returns:

  • (Array<Integer>)
Source Code
lib/ttfunk/table/glyf/simple.rb, line 40
40
def end_points_of_contours
41
  @end_points_of_contours
42
end

#idInteger (readonly)

Glyph ID.

Returns:

  • (Integer)
Source Code
lib/ttfunk/table/glyf/simple.rb, line 12
12
def id
13
  @id
14
end

#instruction_lengthInteger (readonly)

Total number of bytes for instructions.

Returns:

  • (Integer)
Source Code
lib/ttfunk/table/glyf/simple.rb, line 44
44
def instruction_length
45
  @instruction_length
46
end

#instructionsArray<Integer> (readonly)

Instruction byte code.

Returns:

  • (Array<Integer>)
Source Code
lib/ttfunk/table/glyf/simple.rb, line 48
48
def instructions
49
  @instructions
50
end

#number_of_contoursInteger (readonly)

Number of contours in this glyph.

Returns:

  • (Integer)
Source Code
lib/ttfunk/table/glyf/simple.rb, line 20
20
def number_of_contours
21
  @number_of_contours
22
end

#rawString (readonly)

Binary serialization of this glyph.

Returns:

  • (String)
Source Code
lib/ttfunk/table/glyf/simple.rb, line 16
16
def raw
17
  @raw
18
end

#x_maxInteger (readonly)

Maximum x for coordinate.

Returns:

  • (Integer)
Source Code
lib/ttfunk/table/glyf/simple.rb, line 32
32
def x_max
33
  @x_max
34
end

#x_minInteger (readonly)

Minimum x for coordinate.

Returns:

  • (Integer)
Source Code
lib/ttfunk/table/glyf/simple.rb, line 24
24
def x_min
25
  @x_min
26
end

#y_maxInteger (readonly)

Maximum y for coordinate.

Returns:

  • (Integer)
Source Code
lib/ttfunk/table/glyf/simple.rb, line 36
36
def y_max
37
  @y_max
38
end

#y_minInteger (readonly)

Minimum y for coordinate.

Returns:

  • (Integer)
Source Code
lib/ttfunk/table/glyf/simple.rb, line 28
28
def y_min
29
  @y_min
30
end

Instance Method Details

#compound?false

Is this glyph compound?

Returns:

  • (false)
Source Code
lib/ttfunk/table/glyf/simple.rb, line 69
69
def compound?
70
  false
71
end

#end_point_of_last_contourInteger

End point index of last contour.

Returns:

  • (Integer)
Source Code
lib/ttfunk/table/glyf/simple.rb, line 83
83
def end_point_of_last_contour
84
  end_points_of_contours.last + 1
85
end

#recode(_mapping) ⇒ String

Recode glyph.

Parameters:

  • _mapping

    Unused, here for API compatibility.

Returns:

  • (String)
Source Code
lib/ttfunk/table/glyf/simple.rb, line 77
77
def recode(_mapping)
78
  raw
79
end