David Hedbor wrote:
Actually, as I said, adding “abs(descent) + 1” to the height doesn’t
work. What did work was to change back the height setting in
TTF_SizeUNICODE to that of SDL_ttf 1.x; *h = font->height
After doing that, all rendering is perfect. Bug or feature, anyone?
To reply to my own message, it seems like the problem is the difference
between the rendered surface and the size of the text on that surface.
From pglabel.cpp with some debug:
int wl = my_srfText->w;
int hl = my_srfText->h;
std::cout << "Actual size: " << wl << "?" << hl << std::endl;
GetTextExtend(my_textLabel.c_str(), wl, hl);
std::cout << "Given size: " << wl << "?" << hl << std::endl;
my_srfText is the rendered text for this label. GetTextExtend returns
the size for the actual text using TTF_SizeText():
Example output is:
Actual size: 98?21
Given size: 98?11
I.e the rendered surface is 21 pixels high while paragui only uses the
height of the actual text rendered. The problem is that the text on the
returned surface isn’t in the upper left corner, but somewhere farther
down (depending on the text). That is why text is truncated.
There are two fixes for this:
- Make TTF_SizeUNICODE return the “maximum” height, like in SDL_ttf 1.0
or
- Make the text render functions return a cropped surface.
- Return or make it possible to fetch a SDL_rect with the boundaries of
the rendered text (width and height is not enough to represent the text
in the rendered surface).
Personally, 1 or 2 are the only acceptable solutions to me, since 3
would be backwards incompatible.
Either way, the current behavior is a bug, which, if known, can be
worked around (i.e ParaGUI can ignore the TTF_SizeText height and use
the height of the surface).
– david