Chapter 6. Font Rendering

In this chapter, we will cover the following recipes:

  • Generating and rendering bitmap fonts
  • Baking effects into fonts using Hiero
  • Scaling friendly font rendering with distance fields
  • Dynamic font effects using distance fields

Introduction

Depending on the genre of your awesome game project, you may need to show the user more or less text. Role-playing games and some adventures tend to be very text-heavy, while action games … well, they let the guns do the talking. However, in all likeness, all of these will require some font rendering, even if it is just for the menus or the game scores.

This chapter will start with the very basics of how to generate a Libgdx-compatible font and render some text with it on the screen. We will then move on to effects such as drop shadows or outlines, both using prebaked techniques and shaders. Additionally, we will tackle the font-scaling problem and offer a practical solution using distance field fonts.

By the time you finish reading and practicing with the samples, you will be able to handle most font-rendering issues in your game without too much trouble.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.229.111