Hi
pioj!
pioj wrote: ↑Sun Dec 21, 2025 7:50 am
Is there any example to print bitmap font characters or custom-defined ones provided by a new charset?
Yes, of course, there are some basic examples
here and
here for this type of task. I recommend updating your compiler first, as a related issue with COLDFIX was fixed just this afternoon, so it's worth downloading the latest version.
In any case, there are several examples in the repository, and they all revolve around some
ugBASIC commands that allow you to change the standard character font. The
beta version, however, introduces a command that allows you to print a font composed of images. But let's go in order. The command for changing the font is the
FONT LOAD command. This command simply replaces one or more characters in the system font with a graphic representation, which is loaded from an image file. The main feature of this command is that it works with monochrome 8x8 pixel fonts, which is the standard font size on almost all platforms. The main scope is to specify an image containing the various characters: the compiler will automatically crop the characters from the image, transform them into small monochrome bitmaps, and assign them to the various SCREENCODES. There are two syntaxes.
The first syntax allows you to load the entire character set, from position 0 onwards.
The second syntax, however, allows you to load characters starting from a specific position (42, in this case).
If desired, you can specify a starting font other than the standard one to begin working with. In this case, simply use the
DEFINE FONT directive. The allowed parameters for
DEFINE FONT are in the User Manual (see chapter 18.8.2).
Anyway, these instructions work with the
PRINT command, which prints text in multiples of 8 pixels, vertically and horizontally, and is also subject to the limitations of the
CONSOLE command. In the
beta version, support for writing on the screen using a font of any size and in any vertical position has been added. The instruction is called
GR PRINT, and must be used when loading an
ATLAS. The syntax is as follows:
Code: Select all
font := LOAD ATLAS("fonts_4x8.png") FRAME SIZE(4,8)
GR PRINT "EXAMPLE" AT 42, 42 WITH font
pioj wrote: ↑Sun Dec 21, 2025 7:50 am
I'd like to display some text on the screen using a small font.
Note that writing with the
PRINT command or equivalent maintains a minimum size of 8x8 pixels, while
GR PRINT does not suffer from this limitation but, on the other hand, it may not be able to draw characters smaller than 8x8 pixels due to other limitations related to the graphics hardware. In fact,
ugBASIC does not provide any kind of abstraction, and therefore does not guarantee that a functionality will be implemented identically everywhere.
I hope this helps!
