Class: TTFunk::Table::Glyf::Simple
- Inherits:
-
Object
- Object
- TTFunk::Table::Glyf::Simple
- Defined in:
- lib/ttfunk/table/glyf/simple.rb
Overview
Simple TrueType glyph
Instance Attribute Summary collapse
-
#end_points_of_contours ⇒ Array<Integer>
readonly
Point indices for the last point of each contour.
-
#id ⇒ Integer
readonly
Glyph ID.
-
#instruction_length ⇒ Integer
readonly
Total number of bytes for instructions.
-
#instructions ⇒ Array<Integer>
readonly
Instruction byte code.
-
#number_of_contours ⇒ Integer
readonly
Number of contours in this glyph.
-
#raw ⇒ String
readonly
Binary serialization of this glyph.
-
#x_max ⇒ Integer
readonly
Maximum x for coordinate.
-
#x_min ⇒ Integer
readonly
Minimum x for coordinate.
-
#y_max ⇒ Integer
readonly
Maximum y for coordinate.
-
#y_min ⇒ Integer
readonly
Minimum y for coordinate.
Instance Method Summary collapse
-
#compound? ⇒ false
Is this glyph compound?.
-
#end_point_of_last_contour ⇒ Integer
End point index of last contour.
-
#initialize(id, raw) ⇒ Simple
constructor
A new instance of Simple.
-
#recode(_mapping) ⇒ String
Recode glyph.
Constructor Details
#initialize(id, raw) ⇒ Simple
Returns a new instance of Simple.
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_contours ⇒ Array<Integer> (readonly)
Point indices for the last point of each contour.
40 41 42 |
# File 'lib/ttfunk/table/glyf/simple.rb', line 40 def end_points_of_contours @end_points_of_contours end |
#id ⇒ Integer (readonly)
Glyph ID.
12 13 14 |
# File 'lib/ttfunk/table/glyf/simple.rb', line 12 def id @id end |
#instruction_length ⇒ Integer (readonly)
Total number of bytes for instructions.
44 45 46 |
# File 'lib/ttfunk/table/glyf/simple.rb', line 44 def instruction_length @instruction_length end |
#instructions ⇒ Array<Integer> (readonly)
Instruction byte code.
48 49 50 |
# File 'lib/ttfunk/table/glyf/simple.rb', line 48 def instructions @instructions end |
#number_of_contours ⇒ Integer (readonly)
Number of contours in this glyph.
20 21 22 |
# File 'lib/ttfunk/table/glyf/simple.rb', line 20 def number_of_contours @number_of_contours end |
#raw ⇒ String (readonly)
Binary serialization of this glyph.
16 17 18 |
# File 'lib/ttfunk/table/glyf/simple.rb', line 16 def raw @raw end |
#x_max ⇒ Integer (readonly)
Maximum x for coordinate.
32 33 34 |
# File 'lib/ttfunk/table/glyf/simple.rb', line 32 def x_max @x_max end |
#x_min ⇒ Integer (readonly)
Minimum x for coordinate.
24 25 26 |
# File 'lib/ttfunk/table/glyf/simple.rb', line 24 def x_min @x_min end |
#y_max ⇒ Integer (readonly)
Maximum y for coordinate.
36 37 38 |
# File 'lib/ttfunk/table/glyf/simple.rb', line 36 def y_max @y_max end |
#y_min ⇒ Integer (readonly)
Minimum y for coordinate.
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?
69 70 71 |
# File 'lib/ttfunk/table/glyf/simple.rb', line 69 def compound? false end |
#end_point_of_last_contour ⇒ Integer
End point index of last contour.
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.
77 78 79 |
# File 'lib/ttfunk/table/glyf/simple.rb', line 77 def recode(_mapping) raw end |