Class: AlpacaBuildTool::Font

Inherits:
Object
  • Object
show all
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.expand_path(File.dirname(__FILE__) + '/../data')

Instance Attribute Summary collapse

Instance Method Summary collapse

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_blankObject (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

#heightObject (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