Difference between revisions of "BmfFonts"

From MiniScript Wiki
Jump to navigation Jump to search
(Created page with "This module defines a Font class which can read fonts in [https://bmf.php5.cz/index.php?page=format BMF format] version 1.1 or 1.2. Version 1.2 is a recent but significant upg...")
 
(Previously this page was using font on path ("fonts/ming.bmf") which wasn't part of /sys directory. so i edited this to use font which is part of /sys directory)
 
(One intermediate revision by one other user not shown)
Line 16: Line 16:
 
<ms>
 
<ms>
 
import "bmfFonts"
 
import "bmfFonts"
 
+
clear
 
// Load a font
 
// Load a font
f = bmfFonts.Font.load("fonts/ming.bmf")
+
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 10:47, 7 July 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