Search code examples
javafontsbitmapbitmap-fonts

BitMap fonts in java


In the game Minecraft, the developers have used a PNG file for screen fonts.

How would I go about doing this in my Java application?


Solution

  • The Java font rendering system assumes scalable fonts only, such as TrueType fonts, that describe the shapes of glyphs in terms of parameterized curves.

    There is no support for bitmapped fonts, so you would have to lay out the glyphs in your own code. So if you wanted to display a String at position (x, y), you would need to look up the shapes for your bitmapped font, then find the first letter's shape, draw it at (x,y), find the next letters' shape, draw it to (x+fontWidth, y), etc.