class
Eagle::BitmapFont
- Eagle::BitmapFont
- Eagle::Font
- Reference
- Object
Overview
A font drawn from a grid of glyph images, as used by classic and pixel-art games.
atlas = Texture.new(Image.new(96, 48))
font = BitmapFont.grid(atlas, 6, 8) # glyphs from ' ' onward, row by row
Defined in:
eagle/graphics/font.crConstructors
-
.builtin : BitmapFont
Builds Eagle's embedded 5x7 pixel font.
-
.grid(texture : Texture, cell_w : Int32, cell_h : Int32, first : Char = ' ', count : Int32 = 95, advance : Int32 | Nil = nil) : BitmapFont
Builds a font from a sheet where glyphs sit in equal cells, row by row, starting at first.
-
.new(texture : Texture, line_height : Float32)
Creates an empty bitmap font.
Instance Method Summary
-
#add(char : Char, region : TextureRegion, advance : Float32 | Nil = nil, offset : Vec2 = Vec2::ZERO) : self
Adds a glyph for char.
-
#glyph(char : Char) : Glyph | Nil
The glyph for char, or
nil. -
#line_height : Float32
Distance between baselines, in pixels, before
scale. -
#texture : Texture
The atlas texture holding the glyphs.
Instance methods inherited from class Eagle::Font
glyph(char : Char) : Glyph | Nil
glyph,
height : Float32
height,
kerning(a : Char, b : Char) : Float32
kerning,
letter_spacing : Float32
letter_spacing,
letter_spacing=(letter_spacing : Float32)
letter_spacing=,
line_height : Float32
line_height,
measure(text : String) : Vec2
measure,
scale : Float32
scale,
scale=(scale : Float32)
scale=,
texture : Texture
texture,
width(text : String) : Float32
width,
wrap(text : String, max_width : Number) : Array(String)
wrap
Constructor methods inherited from class Eagle::Font
default : Font
default,
load(path : String, size : Number, filter : GPU::Filter = GPU::Filter::Linear) : Font
load
Constructor Detail
def self.builtin : BitmapFont
#
Builds Eagle's embedded 5x7 pixel font. Font.default returns a shared copy.
def self.grid(texture : Texture, cell_w : Int32, cell_h : Int32, first : Char = ' ', count : Int32 = 95, advance : Int32 | Nil = nil) : BitmapFont
#
Builds a font from a sheet where glyphs sit in equal cells, row by row, starting at first.
Instance Method Detail
def add(char : Char, region : TextureRegion, advance : Float32 | Nil = nil, offset : Vec2 = Vec2::ZERO) : self
#
Adds a glyph for char. The advance defaults to the region width.
def line_height : Float32
#
Description copied from class Eagle::Font
Distance between baselines, in pixels, before scale.