class SugarPNG::Font
Constants
- DEFAULT_DIR
- HEIGHT
Public Class Methods
new(dir = DEFAULT_DIR)
click to toggle source
# File lib/sugar_png/font.rb, line 6 def initialize dir = DEFAULT_DIR @dir = dir @pages = {} end
Public Instance Methods
[](idx)
click to toggle source
get glyph by index
# File lib/sugar_png/font.rb, line 16 def [] idx idx = idx.ord if !idx.is_a?(Integer) && idx.respond_to?(:ord) raise ArgumentError.new("invalid idx type: #{idx.class}") unless idx.is_a?(Integer) raise ArgumentError.new("invalid idx: #{idx.inspect}") if idx<0 || idx>0xffff pageno = idx >> 8 @pages[pageno] ||= Page.new(File.join(@dir, "%02x" % pageno)) @pages[pageno][idx] end
height()
click to toggle source
# File lib/sugar_png/font.rb, line 11 def height HEIGHT end