Indiana Kernick
Indiana Kernick

Reputation: 5331

How do I render high quality monochrome text with SDL2_TTF?

I'm writing a game with old school low resolution graphics. I'm using SDL2_TTF to render monochrome text but it doesn't seem to be hinted properly. I set the hinting with TTF_SetFontHinting(font, TTF_HINTING_MONO) and rendered the text with all three rendering functions (TTF_RenderText_Solid, TTF_RenderText_Shaded and TTF_RenderText_Blended) but I'm not happy with the results. Here's the output I'm getting from TTF_RenderText_Solid. The other functions output antialiased text.

Actual output

And here's the output I want. This is Andale Mono 12pt (same as above) rendered by the Mac Terminal emulator and scaled up 4x.

Expected output

The quality of the output does matter because the text is scaled up 4x when shown to the player. Why are they different? I thought that FreeType was the de-facto font rendering library so SDL2_TTF and Terminal would both be using it.

Am I simply using the SDL2_TTF library incorrectly?

Upvotes: 4

Views: 1032

Answers (1)

Indiana Kernick
Indiana Kernick

Reputation: 5331

I didn't want to mess with the SDL2_TTF library to achieve the effect I was looking for so I decided to find a different font that looks better. I found that if I chose a font that looks pixelated and render it at just the right point size everything looks fine.

The effect I was looking for

Upvotes: 1

Related Questions