This is probably an artifact of the way FreeType does it’s rasterization.
In the solid case it has to make decisions about where to place the glyphs on pixel boundaries,
where the shaded and blended case it can simulate subpixel precision.
That makes sense. The middle horizontal line of the “e” lines up with
that in “F” and “E” etc so that is quite a reasonable guess.
Sam’s correct in that it’s an artifact of FreeType operating in all of
1/65536ths, 1/64ths and 1/1ths of a pixel at once.
However, perceived difference between solid and shaded is an artifact
of chosen font and line height - it may as well
manifest differently for some other combination.
Ok, I will try that, but I have a performance issue here: my editor technology redraws
the whole screen every modification, in principle the decoupling between the
display and editing functions make the thing simple. I recently switched from
displaying text lines to characters (to support syntax highlighting) and the speed
difference is perceptible. [by which I mean, unacceptable] Guess I’ll need to do some caching.
I’m stiil using a software renderer then blitting to the window surface,
probably I should move to HW rendering.
You will have to aggressively cache whatever SDL_ttf (and, ultimately,
FreeType + any shaping) returns to you.
That would be per horizontal line of text at the coarsest level, might
need to be even finer-grained than that.
There is literally no other way.
If you want it stay closer to hardware, you could try to fiddle with
pixel formats (GL buffers and attempt putting all your cache backing
store into GPU memory, dropping SDL rendering entirely).
I stopped at caching intensity+glyph attribution (for highlights and
such) per unicode character in main memory.
Here’s a bug-ridden example: https://github.com/lxnt/zhban
Note the difference between unicode code point (character for
simplicity) and the font glyph. It’s an one-way N:M map without any
generic way to determine it - and that’s if only ligatures are used.
You don’t really want to learn this all unless you absolutely can not
either drop all the fancy stuff like ligatures or use Pango for your
text-editor-rendering needs.
Ah, and yes, forgot to mention - it is not possible to determine a
pixel size of a string rendered via FreeType without a dry-run
rendering. This applies to everything (and any other font renderer)
except for bitmap fonts.On Sat, Jul 13, 2013 at 6:18 PM, john skaller wrote:
On 13/07/2013, at 3:24 PM, Sam Lantinga wrote:
–
./lxnt