FontRenderer class
Renders characters to a CanvasTerminal using normal fonts and text drawing. Can draw any character supported by the supplied font. This renderer works best if you keep the scale at 1 and instead adjust the pixel size of the supplied font string based on the device pixel density.
- Inheritance
-
- Object
- Renderer
- CanvasRenderer
- FontRenderer
Constructors
- FontRenderer(CanvasRenderingContext2D context, [int scale = 1, String? font])
Properties
- charHeight → int
-
The height in pixels of a single rendered character (before scaling)
no setteroverride
- charSize → Vec2
-
final
- charWidth → int
-
The width in pixels of a single rendered character (before scaling)
no setteroverride
- ctx → CanvasRenderingContext2D
-
no setterinherited
- font → String
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
loaded
→ Future<
void> -
Returns a Future that resolves whenever the underlying assets used by
the renderer are fully loaded and the renderer is actually ready to
render. Calling renderChar before waiting for this future to resolve may
result in undefined behavior.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scale → int
-
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
renderChar(
int x, int y, Char char) → void -
Render the given Char at column
x
, rowy
in a Terminaloverride -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
measureText(
CanvasRenderingContext2D context, String font, [String? text]) → Vec2 -
Measure the size of the given
text
(or a single character by default) in pixels using the given 2Dcontext
and the given CSSfont
string.