Class: AlpacaBuildTool::Font
- Inherits:
-
Object
- Object
- AlpacaBuildTool::Font
- Defined in:
- lib/alpacabuildtool/log/font.rb
Overview
Font class provides representation of .flf fonts so they can be used
Constant Summary collapse
- FONTPATH =
Absolute path to data folder where *.flf fonts stored
File.(File.dirname(__FILE__) + '/../data')
Instance Attribute Summary collapse
-
#hard_blank ⇒ Object
readonly
Returns the value of attribute hard_blank.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
Instance Method Summary collapse
-
#[](ord) ⇒ Object
Returns array of lines that represent current character.
-
#char?(ord) ⇒ Boolean
Returns true if font have representation for char.ord.
-
#initialize(name) ⇒ Font
constructor
Creates instance of class.
Constructor Details
#initialize(name) ⇒ Font
Creates instance of class
name
-
font name(currently ‘doom’ or ‘lean’ exist)
15 16 17 18 19 20 21 22 23 |
# File 'lib/alpacabuildtool/log/font.rb', line 15 def initialize(name) @filename = File.join FONTPATH, name + '.flf' File.open(@filename, 'rb') do |f| header = f.gets.strip.split(/ /) @hard_blank = header[0] @height = header[1].to_i load_characters f end end |
Instance Attribute Details
#hard_blank ⇒ Object (readonly)
Returns the value of attribute hard_blank.
5 6 7 |
# File 'lib/alpacabuildtool/log/font.rb', line 5 def hard_blank @hard_blank end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
5 6 7 |
# File 'lib/alpacabuildtool/log/font.rb', line 5 def height @height end |
Instance Method Details
#[](ord) ⇒ Object
Returns array of lines that represent current character
ord
-
character code(char.ord)
37 38 39 |
# File 'lib/alpacabuildtool/log/font.rb', line 37 def [](ord) @characters[ord] end |
#char?(ord) ⇒ Boolean
Returns true if font have representation for char.ord
ord
-
character code(char.ord)
29 30 31 |
# File 'lib/alpacabuildtool/log/font.rb', line 29 def char?(ord) @characters.key? ord end |