4

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?

Indiana Kernick
  • 5,041
  • 2
  • 20
  • 50

1 Answers1

1

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

Indiana Kernick
  • 5,041
  • 2
  • 20
  • 50
  • 1
    Always use a real "Pixel Font" when you want to render pixelated text. These fonts are designed to be rendered at a specific point size to perfectly fit on the native pixels of the screen. You can only render these at 1x 2x 3x etc or they will not look right. If you specifically want pixel fonts with SDL, it is almost easier to just render rectangles from a bitmap font. By the way, you can find some nice free ones on the Dwarf Fortress website: http://dwarffortresswiki.org/Tileset_repository. – null Sep 21 '17 at 03:25