Class: Pdfrb::Font::TrueType::Loca
- Inherits:
-
Object
- Object
- Pdfrb::Font::TrueType::Loca
- Defined in:
- lib/pdfrb/font/true_type/loca.rb
Instance Attribute Summary collapse
-
#offsets ⇒ Object
readonly
Returns the value of attribute offsets.
Instance Method Summary collapse
- #glyph_length(index) ⇒ Object
- #glyph_offset(index) ⇒ Object
-
#initialize(data, long_format: false, num_glyphs: 0) ⇒ Loca
constructor
A new instance of Loca.
Constructor Details
#initialize(data, long_format: false, num_glyphs: 0) ⇒ Loca
Returns a new instance of Loca.
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/pdfrb/font/true_type/loca.rb', line 9 def initialize(data, long_format: false, num_glyphs: 0) @offsets = [] return unless data count = num_glyphs + 1 count.times do |i| @offsets << if long_format u32(data, i * 4) else (u16(data, i * 2) * 2) end end end |
Instance Attribute Details
#offsets ⇒ Object (readonly)
Returns the value of attribute offsets.
7 8 9 |
# File 'lib/pdfrb/font/true_type/loca.rb', line 7 def offsets @offsets end |
Instance Method Details
#glyph_length(index) ⇒ Object
29 30 31 32 33 |
# File 'lib/pdfrb/font/true_type/loca.rb', line 29 def glyph_length(index) return 0 if index.nil? || index + 1 >= @offsets.length @offsets[index + 1] - @offsets[index] end |
#glyph_offset(index) ⇒ Object
23 24 25 26 27 |
# File 'lib/pdfrb/font/true_type/loca.rb', line 23 def glyph_offset(index) return nil if index.nil? || index >= @offsets.length @offsets[index] end |