| Summary: | Aligning outlined text broken/inconsistent since changeset 387 | ||
|---|---|---|---|
| Product: | SDL_ttf | Reporter: | Joe LeVeque <joeleveque> |
| Component: | misc | Assignee: | Sylvain <sylvain.becker> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | major | ||
| Priority: | P2 | ||
| Version: | unspecified | ||
| Hardware: | All | ||
| OS: | All | ||
| Attachments: |
HelveticaNeue-Medium.otf font file
testcase test case |
||
Can you make a test-case that I can compile, provide the font and eventually a screenshot, so that the bug is clear. 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 Created attachment 3851 [details]
HelveticaNeue-Medium.otf font file
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. Created attachment 3852 [details]
testcase
ok, thanks, I've made a test-case and I see the issue
I think this is fixed by: https://hg.libsdl.org/SDL_ttf/rev/bf2e6c9bfc83 Can you double-check ? Created attachment 3858 [details]
test case
A better test-case
Also update check: glyph metrics, ascent, descent, height with outline style: https://hg.libsdl.org/SDL_ttf/rev/355d6e6181c5 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! Ok great, I mark this as resolved |
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);