Class: BDF::Font

Inherits:
Object
  • Object
show all
Defined in:
lib/bdf/font.rb

Defined Under Namespace

Classes: ParseError

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ Font

Returns a new instance of Font.



9
10
11
12
# File 'lib/bdf/font.rb', line 9

def initialize(filename)
  @file = File.open(filename)
  parse
end

Instance Attribute Details

#bounding_box_xObject (readonly)

Returns the value of attribute bounding_box_x.



26
27
28
# File 'lib/bdf/font.rb', line 26

def bounding_box_x
  @bounding_box_x
end

#bounding_box_yObject (readonly)

Returns the value of attribute bounding_box_y.



26
27
28
# File 'lib/bdf/font.rb', line 26

def bounding_box_y
  @bounding_box_y
end

#displacement_xObject (readonly)

Returns the value of attribute displacement_x.



26
27
28
# File 'lib/bdf/font.rb', line 26

def displacement_x
  @displacement_x
end

#displacement_yObject (readonly)

Returns the value of attribute displacement_y.



26
27
28
# File 'lib/bdf/font.rb', line 26

def displacement_y
  @displacement_y
end

#nameObject (readonly)

Returns the value of attribute name.



26
27
28
# File 'lib/bdf/font.rb', line 26

def name
  @name
end

#propertiesObject (readonly)

Returns the value of attribute properties.



26
27
28
# File 'lib/bdf/font.rb', line 26

def properties
  @properties
end

#sizeObject (readonly)

Returns the value of attribute size.



26
27
28
# File 'lib/bdf/font.rb', line 26

def size
  @size
end

#versionObject (readonly)

Returns the value of attribute version.



26
27
28
# File 'lib/bdf/font.rb', line 26

def version
  @version
end

#x_resolutionObject (readonly)

Returns the value of attribute x_resolution.



26
27
28
# File 'lib/bdf/font.rb', line 26

def x_resolution
  @x_resolution
end

#y_resolutionObject (readonly)

Returns the value of attribute y_resolution.



26
27
28
# File 'lib/bdf/font.rb', line 26

def y_resolution
  @y_resolution
end

Class Method Details

.from_file(filename) ⇒ Object



5
6
7
# File 'lib/bdf/font.rb', line 5

def self.from_file(filename)
  self.new(filename)
end

Instance Method Details

#char(name) ⇒ Object



14
15
16
# File 'lib/bdf/font.rb', line 14

def char(name)
  Char.new(@chars[name])
end

#glyph(char) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/bdf/font.rb', line 18

def glyph(char)
  # TODO: We could use a glyph list here to get the name from unicode point
  name, _ = @chars.find do |name, char_|
    char_[:encoding] == char.ord
  end
  char(name)
end