class Tipo::Table::Naming

Constants

full template 'n3'

NameRecord

full template 'n6'

Public Class Methods

new(header, font) click to toggle source
Calls superclass method Tipo::Table::Base::new
# File lib/tipo/table/naming.rb, line 11
def initialize header, font
  @name = 'name'
  super
end

Public Instance Methods

family_name() click to toggle source
# File lib/tipo/table/naming.rb, line 36
def family_name
  stringify_record record_at 1
end
header() click to toggle source
# File lib/tipo/table/naming.rb, line 16
def header
  Header.new *(font.unpack seek: offset, bytes: 6, tmpl: 'n3')
end
name() click to toggle source
# File lib/tipo/table/naming.rb, line 40
def name
  stringify_record record_at 4
end
naming_list() click to toggle source
# File lib/tipo/table/naming.rb, line 24
def naming_list 
  header.count.times.map do
    NameRecord.new *(font.unpack bytes: 12, tmpl: 'n6')
  end
end
record_at(id) click to toggle source
# File lib/tipo/table/naming.rb, line 30
def record_at id
  naming_list.select do |n|
    n.name == id && n.platform == 1
  end.first
end
storage_offset() click to toggle source
# File lib/tipo/table/naming.rb, line 20
def storage_offset
  header.storage_offset + offset
end
style() click to toggle source
# File lib/tipo/table/naming.rb, line 44
def style
  stringify_record record_at 2
end

Private Instance Methods

stringify_record(record) click to toggle source
# File lib/tipo/table/naming.rb, line 50
def stringify_record record
  # To handle both 16bit and 8bit strings
  # first convert to a ord array and build the string
  #
  # TODO: Verify platform and encoding ids and provide
  # the proper template for each
  #
  text = font.unpack(
    seek: storage_offset + record.offset,
    bytes: record.length,
    tmpl: 'c*')
  text.pack 'U*'
end