Class: TTFunk::Table

Inherits:
Object
  • Object
show all
Includes:
Reader
Defined in:
lib/ttfunk/table.rb,
lib/ttfunk/table/os2.rb,
lib/ttfunk/table/maxp.rb,
lib/ttfunk/table/loca.rb,
lib/ttfunk/table/glyf.rb,
lib/ttfunk/table/name.rb,
lib/ttfunk/table/post.rb,
lib/ttfunk/table/hhea.rb,
lib/ttfunk/table/hmtx.rb,
lib/ttfunk/table/cmap.rb,
lib/ttfunk/table/kern.rb,
lib/ttfunk/table/head.rb,
lib/ttfunk/table/simple.rb,
lib/ttfunk/table/glyf/simple.rb,
lib/ttfunk/table/kern/format0.rb,
lib/ttfunk/table/post/format25.rb,
lib/ttfunk/table/post/format40.rb,
lib/ttfunk/table/post/format20.rb,
lib/ttfunk/table/post/format10.rb,
lib/ttfunk/table/post/format30.rb,
lib/ttfunk/table/cmap/subtable.rb,
lib/ttfunk/table/glyf/compound.rb,
lib/ttfunk/table/cmap/format00.rb,
lib/ttfunk/table/cmap/format04.rb

Direct Known Subclasses

Cmap, Glyf, Head, Hhea, Hmtx, Kern, Loca, Maxp, Name, OS2, Post, Simple

Defined Under Namespace

Classes: Cmap, Glyf, Head, Hhea, Hmtx, Kern, Loca, Maxp, Name, OS2, Post, Simple

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Table) initialize(file)



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/ttfunk/table.rb', line 11

def initialize(file)
  @file = file

  info = file.directory_info(tag)

  if info
    @offset = info[:offset]
    @length = info[:length]

    parse_from(@offset) { parse! }
  end
end

Instance Attribute Details

- (Object) file (readonly)

Returns the value of attribute file



7
8
9
# File 'lib/ttfunk/table.rb', line 7

def file
  @file
end

- (Object) length (readonly)

Returns the value of attribute length



9
10
11
# File 'lib/ttfunk/table.rb', line 9

def length
  @length
end

- (Object) offset (readonly)

Returns the value of attribute offset



8
9
10
# File 'lib/ttfunk/table.rb', line 8

def offset
  @offset
end

Instance Method Details

- (Boolean) exists?



24
25
26
# File 'lib/ttfunk/table.rb', line 24

def exists?
  !@offset.nil?
end

- (Object) raw



28
29
30
31
32
33
34
# File 'lib/ttfunk/table.rb', line 28

def raw
  if exists?
    parse_from(offset) { io.read(length) }
  else
    nil
  end
end

- (Object) tag



36
37
38
# File 'lib/ttfunk/table.rb', line 36

def tag
  self.class.name.split(/::/).last.downcase
end