We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4344

Summary: TTF_Size() is computing a little bigger size
Product: SDL_ttf Reporter: Sylvain <sylvain.becker>
Component: miscAssignee: Sam Lantinga <slouken>
Status: RESOLVED INVALID QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: unspecified   
Hardware: x86_64   
OS: Linux   
Attachments: patch

Description Sylvain 2018-10-30 21:20:24 UTC
TTF_Size() is computing a little bigger size because it considers also the "glyph->advance" in its computation.

I think we only need the bounding box.
Comment 1 Sylvain 2018-10-30 21:21:21 UTC
Created attachment 3422 [details]
patch
Comment 2 Sam Lantinga 2018-10-31 03:13:35 UTC
I'm accepting this patch, but I know I added that to fix something, but I can't remember what. Since you've made a bunch of other fixes relating to sizing, let's try this out now.

https://hg.libsdl.org/SDL_ttf/rev/7489a6f9929b
Comment 3 Sylvain 2018-10-31 08:37:10 UTC
I think I got the reason as I saw some log

1) Now, when you render a string with only space " ", it will report an internal error "Text has zero width" and return NULL surface.
Because bounding box is 0 (maxx == minx == 0), but advance has the value for potential next glyph.

If you really want 1 space you need to write 2 spaces "  ", so that the second one confirm the advance of the first.

2) Also, the difference can be for a trailing space. "foo " will be rendered as "foo" (+ advance of the last 'o').

Not sure, 
We may still want the first case 1), without the 2) ?
Comment 4 Sylvain 2018-10-31 21:35:05 UTC
Case 3)

It may be a memory allocation when rendering a font (non scalable?) that has no width metrics. See bug 4346.
Comment 5 Sam Lantinga 2018-10-31 22:05:12 UTC
Okay, this change is rolled back:
https://hg.libsdl.org/SDL_ttf/rev/5df6b43a9f6d