How to make high quality monochrome text using SDL2_TTF?

I am writing a game with old school low-resolution graphics. I am using SDL2_TTF to render monochrome text, but it does not seem to hint properly. I set a tooltip with TTF_SetFontHinting(font, TTF_HINTING_MONO)and displayed text with all three rendering functions ( TTF_RenderText_Solid, TTF_RenderText_Shadedand TTF_RenderText_Blended), but I am not happy with the results. Here is the conclusion that I get from TTF_RenderText_Solid. Other functions display smoothed text.

Actual result

And here is the conclusion that I want. This is Andale Mono 12pt (same as above), provided by the Mac Terminal emulator and increased by 4 times.

Expected Result

The output quality matters because the text is increased 4 times when the player is displayed. Why are they different? I thought FreeType was a de facto font rendering library, so SDL2_TTF and Terminal will both use it.

Am I just using the SDL2_TTF library incorrectly?

+4
source share
1 answer

I did not want to contact the SDL2_TTF library to achieve the effect I was looking for, so I decided to find another font that looks better. I found that if I select a font that looks pixelated and displays it in the correct size, everything looks fine.

The effect I was looking for

+1
source

Source: https://habr.com/ru/post/1680676/


All Articles