Draw TTF font at partial pixel coordinates

In my project, one effect I would like to use is making text grow and shrink in size. The idea is to load the font .ttf file as a RWops once, then on each frame, calculate the size, create a TTF from the RWops and size, use it to render the text to a surface, use the surface to make a texture, and blit the texture. To make it still display in the same place, I’m also adjusting the y coordinate upward by half the difference in font size. I think in practice, this value (half) needs to depend on the font in question but that’s getting off-topic.

Sounds simple enough, but it actually looks really janky in execution, when the font size increases, say from 30pt to 30.5pt, making the font render 1 pixel taller (30.5 rounds up to 31) but render at the same height (-.25 rounds up to 0) and such unusual quantizations continue to happen on subsequent frames.

Is there a way that I can have the font text draw at partial pixel coordinates (say 300.5, 200.5 as opposed to 300, 200) and have it blend at the edges, or some other technique to make this look smoother, or am I stuck with something that either looks really bizarre or just doesn’t have that extra effect?

Using SDL_RenderCopyF() or SDL_RenderCopyExF(), which take float coordinates, to render your textures should achieve that, so long as you specify a suitable blend mode and scaling quality.

The floating-point rendering functions have been available since SDL 2.0.10 but are seemingly still not mentioned in the main SDL 2.0 documentation. I have expressed my annoyance at this before!

Hey, thanks for the tip! Sounds like exactly what I need.

I wish the Ada bindings weren’t so far behind. These things are such a pain to get to link… Whoops, actually that one was on me. I copied the library to the wrong directory, haha.