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 4701 - Aligning outlined text broken/inconsistent since changeset 387
Summary: Aligning outlined text broken/inconsistent since changeset 387
Status: RESOLVED FIXED
Alias: None
Product: SDL_ttf
Classification: Unclassified
Component: misc (show other bugs)
Version: unspecified
Hardware: All All
: P2 major
Assignee: Sylvain
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-07-01 04:38 UTC by Joe LeVeque
Modified: 2019-07-04 18:29 UTC (History)
0 users

See Also:


Attachments
HelveticaNeue-Medium.otf font file (24.42 KB, application/x-font-otf)
2019-07-01 07:41 UTC, Joe LeVeque
Details
testcase (3.46 KB, text/x-csrc)
2019-07-01 09:41 UTC, Sylvain
Details
test case (5.11 KB, text/x-csrc)
2019-07-03 10:59 UTC, Sylvain
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Joe LeVeque 2019-07-01 04:38:25 UTC
As of changeset 387, using code that previously always aligned outlined text with filled text properly is now broken. Below is simplified sample code taken from the web which should be able to reproduce this issue. Previously, one just needed to blit the filled text at an offset of (OUTLINE_SIZE, OUTLINE_SIZE) over the outline text. This always worked consistently.

However, as of changeset 387, now one must shift the filled text down by (OUTLINE_SIZE *2) (?!?), and when positioning on the x-axis, the amount varies and is inconsistent based on the text being rendered (sometimes OUTLINE_SIZE works, sometimes it's off by a pixel or two).


Simplified sample code which should be able to reproduce the issue:

#define OUTLINE_SIZE 2

/* load font and its outline */ 
font = TTF_OpenFont(font_path, font_size); 
font_outline = TTF_OpenFont(font_path, font_size); 
TTF_SetFontOutline(font_outline, OUTLINE_SIZE); 

/* render text and text outline */ 
SDL_Color white = {0xFF, 0xFF, 0xFF}; 
SDL_Color black = {0x00, 0x00, 0x00}; 
SDL_Surface *bg_surface = TTF_RenderText_Blended(font_outline, text, black); 
SDL_Surface *fg_surface = TTF_RenderText_Blended(font, text, white); 
SDL_Rect rect = {OUTLINE_SIZE, OUTLINE_SIZE, fg_surface->w, fg_surface->h}; 

/* blit text onto its outline */ 
SDL_SetSurfaceBlendMode(fg_surface, SDL_BLENDMODE_BLEND); 
SDL_BlitSurface(fg_surface, NULL, bg_surface, &rect); 
SDL_FreeSurface(fg_surface);
Comment 1 Sylvain 2019-07-01 06:54:53 UTC
Can you make a test-case that I can compile, provide the font and eventually a screenshot, so that the bug is clear.
Comment 2 Sylvain 2019-07-01 07:24:16 UTC
Also, did you try with latest SDL_ttf version ?

there was this change about outline, maybe it helps
https://bugzilla.libsdl.org/show_bug.cgi?id=4355

thanks
Comment 3 Joe LeVeque 2019-07-01 07:41:25 UTC
Created attachment 3851 [details]
HelveticaNeue-Medium.otf font file
Comment 4 Joe LeVeque 2019-07-01 07:47:22 UTC
Hi Sylvain. The bug is still present in the latest commit of SDL_ttf. Actually I found this issue by updating to the current head of the repo. I traced it back to changeset 387. The issue was introduced in changeset 387 and is present from changeset 387 onward.

I will try to find some time to write a small program you can test with, but in the meantime, I have attached the font file which I am using (HelveticaNeue-Medium.otf) for you to play around with. I have not tried any other fonts to see if the issue affects them as well, but I'm fairly certain it will, because I have never seen this behavior in many years of using SDL_ttf.
Comment 5 Sylvain 2019-07-01 09:41:55 UTC
Created attachment 3852 [details]
testcase

ok, thanks, I've made a test-case and I see the issue
Comment 6 Sylvain 2019-07-03 10:59:04 UTC
I think this is fixed by:
https://hg.libsdl.org/SDL_ttf/rev/bf2e6c9bfc83

Can you double-check ?
Comment 7 Sylvain 2019-07-03 10:59:48 UTC
Created attachment 3858 [details]
test case

A better test-case
Comment 8 Sylvain 2019-07-04 07:02:32 UTC
Also update check: glyph metrics, ascent, descent, height with outline style:

https://hg.libsdl.org/SDL_ttf/rev/355d6e6181c5
Comment 9 Joe LeVeque 2019-07-04 18:05:36 UTC
Thanks for looking into this issue so quickly, Sylvain. I have compiled and tested the latest SDL_ttf code and it appears as though the issue is fixed. Outlined text alignment seems to work properly now, as it did previously. Thanks again!
Comment 10 Sylvain 2019-07-04 18:29:23 UTC
Ok great, I mark this as resolved