Class: TTFunk::Table::Loca

### Home Classes Methods

### In Files

- lib/ttfunk/table/loca.rb

### Parent

TTFunk::Table

### Methods

- ::encode
- #index_of
- #size_of

### Class/Module Index

Quicksearch

- TTFunk
- TTFunk::Directory
- TTFunk::Encoding
- TTFunk::Encoding::MacRoman
- TTFunk::Encoding::Windows1252
- TTFunk::File
- TTFunk::Reader
- TTFunk::ResourceFile
- TTFunk::Subset
- TTFunk::Subset::Base
- TTFunk::Subset::MacRoman
- TTFunk::Subset::Unicode
- TTFunk::Subset::Unicode8Bit
- TTFunk::Subset::Windows1252
- TTFunk::SubsetCollection
- TTFunk::Table
- TTFunk::Table::Cmap
- TTFunk::Table::Cmap::Format00
- TTFunk::Table::Cmap::Format04
- TTFunk::Table::Cmap::Subtable
- TTFunk::Table::Glyf
- TTFunk::Table::Glyf::Compound
- TTFunk::Table::Glyf::Simple
- TTFunk::Table::Head
- TTFunk::Table::Hhea
- TTFunk::Table::Hmtx
- TTFunk::Table::Kern
- TTFunk::Table::Kern::Format0
- TTFunk::Table::Loca
- TTFunk::Table::Maxp
- TTFunk::Table::Name
- TTFunk::Table::Name::String
- TTFunk::Table::OS2
- TTFunk::Table::Post
- TTFunk::Table::Post::Format10
- TTFunk::Table::Post::Format20
- TTFunk::Table::Post::Format25
- TTFunk::Table::Post::Format30
- TTFunk::Table::Post::Format40
- TTFunk::Table::Simple

No matching classes.

# TTFunk::Table::Loca

### Attributes

offsets[R]

### Public Class Methods

encode(offsets) click to toggle source

Accepts an array of offsets, with each index corresponding to the glyph id with that index.

Returns a hash containing:

- :table - the string representing the table's contents

- :type - the type of offset (to be encoded in the 'head' table)

    # File lib/ttfunk/table/loca.rb, line 15
    def self.encode(offsets)
      if offsets.any? { |ofs| ofs > 0xFFFF }
        { :type => 1, :table => offsets.pack("N*") }
      else
        { :type => 0, :table => offsets.map { |o| o/2 }.pack("n*") }
      end
    end

### Public Instance Methods

index_of(glyph_id) click to toggle source

    # File lib/ttfunk/table/loca.rb, line 23
    def index_of(glyph_id)
      @offsets[glyph_id]
    end

size_of(glyph_id) click to toggle source

    # File lib/ttfunk/table/loca.rb, line 27
    def size_of(glyph_id)
      @offsets[glyph_id+1] - @offsets[glyph_id]
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.