romfont
romfont ¶
Read a raw binary font file and creates a Framebuffer font object.
Classes¶
ROMFont ¶
ROMFont(font_file)
Create a new ROMFont object. The font file is a raw binary file containing 256 characters. Each character is 8 pixels wide and any number of pixels high.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
font_file
|
str
|
The path to the raw binary font file. |
required |
Usage
font = ROMFont("fontfile.bin") font.text(canvas, "Hello", 0, 0, 1)
Methods:¶
char ¶
char(canvas, c, x, y, key=-1, pal=None)
Place a character on the canvas.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
canvas
|
FrameBuffer
|
The canvas to draw on. |
required |
c
|
str
|
The character to draw. |
required |
x
|
int
|
The x coordinate. |
required |
y
|
int
|
The y coordinate. |
required |
key
|
int
|
The color key. |
-1
|
pal
|
FrameBuffer
|
The palette to use. |
None
|
Returns:
| Type | Description |
|---|---|
Area
|
The area of the canvas that was drawn on. |
text ¶
text(canvas, s, x, y, fg, bg=None)
Place text on the canvas. Breaks on
to next line.
Does not break on line going off canvas.
Args:
canvas (Canvas): The DisplayDriver, FrameBuffer, or other canvas-like object to draw on.
s (str): The text to draw.
x (int): The x coordinate.
y (int): The y coordinate.
fg (int): The foreground color.
bg (int): The background color.
Returns:
Area: The area of the canvas that was drawn on.