class DXRubySDL::Font

Constants

FONTS
FONT_ALIASES

Attributes

_ttf[R]
size[R]

Public Class Methods

new(size, fontname = '', hash = {}) click to toggle source
# File lib/dxruby_sdl/font.rb, line 9
def initialize(size, fontname = '', hash = {})
  @size = size

  if !SDL::TTF.init?
    SDL::TTF.init
  end
  if !(path = (FONTS[fontname] || FONT_ALIASES[fontname]))
    path = FONTS.first.last
  end
  font_cache = Font.instance_variable_get('@font_cache')
  args = [path, size]
  if font_cache.key?(args)
    @_ttf = font_cache[args]
  else
    @_ttf = font_cache[args] = SDL::TTF.open(*args)
  end
end

Public Instance Methods

getWidth(string)
Alias for: get_width
get_width(string) click to toggle source
# File lib/dxruby_sdl/font.rb, line 27
def get_width(string)
  return @_ttf.text_size(string).first
end
Also aliased as: getWidth