class TTFunk::File

Attributes

contents[R]
directory[R]

Public Class Methods

from_dfont(file, which=0) click to toggle source
# File lib/ttfunk.rb, line 14
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 18
def initialize(contents)
  @contents = StringIO.new(contents)
  @directory = Directory.new(@contents)
end
open(file) click to toggle source
# File lib/ttfunk.rb, line 10
def self.open(file)
  new(::File.open(file, "rb") { |f| f.read })
end

Public Instance Methods

ascent() click to toggle source
# File lib/ttfunk.rb, line 24
def ascent
  @ascent ||= (os2.exists? && os2.ascent && os2.ascent.nonzero?) || horizontal_header.ascent
end
bbox() click to toggle source
# File lib/ttfunk.rb, line 36
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 49
def cmap
  @cmap ||= TTFunk::Table::Cmap.new(self)
end
descent() click to toggle source
# File lib/ttfunk.rb, line 28
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 41
def directory_info(tag)
  directory.tables[tag.to_s]
end
glyph_locations() click to toggle source
# File lib/ttfunk.rb, line 81
def glyph_locations
  @glyph_locations ||= TTFunk::Table::Loca.new(self)
end
glyph_outlines() click to toggle source
# File lib/ttfunk.rb, line 85
def glyph_outlines
  @glyph_outlines ||= TTFunk::Table::Glyf.new(self)
end
header() click to toggle source
# File lib/ttfunk.rb, line 45
def header
  @header ||= TTFunk::Table::Head.new(self)
end
horizontal_header() click to toggle source
# File lib/ttfunk.rb, line 53
def horizontal_header
  @horizontal_header ||= TTFunk::Table::Hhea.new(self)
end
horizontal_metrics() click to toggle source
# File lib/ttfunk.rb, line 57
def horizontal_metrics
  @horizontal_metrics ||= TTFunk::Table::Hmtx.new(self)
end
kerning() click to toggle source
# File lib/ttfunk.rb, line 65
def kerning
  @kerning ||= TTFunk::Table::Kern.new(self)
end
line_gap() click to toggle source
# File lib/ttfunk.rb, line 32
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 61
def maximum_profile
  @maximum_profile ||= TTFunk::Table::Maxp.new(self)
end
name() click to toggle source
# File lib/ttfunk.rb, line 69
def name
  @name ||= TTFunk::Table::Name.new(self)
end
os2() click to toggle source
# File lib/ttfunk.rb, line 73
def os2
  @os2 ||= TTFunk::Table::OS2.new(self)
end
postscript() click to toggle source
# File lib/ttfunk.rb, line 77
def postscript
  @postscript ||= TTFunk::Table::Post.new(self)
end