Class: Pdfrb::Font::TrueType::Kern
- Inherits:
-
Object
- Object
- Pdfrb::Font::TrueType::Kern
- Defined in:
- lib/pdfrb/font/true_type/kern.rb
Instance Attribute Summary collapse
-
#pairs ⇒ Object
readonly
Returns the value of attribute pairs.
Instance Method Summary collapse
-
#initialize(data) ⇒ Kern
constructor
A new instance of Kern.
- #kerning(left_glyph, right_glyph) ⇒ Object
Constructor Details
#initialize(data) ⇒ Kern
Returns a new instance of Kern.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/pdfrb/font/true_type/kern.rb', line 9 def initialize(data) @pairs = {} return unless data && data.bytesize >= 4 version = u16(data, 0) n_tables = u16(data, 2) offset = 4 n_tables.times do break if offset + 6 > data.bytesize u16(data, offset) sub_length = u16(data, offset + 2) coverage = u16(data, offset + 4) if version.zero? && coverage & 0x0001 != 0 n_pairs = u16(data, offset + 6) pair_offset = offset + 14 n_pairs.times do |_p| break if pair_offset + 6 > data.bytesize left = u16(data, pair_offset) right = u16(data, pair_offset + 2) value = s16(data, pair_offset + 4) @pairs[[left, right]] = value pair_offset += 6 end end offset += sub_length end end |
Instance Attribute Details
#pairs ⇒ Object (readonly)
Returns the value of attribute pairs.
7 8 9 |
# File 'lib/pdfrb/font/true_type/kern.rb', line 7 def pairs @pairs end |
Instance Method Details
#kerning(left_glyph, right_glyph) ⇒ Object
43 44 45 |
# File 'lib/pdfrb/font/true_type/kern.rb', line 43 def kerning(left_glyph, right_glyph) @pairs[[left_glyph, right_glyph]] || 0 end |