Home Game Development java – Rendering Smooth Text in Libgdx

java – Rendering Smooth Text in Libgdx

0
java – Rendering Smooth Text in Libgdx

[ad_1]

After doing some testing it seems the problem is caused by a large font size and a large viewport size. Luckily this is easily fixed by following these simple steps:

  1. Reduce Font size by half.
  2. Reduce Viewport size by half.
  3. Make sure the font minFilter is MipMapLinearNearest and the magFilter is Linear.
  4. If this doesn’t work go to step 1.

(In your case though I think the font size is just fine so I would suggest just reducing viewport size at first. If that doesn’t work follow the steps above.)

To be clear try reducing your font size to 32 and your viewport size to (500, 500 * aspectRatio), then if that doesn’t work try 16 and (250, 250 * aspectRatio).

This method does require you to use a separate viewport to render text with unless you want to change the viewport size of your actual game as well, so just create a new viewport of any type and make sure to apply it before rendering text:

gameViewport.apply();
batch.setProjectionMatrix(gameViewport.getCamera().combined);
batch.begin();
// Draw game stuff

textViewport.apply(true); // Center camera
batch.setProjectionMatrix(textViewport.getCamera().combined);
// Draw text
batch.end();

For me this produces quite satisfactory results
font showcase

[ad_2]

Previous article SpaceX calls off Falcon Heavy launch for third day in a row
Next article Ryan Gosling accepts Golden Globe nom with Kenergy
Hello there! My name is YoleeTeam, and I am thrilled to welcome you to AmazonianGames.com. As the premier destination for all things related to Amazon Games' universe, we are dedicated to providing you with the most exciting and immersive gaming experiences out there. From captivating visuals to exhilarating gameplay, our website is packed with comprehensive insights, updates, and reviews to keep you ahead of the game. Whether you're a seasoned gamer or new to the scene, I am here to guide you through this virtual frontier. If you have any questions or suggestions, feel free to reach out to me at john@yoleesolutions.com. Embark on your Amazon gaming journey today with AmazonianGames.com and let the adventure begin!