class
Eagle::TrueTypeFont
- Eagle::TrueTypeFont
- Eagle::Font
- Reference
- Object
Overview
A Font backed by a TrueType file at one pixel size. Glyphs are rasterized on first use.
Create one with Font.load, which also caches it.
font = Font.load("res://fonts/Inter.ttf", 24)
g.print("Hello", 10, 10, font: font)
Defined in:
eagle/graphics/truetype.crConstructors
-
.load(path : String, size : Number, filter : GPU::Filter = GPU::Filter::Linear) : TrueTypeFont
Loads a font file at size pixels, without caching.
-
.new(data : Bytes, size : Number, filter : GPU::Filter = GPU::Filter::Linear)
Creates a font from raw TrueType bytes at size pixels.
Instance Method Summary
-
#ascent : Float32
Height above the baseline, in pixels.
-
#descent : Float32
Depth below the baseline, in pixels.
-
#family_name : String
The font's family name.
-
#glyph(char : Char) : Glyph | Nil
The glyph for char, rasterizing it on first use.
-
#kerning(a : Char, b : Char) : Float32
Kerning between two characters, in pixels.
-
#line_height : Float32
Distance between baselines, in pixels.
-
#preload(chars : Enumerable(Char) = (32..126).map(&.chr)) : self
Rasterizes glyphs up front so the first frame that uses them doesn't hitch.
-
#size : Float32
Pixel size the font was loaded at.
-
#texture : Texture
The first atlas texture.
-
#ttf : TrueType
The parsed font file.
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
Loads a font file at size pixels, without caching. Prefer Font.load.
Creates a font from raw TrueType bytes at size pixels.
Instance Method Detail
The glyph for char, rasterizing it on first use. Returns nil if the font lacks it.
Rasterizes glyphs up front so the first frame that uses them doesn't hitch. Covers printable ASCII by default.