Class: Pdfrb::Font::TrueType::Name
- Inherits:
-
Object
- Object
- Pdfrb::Font::TrueType::Name
- Defined in:
- lib/pdfrb/font/true_type/name.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#records ⇒ Object
readonly
Returns the value of attribute records.
Instance Method Summary collapse
- #family ⇒ Object
- #full_name ⇒ Object
-
#initialize(data) ⇒ Name
constructor
A new instance of Name.
- #ps_name ⇒ Object
- #subfamily ⇒ Object
Constructor Details
#initialize(data) ⇒ Name
Returns a new instance of Name.
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 |
# File 'lib/pdfrb/font/true_type/name.rb', line 9 def initialize(data) @records = {} return unless data && data.bytesize >= 6 @format = u16(data, 0) @count = u16(data, 2) string_offset = u16(data, 4) @count.times do |i| offset = 6 + (i * 12) break if offset + 12 > data.bytesize platform_id = u16(data, offset) u16(data, offset + 2) _lang_id = u16(data, offset + 4) name_id = u16(data, offset + 6) length = u16(data, offset + 8) str_offset = u16(data, offset + 10) next unless [1, 3].include?(platform_id) raw = data.byteslice(string_offset + str_offset, length) next unless raw str = if platform_id == 3 raw.bytes.each_slice(2).map { |b| (b[0] << 8) | (b[1] || 0) }.pack("U*") else raw.force_encoding("UTF-8") end @records[name_id] = str end end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
7 8 9 |
# File 'lib/pdfrb/font/true_type/name.rb', line 7 def count @count end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
7 8 9 |
# File 'lib/pdfrb/font/true_type/name.rb', line 7 def format @format end |
#records ⇒ Object (readonly)
Returns the value of attribute records.
7 8 9 |
# File 'lib/pdfrb/font/true_type/name.rb', line 7 def records @records end |
Instance Method Details
#family ⇒ Object
42 |
# File 'lib/pdfrb/font/true_type/name.rb', line 42 def family; @records[1] || @records[16]; end |
#full_name ⇒ Object
45 |
# File 'lib/pdfrb/font/true_type/name.rb', line 45 def full_name; @records[4]; end |
#ps_name ⇒ Object
44 |
# File 'lib/pdfrb/font/true_type/name.rb', line 44 def ps_name; @records[6]; end |
#subfamily ⇒ Object
43 |
# File 'lib/pdfrb/font/true_type/name.rb', line 43 def subfamily; @records[2] || @records[17]; end |