Class: SDL2::TTF::Font

Inherits:
Struct
  • Object
show all
Defined in:
lib/sdl2/ttf/font.rb

Overview

Internal structure containing font information

Defined Under Namespace

Classes: CachedGlyph, FT_Bitmap, FT_Open_Args

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Struct

#==, cast, create, #initialize, #to_s, #update_members

Methods included from StructHelper

#member_readers, #member_writers

Constructor Details

This class inherits a constructor from SDL2::Struct

Class Method Details

.default_bgObject



100
101
102
# File 'lib/sdl2/ttf/font.rb', line 100

def self.default_bg
  @@default_bg ||= Color.cast([0,0,0,ALPHA_OPAQUE])
end

.default_bg=(color) ⇒ Object



96
97
98
# File 'lib/sdl2/ttf/font.rb', line 96

def self.default_bg=(color)
  @@default_bg = Color.cast(color)
end

.default_fgObject



92
93
94
# File 'lib/sdl2/ttf/font.rb', line 92

def self.default_fg
  @@default_fg ||= Color.cast([255,255,255, ALPHA_OPAQUE])
end

.default_fg=(color) ⇒ Object



88
89
90
# File 'lib/sdl2/ttf/font.rb', line 88

def self.default_fg=(color)
  @@default_fg = Color.cast(color)
end

.open(file, pt_size) ⇒ Object



74
75
76
# File 'lib/sdl2/ttf/font.rb', line 74

def self.open(file, pt_size)
  TTF.open_font!(file, pt_size)
end

.release(pointer) ⇒ Object



78
79
80
# File 'lib/sdl2/ttf/font.rb', line 78

def self.release(pointer)
  TTF.close_font(pointer)
end

Instance Method Details

#closeObject Also known as: free



82
83
84
# File 'lib/sdl2/ttf/font.rb', line 82

def close()
  TTF.close_font(self)
end

#render_text_blended(text, fg = Font::default_fg) ⇒ Object



115
116
117
118
119
120
# File 'lib/sdl2/ttf/font.rb', line 115

def render_text_blended(text, fg = Font::default_fg)
  #binding.pry
  fg = Color.cast(fg)
  #binding.pry
  TTF.render_text_blended!(self, text, fg)
end

#render_text_blended_wrapped(text, width, fg = default_fg) ⇒ Object



122
123
124
125
# File 'lib/sdl2/ttf/font.rb', line 122

def render_text_blended_wrapped(text, width, fg = default_fg)
  fg = Color.cast(fg)
  TTF.render_text_blended_wrapped!(self, text, fg, width)
end

#render_text_shaded(text, fg = Font::default_fg, bg = Font::default_bg) ⇒ Object



109
110
111
112
113
# File 'lib/sdl2/ttf/font.rb', line 109

def render_text_shaded(text, fg = Font::default_fg, bg = Font::default_bg )
  fg = Color.cast(fg)
  bg = Color.cast(bg)
  TTF.render_text_shaded!(self, text, fg, bg)
end

#render_text_solid(text, color = Font::default_fg) ⇒ Object



104
105
106
107
# File 'lib/sdl2/ttf/font.rb', line 104

def render_text_solid(text, color = Font::default_fg)
  color = Color.cast(color)
  TTF.render_text_solid!(self, text, color)
end