Font Rendering

From Slick2D Wiki
(Redirected from Fonts)
Jump to: navigation, search

There are currently two implementations of font rendering in Slick, both complying to one common Font interface. This interface allows us to render the text and also to determine the size and spacing of characters within that font (allowing for justification). The two implementations currently available are bitmap based - this provides fast convenient rendering but does not allow smooth scaling. A glyph rendering approach directly liked to true type fonts may be provided later.

AngelCode Fonts[edit]

The wonderful folks at AngelCode provide the Bitmap Font Generator (see below) which can be used to produce textures filled with the characters from a font. The tools also produces a descriptor file which defined the positions of the font characters and the associated kerning values (kerning defines how characters should be placed next to each other for smooth looking paragraphs).

Slick provides the font implementation AngelCodeFont which is responsible for loading both the texture and descriptor file and making the font itself available to be rendered. The benefits of AngelCode font is flexibility, ease of use and kerning support. However, AngelCode font support in Slick can be slightly slower than the alternatives due to the need to account for kerning when rendering text.

Sprite Sheet Fonts[edit]

The alternative approach is to use evenly spaced fonts, where the font texture is split into an even grid and each character is placed within a cell. The font implementation SpriteSheetFont provides a way to load a texture with a given spacing and use it as a font.

While this is slightly faster than using AngelCode generated font it does not support kerning and it is advised that where large paragraphs of text are to be displayed that AngelCode fonts are used in preference.

External Links[edit]