Sprite Font Engine
Posted: Mon Dec 29, 2014 1:29 am
Here's a very, very early version of what I think will contribute greatly to proper GUI design. Currently you have to use a TrueType or OpenType font and can only hope that the user will have that font installed.
Most of the time you only have some labels which don't change, so you can substitute by using a bitmap of that labels. But what about changing displays, like the value of a knob or a rolling LED or something like that?
Sprite Font Engine aims to be a proper bitmapped font replacement for the system fonts. Whatever font you use with SFE, it will always be accessible (it is loaded with the dll or exe). You can rely on it.
It works by dividing each char of a font into sprites that are than arranged on a sheet. This is saved as a bitmap, and loaded into the engine. Next you provide the width and height of the cells and a list of all chars present in the font, in order of appearance.
EDIT: Each char needs at least a 1-pixel-full-transparent-border around it.
Example:
Your bitmap is structured as such
A B C D
E F G H
I J
Then the character list string must read "ABCDEFGHIJ" (fun fact: although I'm german, I just called the letters in english in my head while writing them down)
I don't have enough time to create a proper full ASCII set font. Currently the example fonts only contain the upper case letters needed to write the word "FLOWSTONE". I'm seeking for someone to create a font (A-Z, a-z, 0-9, the most used special signs, and if possible the german umlauts äÄöÖüÜ). If you are willing to help, just make sure you're not just copying/converting an existing font, but really create an original that can be bundled with SFE without license issues. Aim for a font that can be used as a general workhorse, no fancy flower letters and the like
I hope you'll test this intensively, report issues and make feature requests. But before you do so, read the following.
Current restrictions:
- Monospace only (that means, each char takes the same cell size as each other char, regardless of its actual size). Proportional fonts are already on the to-do-list.
- The scale factor currently is based on the cell size. I am thinking of changing it to absolute values, so that you can use Flowstone's grid units. For example, scale 2 would then scale the font so that the font height is exactly two grid squares high. This could be very difficult with more complex fonts, so I am not sure about it. What do you think?
Upcoming features:
- Individual char kerning
- Flexible line height adjustments
- Wrap mode
- module chaining (to have multiple displays with different text using the same sprite font sheet, to save on RAM)
I will post this and the following versions here until it is at a usable, not too buggy state. Then I'll transfer it to Flowstone GURU.
Most of the time you only have some labels which don't change, so you can substitute by using a bitmap of that labels. But what about changing displays, like the value of a knob or a rolling LED or something like that?
Sprite Font Engine aims to be a proper bitmapped font replacement for the system fonts. Whatever font you use with SFE, it will always be accessible (it is loaded with the dll or exe). You can rely on it.
It works by dividing each char of a font into sprites that are than arranged on a sheet. This is saved as a bitmap, and loaded into the engine. Next you provide the width and height of the cells and a list of all chars present in the font, in order of appearance.
EDIT: Each char needs at least a 1-pixel-full-transparent-border around it.
Example:
Your bitmap is structured as such
A B C D
E F G H
I J
Then the character list string must read "ABCDEFGHIJ" (fun fact: although I'm german, I just called the letters in english in my head while writing them down)
I don't have enough time to create a proper full ASCII set font. Currently the example fonts only contain the upper case letters needed to write the word "FLOWSTONE". I'm seeking for someone to create a font (A-Z, a-z, 0-9, the most used special signs, and if possible the german umlauts äÄöÖüÜ). If you are willing to help, just make sure you're not just copying/converting an existing font, but really create an original that can be bundled with SFE without license issues. Aim for a font that can be used as a general workhorse, no fancy flower letters and the like
I hope you'll test this intensively, report issues and make feature requests. But before you do so, read the following.
Current restrictions:
- Monospace only (that means, each char takes the same cell size as each other char, regardless of its actual size). Proportional fonts are already on the to-do-list.
- The scale factor currently is based on the cell size. I am thinking of changing it to absolute values, so that you can use Flowstone's grid units. For example, scale 2 would then scale the font so that the font height is exactly two grid squares high. This could be very difficult with more complex fonts, so I am not sure about it. What do you think?
Upcoming features:
- Individual char kerning
- Flexible line height adjustments
- Wrap mode
- module chaining (to have multiple displays with different text using the same sprite font sheet, to save on RAM)
I will post this and the following versions here until it is at a usable, not too buggy state. Then I'll transfer it to Flowstone GURU.