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 2470

Summary: bug rendering a string starting with glyph with negative minx, in TTF_RenderUTF8_Shaded
Product: SDL_ttf Reporter: Sylvain <sylvain.becker>
Component: miscAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: unspecified   
Hardware: x86_64   
OS: Linux   
Attachments: test case
ttf font
ttf font with no problem

Description Sylvain 2014-03-29 13:42:33 UTC
Hi,

With latest version, on Linux. (but whatever OS would do the same).


I try to render the string "Jap" in size 50, and what appears to be rendered is "Jap." 
The "." is in fact the begining of the "J"

The first glyph has a value "minx" of -14
And so, should be "compensated for the wrap around with negative minx".

... basically : 

in the function TTF_RenderUTF8_Shaded: 
line 1586:
we have the initialisation to false :

 first = SDL_FALSE

and it should be 

 first = SDL_TRUE

Thanks, 

Sylvain
Comment 1 Sylvain 2014-04-17 06:53:12 UTC
Created attachment 1622 [details]
test case

test case
Comment 2 Sylvain 2014-04-17 06:55:45 UTC
Created attachment 1623 [details]
ttf font

And also the font for the testcase. All fonts do not make the bug appear. This one does.
Comment 3 Sylvain 2014-04-17 06:59:28 UTC
I was thinking of this patch : 


diff -r 1854597a90fd SDL_ttf.c
--- a/SDL_ttf.c	Sun Feb 02 02:32:02 2014 -0800
+++ b/SDL_ttf.c	Thu Apr 17 08:55:46 2014 +0200
@@ -1583,7 +1583,7 @@
 
     /* Load and render each character */
     textlen = SDL_strlen(text);
-    first = SDL_FALSE;
+    first = SDL_TRUE;
     xstart = 0;
     while ( textlen > 0 ) {
         Uint16 c = UTF8_getch(&text, &textlen);



But this is not perfect. The "." does not appear, but the "J" is not fully rendered.
Comment 4 Sylvain 2014-04-17 07:00:28 UTC
Created attachment 1624 [details]
ttf font with no problem

This TTF font has no problem !
Comment 5 Sylvain 2014-04-22 11:21:40 UTC
Sorry, the two fonts are different. So the "J" is rendered as exepected when the patch is applied.

Please double-check the patch and apply it.
Thanks
Comment 6 Sam Lantinga 2014-06-28 18:43:15 UTC
Fixed, thanks!
https://hg.libsdl.org/SDL_ttf/rev/86d0c63699f4