Class: BDF::Font
- Inherits:
-
Object
- Object
- BDF::Font
- Defined in:
- lib/bdf/font.rb
Defined Under Namespace
Classes: ParseError
Instance Attribute Summary collapse
-
#bounding_box_x ⇒ Object
readonly
Returns the value of attribute bounding_box_x.
-
#bounding_box_y ⇒ Object
readonly
Returns the value of attribute bounding_box_y.
-
#displacement_x ⇒ Object
readonly
Returns the value of attribute displacement_x.
-
#displacement_y ⇒ Object
readonly
Returns the value of attribute displacement_y.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
-
#x_resolution ⇒ Object
readonly
Returns the value of attribute x_resolution.
-
#y_resolution ⇒ Object
readonly
Returns the value of attribute y_resolution.
Class Method Summary collapse
Instance Method Summary collapse
- #char(name) ⇒ Object
- #glyph(char) ⇒ Object
-
#initialize(filename) ⇒ Font
constructor
A new instance of Font.
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_x ⇒ Object (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_y ⇒ Object (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_x ⇒ Object (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_y ⇒ Object (readonly)
Returns the value of attribute displacement_y.
26 27 28 |
# File 'lib/bdf/font.rb', line 26 def displacement_y @displacement_y end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
26 27 28 |
# File 'lib/bdf/font.rb', line 26 def name @name end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
26 27 28 |
# File 'lib/bdf/font.rb', line 26 def properties @properties end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
26 27 28 |
# File 'lib/bdf/font.rb', line 26 def size @size end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
26 27 28 |
# File 'lib/bdf/font.rb', line 26 def version @version end |
#x_resolution ⇒ Object (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_resolution ⇒ Object (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 |