Thanks to Jeff, Woopsi now has a smorgasbord of new fonts. They are all included in the main libwoopsi folder, so I’ve had to tweak the makefiles in all projects to accommodate the change.
The fonts include standards such as MS Sans, Garamond, Times New Roman and Courier. Some of them are available in more than one size.
Not all of the fonts Jeff supplied were usable, due to being too large, too small or having other problems. The PackedFonts system has size limits due to using u16s instead of u32s in a variety of places; the limits should be trivial to remove (or at least extend) but it’s probably a good thing that absurdly-sized fonts aren’t allowed. At least one of the fonts was too small to be legible. Others had strange vertical alignment problems. I still need to remove some of the troublesome fonts.
Including all of the fonts in the library has no impact on projects built with standard makefiles, but it vastly bloats the size of the demo project that’s built with VC++. I suppose the makefile must include all .cpp files regardless of whether or not they’re used. Not a problem for end-users, though.
Having some example fonts allowed me to change the way Woopsi was working with its original two fonts - the system font and tiny font. Instead of needing to manually instantiate a Font object and pass in the data comprising the fonts, they’re now implemented as classes. To create an instance of the tiny font, include “fonts/tinyfont.h” and call “new TinyFont()”. To create an instance of the system font, include “fonts/topaz.h” and call “new Topaz()”.
The new name for the system font hints at another change - I’ve replaced the default font. Topaz, apart from being ugly, is a fixed-width font. A considerable amount of screen real estate is taken up with the blank space between letters. Using Jeff’s PackedFont classes I’ve replaced Topaz with NewTopaz. More text can now fit on the DS’ screens, the UI looks more attractive, and as an added bonus, Woopsi looks more like my WinUAE setup.
Along with these changes, I’ve ripped out the global “systemFont” and “tinyFont” objects. These were created in the woopsifuncs.h file. However, tinyFont was only used by the Debug class (which now creates the font itself), whilst systemFont has been absorbed into a new “defaultGadgetStyle” object.
Previously, most of the gadgets in Woopsi could receive a pointer to a font as their final constructor argument. If no font was supplied they used the systemFont instead. They pulled all of their default colours from static members of the “DefaultStyle” class. This worked well enough, but it was an ugly solution.
I’ve re-worked this so that instead of receiving a pointer to a font in their constructors, gadgets can be passed a pointer to a GadgetStyle object instead. GadgetStyle objects contain definitions for all colours a gadget uses and the font. The gadget copies the properties of the object into its own internal GadgetStyle instance. If no object is supplied, they copy the information from the global defaultGadgetStyle object instead. This means that:
- It is much easier to change the font and colours for all gadgets that need to be created;
- It is much easier to change the font and colours for a subset of gadgets that need to be created;
- Colour and font information is stored together.
All of this represents breaking changes.
In other font/style news, the PackedFontBase::isCharBlank() method returns the correct value. I’ve added a packedfonts example program which demonstrates all of the fonts in Woopsi. I’ve also added a defaultstyle example which illustrates how to change the properties of the defaultGadgetStyle and alter the appearance of Woopsi.
I’ve made many other fixes. The ListBox draws correctly when it is dragged; previously, dragging upwards caused graphical artifacts to appear. It does not attempt to redraw the item at index -1 in its list. The CycleButton redraws itself correctly if it is clicked but it contains no options. The Label and its subclasses recalculate their text positions and redraw when their fonts are changed, a does the MultiLineTextBox.
There are a few fixes to the TextBox. It does not attempt to reposition its cursor if it contains no text. Its cursor jumps to the right location if its font is a PackedFont.
I’ve stopped the Graphics::floodFill() method from getting stuck in an infinite loop (not sure when I introduced that bug), and removed some unused bitmaps from the demo.
Finally, I’ve added the FileListBox classes to SVN. These were supposed to have been released in version 0.42, but I apparently forgot to check them into SVN and so they were omitted. This means that the FileRequester is broken in version 0.42. I’m just glad I still had copies of the files.