Class: TTFunk::Table

Inherits:
Object
  • Object
show all
Includes:
Reader
Defined in:
lib/ttfunk/table.rb,
lib/ttfunk/table/cff.rb,
lib/ttfunk/table/os2.rb,
lib/ttfunk/table/cmap.rb,
lib/ttfunk/table/dsig.rb,
lib/ttfunk/table/glyf.rb,
lib/ttfunk/table/head.rb,
lib/ttfunk/table/hhea.rb,
lib/ttfunk/table/hmtx.rb,
lib/ttfunk/table/kern.rb,
lib/ttfunk/table/loca.rb,
lib/ttfunk/table/maxp.rb,
lib/ttfunk/table/name.rb,
lib/ttfunk/table/post.rb,
lib/ttfunk/table/sbix.rb,
lib/ttfunk/table/vorg.rb,
lib/ttfunk/table/simple.rb,
lib/ttfunk/table/cff/dict.rb,
lib/ttfunk/table/cff/path.rb,
lib/ttfunk/table/cff/index.rb,
lib/ttfunk/table/cff/header.rb,
lib/ttfunk/table/cff/charset.rb,
lib/ttfunk/table/glyf/simple.rb,
lib/ttfunk/table/cff/charsets.rb,
lib/ttfunk/table/cff/encoding.rb,
lib/ttfunk/table/cff/top_dict.rb,
lib/ttfunk/table/kern/format0.rb,
lib/ttfunk/table/cff/encodings.rb,
lib/ttfunk/table/cff/font_dict.rb,
lib/ttfunk/table/cff/top_index.rb,
lib/ttfunk/table/cmap/format00.rb,
lib/ttfunk/table/cmap/format04.rb,
lib/ttfunk/table/cmap/format06.rb,
lib/ttfunk/table/cmap/format10.rb,
lib/ttfunk/table/cmap/format12.rb,
lib/ttfunk/table/cmap/subtable.rb,
lib/ttfunk/table/glyf/compound.rb,
lib/ttfunk/table/post/format10.rb,
lib/ttfunk/table/post/format20.rb,
lib/ttfunk/table/post/format30.rb,
lib/ttfunk/table/post/format40.rb,
lib/ttfunk/table/cff/charstring.rb,
lib/ttfunk/table/cff/font_index.rb,
lib/ttfunk/table/cff/subr_index.rb,
lib/ttfunk/table/cff/fd_selector.rb,
lib/ttfunk/table/glyf/path_based.rb,
lib/ttfunk/table/cff/private_dict.rb,
lib/ttfunk/table/cff/charsets/expert.rb,
lib/ttfunk/table/cff/one_based_index.rb,
lib/ttfunk/table/cff/encodings/expert.rb,
lib/ttfunk/table/cff/charstrings_index.rb,
lib/ttfunk/table/cff/charsets/iso_adobe.rb,
lib/ttfunk/table/cff/encodings/standard.rb,
lib/ttfunk/table/cff/charsets/expert_subset.rb,
lib/ttfunk/table/cff/charsets/standard_strings.rb

Overview

SFNT table

Direct Known Subclasses

Cff, Cmap, Dsig, Glyf, Head, Hhea, Hmtx, Kern, Loca, Maxp, Name, OS2, Post, Sbix, Simple, Vorg

Defined Under Namespace

Classes: Cff, Cmap, Dsig, Glyf, Head, Hhea, Hmtx, Kern, Loca, Maxp, Name, OS2, Post, Sbix, Simple, Vorg

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ Table

Returns a new instance of Table.

Parameters:

Source Code
lib/ttfunk/table.rb, line 23
23
def initialize(file)
24
  @file = file
25
  @offset = nil
26
  @length = nil
27
28
  info = file.directory_info(tag)
29
30
  if info
31
    @offset = info[:offset]
32
    @length = info[:length]
33
34
    parse_from(@offset) { parse! }
35
  end
36
end

Instance Attribute Details

#fileTTFunk::File (readonly)

File this table is in.

Returns:

Source Code
lib/ttfunk/table.rb, line 12
12
def file
13
  @file
14
end

#lengthInteger? (readonly)

This table’s length in byes.

Returns:

  • (Integer, nil)
Source Code
lib/ttfunk/table.rb, line 20
20
def length
21
  @length
22
end

#offsetInteger (readonly)

This table’s offset from the file beginning.

Returns:

  • (Integer)
Source Code
lib/ttfunk/table.rb, line 16
16
def offset
17
  @offset
18
end

Instance Method Details

#exists?Boolean

Does this table exist in the file?

Returns:

  • (Boolean)
Source Code
lib/ttfunk/table.rb, line 41
41
def exists?
42
  !@offset.nil?
43
end

#rawString?

Raw bytes of this table in the file.

Returns:

  • (String, nil)
Source Code
lib/ttfunk/table.rb, line 48
48
def raw
49
  if exists?
50
    parse_from(offset) { io.read(length) }
51
  end
52
end

#tagString

Table tag.

Returns:

  • (String)
Source Code
lib/ttfunk/table.rb, line 57
57
def tag
58
  self.class.name.split('::').last.downcase
59
end