Difference between revisions of "BmfFonts"
Jump to navigation
Jump to search
m (Redspark moved page BmfFonts Module to BmfFonts: Removing the Word Module because it is under the category Sys Modules.) |
m (Updated URL) |
||
| (One intermediate revision by one other user not shown) | |||
| Line 1: | Line 1: | ||
| − | This module defines a Font class which can read fonts in [ | + | This module defines a Font class which can read fonts in [http://bmf.wz.cz:8080/?page=format BMF format] version 1.1 or 1.2. Version 1.2 is a recent but significant upgrade, adding support for non-ASCII Unicode characters, kerning, and an alpha channel for anti-aliased fonts. |
If you run bmfFonts.demo (or load and run the module directly instead of using import), it will look for the fonts folder, and draw a string with each one. The final font will be drawn at 3X scale at the bottom of the screen. | If you run bmfFonts.demo (or load and run the module directly instead of using import), it will look for the fonts folder, and draw a string with each one. The final font will be drawn at 3X scale at the bottom of the screen. | ||
| Line 16: | Line 16: | ||
<ms> | <ms> | ||
import "bmfFonts" | import "bmfFonts" | ||
| − | + | clear | |
// Load a font | // Load a font | ||
| − | f = bmfFonts.Font.load("fonts/ | + | f = bmfFonts.Font.load("/sys/fonts/Arial14Bold.bmf") |
// Print a string in that font to gfx | // Print a string in that font to gfx | ||
Latest revision as of 15:02, 22 November 2025
This module defines a Font class which can read fonts in BMF format version 1.1 or 1.2. Version 1.2 is a recent but significant upgrade, adding support for non-ASCII Unicode characters, kerning, and an alpha channel for anti-aliased fonts.
If you run bmfFonts.demo (or load and run the module directly instead of using import), it will look for the fonts folder, and draw a string with each one. The final font will be drawn at 3X scale at the bottom of the screen.
Classes
| Name | Description |
|---|---|
| Font | Stores all data about a particular font. |
| CharData | Stores all data about a single character in a specific font. |
Example
import "bmfFonts"
clear
// Load a font
f = bmfFonts.Font.load("/sys/fonts/Arial14Bold.bmf")
// Print a string in that font to gfx
f.print "Hello world!", 20, 500
// Get a character image, and make a Sprite out of it
spr = new Sprite
spr.image = f.getCharImage("R")
spr.x = 600
spr.y = 500
spr.scale = 3
spr.rotation = 30
display(4).sprites.push spr