Class: TTFunk::File

### Home Classes Methods

### In Files

- lib/ttfunk.rb

### Parent

Object

### Methods

- ::from_dfont
- ::new
- ::open
- ::verify_and_open
- #ascent
- #bbox
- #cmap
- #descent
- #directory_info
- #glyph_locations
- #glyph_outlines
- #header
- #horizontal_header
- #horizontal_metrics
- #kerning
- #line_gap
- #maximum_profile
- #name
- #os2
- #postscript
- #sbix

### 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::Format06
- TTFunk::Table::Cmap::Format10
- TTFunk::Table::Cmap::Format12
- 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::Format30
- TTFunk::Table::Post::Format40
- TTFunk::Table::Sbix
- TTFunk::Table::Simple

No matching classes.

# TTFunk::File

### Attributes

contents[R]
directory[R]

### Public Class Methods

from_dfont(file, which=0) click to toggle source

    # File lib/ttfunk.rb, line 16
    def self.from_dfont(file, which=0)
      new(ResourceFile.open(file) { |dfont| dfont["sfnt", which] })
    end

new(contents) click to toggle source

    # File lib/ttfunk.rb, line 39
    def initialize(contents)
      @contents = StringIO.new(contents)
      @directory = Directory.new(@contents)
    end

open(io_or_path) click to toggle source

    # File lib/ttfunk.rb, line 12
    def self.open(io_or_path)
      new verify_and_open(io_or_path).read
    end

verify_and_open(io_or_path) click to toggle source

    # File lib/ttfunk.rb, line 20
    def self.verify_and_open(io_or_path)
      # File or IO
      if io_or_path.respond_to?(:rewind)
        io = io_or_path
        # Rewind if the object we're passed is an IO, so that multiple embeds of
        # the same IO object will work
        io.rewind
        # read the file as binary so the size is calculated correctly
        # guard binmode because some objects acting io-like don't implement it
        io.binmode if io.respond_to?(:binmode)
        return io
      end
      # String or Pathname
      io_or_path = Pathname.new(io_or_path)
      raise ArgumentError, "#{io_or_path} not found" unless io_or_path.file?
      io = io_or_path.open('rb')
      io
    end

### Public Instance Methods

ascent() click to toggle source

    # File lib/ttfunk.rb, line 45
    def ascent
      @ascent ||= (os2.exists? && os2.ascent && os2.ascent.nonzero?) || horizontal_header.ascent
    end

bbox() click to toggle source

    # File lib/ttfunk.rb, line 57
    def bbox
      [header.x_min, header.y_min, header.x_max, header.y_max]
    end

cmap() click to toggle source

    # File lib/ttfunk.rb, line 70
    def cmap
      @cmap ||= TTFunk::Table::Cmap.new(self)
    end

descent() click to toggle source

    # File lib/ttfunk.rb, line 49
    def descent
      @descent ||= (os2.exists? && os2.descent && os2.descent.nonzero?) || horizontal_header.descent
    end

directory_info(tag) click to toggle source

    # File lib/ttfunk.rb, line 62
    def directory_info(tag)
      directory.tables[tag.to_s]
    end

glyph_locations() click to toggle source

    # File lib/ttfunk.rb, line 102
    def glyph_locations
      @glyph_locations ||= TTFunk::Table::Loca.new(self)
    end

glyph_outlines() click to toggle source

    # File lib/ttfunk.rb, line 106
    def glyph_outlines
      @glyph_outlines ||= TTFunk::Table::Glyf.new(self)
    end

header() click to toggle source

    # File lib/ttfunk.rb, line 66
    def header
      @header ||= TTFunk::Table::Head.new(self)
    end

horizontal_header() click to toggle source

    # File lib/ttfunk.rb, line 74
    def horizontal_header
      @horizontal_header ||= TTFunk::Table::Hhea.new(self)
    end

horizontal_metrics() click to toggle source

    # File lib/ttfunk.rb, line 78
    def horizontal_metrics
      @horizontal_metrics ||= TTFunk::Table::Hmtx.new(self)
    end

kerning() click to toggle source

    # File lib/ttfunk.rb, line 86
    def kerning
      @kerning ||= TTFunk::Table::Kern.new(self)
    end

line_gap() click to toggle source

    # File lib/ttfunk.rb, line 53
    def line_gap
      @line_gap ||= (os2.exists? && os2.line_gap && os2.line_gap.nonzero?) || horizontal_header.line_gap
    end

maximum_profile() click to toggle source

    # File lib/ttfunk.rb, line 82
    def maximum_profile
      @maximum_profile ||= TTFunk::Table::Maxp.new(self)
    end

name() click to toggle source

    # File lib/ttfunk.rb, line 90
    def name
      @name ||= TTFunk::Table::Name.new(self)
    end

os2() click to toggle source

    # File lib/ttfunk.rb, line 94
    def os2
      @os2 ||= TTFunk::Table::OS2.new(self)
    end

postscript() click to toggle source

    # File lib/ttfunk.rb, line 98
    def postscript
      @postscript ||= TTFunk::Table::Post.new(self)
    end

sbix() click to toggle source

    # File lib/ttfunk.rb, line 110
    def sbix
      @sbix ||= TTFunk::Table::Sbix.new(self)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.