Fonts

Introduction

Generate a new font

To generate a new font we can use phxFontEditor.exe that is located in the Binary folder and select File→New and select generator to start the built in font generator.

You can modify the settings of the font to generate to add shadows and outlines but the default settings will be sufficient for the tutorial.

To select witch characters to include in the bitmap font press the Characters button above to show the character select dialog. If you have a translation file containing all required characters you can press Import to add all the characters from that file.

Close the character dialog and press OK to generate the font. Make sure to check the preview window so the text looks okey.

If any character overlaps or looks wrong you can change the location and offsets of the character in the character editor page.

Aligning text

One of the overloaded text out methods allows to align text inside a rectangle

// Draw text that is aligned to the top right corner of the device window
Fonts[0].TextOut(Device.Bounds,'Aligned text', taTopRight, clrGreen);// Draw text that is aligned to the bottom left corner of the device window
Fonts[0].TextOut(Device.Bounds,'Aligned text', taBottomLeft, clrTeal);

Green text to the top right corner and teal in the bottom left corner.

Drawing selection

The font class has support for drawing selection rectangles for a text using the DrawSelection method.