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 5340

Summary: TTF_RenderText_Blended fails to render GNU Unifont capital letter S with 2 pixel outline
Product: SDL_ttf Reporter: Sander in 't Veld <sander>
Component: miscAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: minor    
Priority: P2 CC: sander, sylvain.becker
Version: 2.0.15   
Hardware: x86_64   
OS: All   
Attachments: Functions render() and test() that render the string 'Test S' with different fonts and outlines

Description Sander in 't Veld 2020-11-05 11:43:46 UTC
Created attachment 4506 [details]
Functions render() and test() that render the string 'Test S' with different fonts and outlines

On both Linux and Windows 10, TTF_RenderText_Blended() and TTF_RenderUTF8_Blended() fail to render any text containing the capital letter S using the font GNU Unifont with an outline of 2 pixels. They instead return null, and TTF_GetError() reports the peculiar error "Couldn't find glyph".

I recently added translation support to the game I am working on. I was testing Polish translations when I noticed that one of the buttons had no text in Polish: "Tutorial" in English rendered fine, but its Polish translation "Samouczek" failed to render. At first I assumed it was some obscure UTF8 character that only looked like an S, but then I wrote a quick test and was a bit baffled to find this in my game's logs:

2020-11-05 12:01:35.361 NONE  [13012] [render@57] Rendered 'Test A'.
2020-11-05 12:01:35.361 NONE  [13012] [render@57] Rendered 'Test B'.
2020-11-05 12:01:35.361 NONE  [13012] [render@57] Rendered 'Test C'.
2020-11-05 12:01:35.361 NONE  [13012] [render@57] Rendered 'Test D'.
2020-11-05 12:01:35.361 NONE  [13012] [render@57] Rendered 'Test E'.
2020-11-05 12:01:35.361 NONE  [13012] [render@57] Rendered 'Test F'.
2020-11-05 12:01:35.361 NONE  [13012] [render@57] Rendered 'Test G'.
2020-11-05 12:01:35.362 NONE  [13012] [render@57] Rendered 'Test H'.
2020-11-05 12:01:35.362 NONE  [13012] [render@57] Rendered 'Test I'.
2020-11-05 12:01:35.362 NONE  [13012] [render@57] Rendered 'Test J'.
2020-11-05 12:01:35.362 NONE  [13012] [render@57] Rendered 'Test K'.
2020-11-05 12:01:35.362 NONE  [13012] [render@57] Rendered 'Test L'.
2020-11-05 12:01:35.362 NONE  [13012] [render@57] Rendered 'Test M'.
2020-11-05 12:01:35.362 NONE  [13012] [render@57] Rendered 'Test N'.
2020-11-05 12:01:35.362 NONE  [13012] [render@57] Rendered 'Test O'.
2020-11-05 12:01:35.362 NONE  [13012] [render@57] Rendered 'Test P'.
2020-11-05 12:01:35.362 NONE  [13012] [render@57] Rendered 'Test Q'.
2020-11-05 12:01:35.363 NONE  [13012] [render@57] Rendered 'Test R'.
2020-11-05 12:01:35.363 WARN  [13012] [render@61] Failed to render 'Test S': Couldn't find glyph
2020-11-05 12:01:35.363 NONE  [13012] [render@57] Rendered 'Test T'.
2020-11-05 12:01:35.363 NONE  [13012] [render@57] Rendered 'Test U'.
2020-11-05 12:01:35.363 NONE  [13012] [render@57] Rendered 'Test V'.
2020-11-05 12:01:35.363 NONE  [13012] [render@57] Rendered 'Test W'.
2020-11-05 12:01:35.363 NONE  [13012] [render@57] Rendered 'Test X'.
2020-11-05 12:01:35.363 NONE  [13012] [render@57] Rendered 'Test Y'.
2020-11-05 12:01:35.363 NONE  [13012] [render@57] Rendered 'Test Z'.

I just wrote some more tests, and it only happens with an outline of exactly 2 pixels (not 1 or 3 or 4):

2020-11-05 12:01:35.363 NONE  [13012] [test@98] Trying outline = 0, hinting = 0, utf8 = 0:
2020-11-05 12:01:35.364 NONE  [13012] [render@57] Rendered 'Test S'.
2020-11-05 12:01:35.364 NONE  [13012] [test@98] Trying outline = 0, hinting = 0, utf8 = 1:
2020-11-05 12:01:35.366 NONE  [13012] [render@57] Rendered 'Test S'.
2020-11-05 12:01:35.366 NONE  [13012] [test@98] Trying outline = 0, hinting = 1, utf8 = 0:
2020-11-05 12:01:35.367 NONE  [13012] [render@57] Rendered 'Test S'.
2020-11-05 12:01:35.367 NONE  [13012] [test@98] Trying outline = 0, hinting = 1, utf8 = 1:
2020-11-05 12:01:35.368 NONE  [13012] [render@57] Rendered 'Test S'.
2020-11-05 12:01:35.368 NONE  [13012] [test@98] Trying outline = 1, hinting = 0, utf8 = 0:
2020-11-05 12:01:35.369 NONE  [13012] [render@57] Rendered 'Test S'.
2020-11-05 12:01:35.369 NONE  [13012] [test@98] Trying outline = 1, hinting = 0, utf8 = 1:
2020-11-05 12:01:35.371 NONE  [13012] [render@57] Rendered 'Test S'.
2020-11-05 12:01:35.371 NONE  [13012] [test@98] Trying outline = 1, hinting = 1, utf8 = 0:
2020-11-05 12:01:35.372 NONE  [13012] [render@57] Rendered 'Test S'.
2020-11-05 12:01:35.372 NONE  [13012] [test@98] Trying outline = 1, hinting = 1, utf8 = 1:
2020-11-05 12:01:35.374 NONE  [13012] [render@57] Rendered 'Test S'.
2020-11-05 12:01:35.374 NONE  [13012] [test@98] Trying outline = 2, hinting = 0, utf8 = 0:
2020-11-05 12:01:35.375 WARN  [13012] [render@61] Failed to render 'Test S': Couldn't find glyph
2020-11-05 12:01:35.376 NONE  [13012] [test@98] Trying outline = 2, hinting = 0, utf8 = 1:
2020-11-05 12:01:35.377 WARN  [13012] [render@61] Failed to render 'Test S': Couldn't find glyph
2020-11-05 12:01:35.378 NONE  [13012] [test@98] Trying outline = 2, hinting = 1, utf8 = 0:
2020-11-05 12:01:35.379 WARN  [13012] [render@61] Failed to render 'Test S': Couldn't find glyph
2020-11-05 12:01:35.379 NONE  [13012] [test@98] Trying outline = 2, hinting = 1, utf8 = 1:
2020-11-05 12:01:35.381 WARN  [13012] [render@61] Failed to render 'Test S': Couldn't find glyph
2020-11-05 12:01:35.381 NONE  [13012] [test@98] Trying outline = 3, hinting = 0, utf8 = 0:
2020-11-05 12:01:35.382 NONE  [13012] [render@57] Rendered 'Test S'.
2020-11-05 12:01:35.382 NONE  [13012] [test@98] Trying outline = 3, hinting = 0, utf8 = 1:
2020-11-05 12:01:35.383 NONE  [13012] [render@57] Rendered 'Test S'.
2020-11-05 12:01:35.384 NONE  [13012] [test@98] Trying outline = 3, hinting = 1, utf8 = 0:
2020-11-05 12:01:35.385 NONE  [13012] [render@57] Rendered 'Test S'.
2020-11-05 12:01:35.385 NONE  [13012] [test@98] Trying outline = 3, hinting = 1, utf8 = 1:
2020-11-05 12:01:35.386 NONE  [13012] [render@57] Rendered 'Test S'.
2020-11-05 12:01:35.387 NONE  [13012] [test@98] Trying outline = 4, hinting = 0, utf8 = 0:
2020-11-05 12:01:35.388 NONE  [13012] [render@57] Rendered 'Test S'.
2020-11-05 12:01:35.388 NONE  [13012] [test@98] Trying outline = 4, hinting = 0, utf8 = 1:
2020-11-05 12:01:35.390 NONE  [13012] [render@57] Rendered 'Test S'.
2020-11-05 12:01:35.390 NONE  [13012] [test@98] Trying outline = 4, hinting = 1, utf8 = 0:
2020-11-05 12:01:35.391 NONE  [13012] [render@57] Rendered 'Test S'.
2020-11-05 12:01:35.392 NONE  [13012] [test@98] Trying outline = 4, hinting = 1, utf8 = 1:
2020-11-05 12:01:35.393 NONE  [13012] [render@57] Rendered 'Test S'.

It doesn't seem to happen with other fonts:

2020-11-05 12:01:35.393 NONE  [13012] [test@114] Switching to font /usr/share/fonts/truetype/noto/NotoMono-Regular.ttf
2020-11-05 12:01:35.394 NONE  [13012] [render@57] Rendered 'Test S'.
2020-11-05 12:01:35.394 NONE  [13012] [test@114] Switching to font /usr/share/fonts/truetype/dejavu/DejaVuSans.ttf
2020-11-05 12:01:35.395 NONE  [13012] [render@57] Rendered 'Test S'.

I just downloaded the latest GNU Unifont TTF file (13.0.03) from https://unifoundry.com/unifont/index.html to make sure it wasn't a glitch in an old copy of the font. I've attached the snippet that I used to generated these logs (with the logging macro replaced with std::cout). For what it's worth, the font size used is 16 as GNU Unifont's glyphs are 16x8 bitmaps.

(I wasn't sure if I should report this bug here or with GNU, but I figured because it only appears with specific SDL_TTF options it is probably a bug in the way SDL_TTF handles something peculiar about GNU Unifont's capital S glyph.)
Comment 1 Sylvain 2020-11-05 14:21:16 UTC
Can you try with latest head sources of SDL_ttf, from https://hg.libsdl.org/SDL_ttf/  ?

If this doesn't work for a font + a specific size, this sounds to be a bug in freetype ... (which could be fixed in a higher version though).
Comment 2 Sylvain 2020-11-05 14:56:20 UTC
I actually trying with latest and all seems ok:

Rendered 'Test A'.
Rendered 'Test B'.
Rendered 'Test C'.
Rendered 'Test D'.
Rendered 'Test E'.
Rendered 'Test F'.
Rendered 'Test G'.
Rendered 'Test H'.
Rendered 'Test I'.
Rendered 'Test J'.
Rendered 'Test K'.
Rendered 'Test L'.
Rendered 'Test M'.
Rendered 'Test N'.
Rendered 'Test O'.
Rendered 'Test P'.
Rendered 'Test Q'.
Rendered 'Test R'.
Rendered 'Test S'.
Rendered 'Test T'.
Rendered 'Test U'.
Rendered 'Test V'.
Rendered 'Test W'.
Rendered 'Test X'.
Rendered 'Test Y'.
Rendered 'Test Z'.
Trying outline = 0, hinting = 0, utf8 = 0:
Rendered 'Test S'.
Trying outline = 0, hinting = 0, utf8 = 1:
Rendered 'Test S'.
Trying outline = 0, hinting = 1, utf8 = 0:
Rendered 'Test S'.
Trying outline = 0, hinting = 1, utf8 = 1:
Rendered 'Test S'.
Trying outline = 1, hinting = 0, utf8 = 0:
Rendered 'Test S'.
Trying outline = 1, hinting = 0, utf8 = 1:
Rendered 'Test S'.
Trying outline = 1, hinting = 1, utf8 = 0:
Rendered 'Test S'.
Trying outline = 1, hinting = 1, utf8 = 1:
Rendered 'Test S'.
Trying outline = 2, hinting = 0, utf8 = 0:
Rendered 'Test S'.
Trying outline = 2, hinting = 0, utf8 = 1:
Rendered 'Test S'.
Trying outline = 2, hinting = 1, utf8 = 0:
Rendered 'Test S'.
Trying outline = 2, hinting = 1, utf8 = 1:
Rendered 'Test S'.
Trying outline = 3, hinting = 0, utf8 = 0:
Rendered 'Test S'.
Trying outline = 3, hinting = 0, utf8 = 1:
Rendered 'Test S'.
Trying outline = 3, hinting = 1, utf8 = 0:
Rendered 'Test S'.
Trying outline = 3, hinting = 1, utf8 = 1:
Rendered 'Test S'.
Trying outline = 4, hinting = 0, utf8 = 0:
Rendered 'Test S'.
Trying outline = 4, hinting = 0, utf8 = 1:
Rendered 'Test S'.
Trying outline = 4, hinting = 1, utf8 = 0:
Rendered 'Test S'.
Trying outline = 4, hinting = 1, utf8 = 1:
Rendered 'Test S'.
Switching to font /usr/share/fonts/truetype/noto/NotoMono-Regular.ttf
Rendered 'Test S'.
Switching to font /usr/share/fonts/truetype/dejavu/DejaVuSans.ttf
Rendered 'Test S'.
Comment 3 Sander in 't Veld 2020-11-06 17:31:54 UTC
Yes, I just recompiled the latest SDL_ttf (703ebc7c66fd) with freetype 2.9.1 and SDL2 2.0.12 (which we already used) and I can confirm that the bug is now gone.

Thanks!
Comment 4 Sylvain 2020-11-06 19:05:56 UTC
Ok thanks. I marked as resolved.