In other words, I want to use different letters when it's under 20pt, which are optimized for smaller rendering. Is this possible with a TTF font?
Yes, it’s (sort of) possible, if your TTF file is a variable OpenType font.
To start off, 20pt would not normally be considered “smaller rendering” – that’s larger than most headings in books and documents, and any optical size variants for that kind of size would normally be in the ‘Header’ or ‘Display’ territory.
Most commonly, size-based variants (often called optical size variants) are created as separate fonts, and it’s then up to the user/designer to decide when to switch between the ‘default’ (running body text) variant and other optical size variants. This is, I think, a good thing. It won’t necessarily be the case that all text above 16pt should be in the Display variant, or that all text below 8pt should be in the Small variant (or whatever the type designer has called them) – that needs to be decided on a per-use-case basis.
In variable fonts, however, it is possible to use the Optical Size axis to have multiple such variants in a single font. One possible value for this axis is
auto, which is intended to allow the renderer to choose the appropriate optical size based on the font size.
This is supported by all modern browsers, as well as by applications such as InDesign (since InDesign 2021, version 16.4). If you set the Optical Size axis to
auto, you will get the behaviour you’re asking about.
However, I don’t believe there is a way to force this behaviour. If the user sets the Optical Size axis to a different value than
auto, then that is the optical size that will be used, regardless of font size. There is no way that I’m aware of to override the user’s selection.