class SugarPNG::Font::Page

Public Class Methods

new(fname) click to toggle source
# File lib/sugar_png/font.rb, line 27
def initialize fname
  @data   = Marshal.load(File.binread(fname))
  @glyphs = {}
end

Public Instance Methods

[](ord) click to toggle source

get glyph by index

# File lib/sugar_png/font.rb, line 33
def [] ord
  idx = ord&0xff
  @glyphs[idx] ||= Glyph.new(
    :height => HEIGHT,
    :width  => @data[idx].size/2,
    :data   => @data[idx],
    :ord    => ord
  )
end