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 2127

Summary: SDL_ttf (2.0.12) - Cannot load .fon file. (Couldn't set the font size).
Product: SDL_ttf Reporter: Yohann Ferreira <yohann.ferreira>
Component: miscAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: philipp.wiesemann
Version: 2.0.12   
Hardware: x86_64   
OS: Linux   
URL: https://github.com/christopho/zsdx/issues/59
Attachments: The .fon file.

Description Yohann Ferreira 2013-10-01 21:05:36 UTC
Created attachment 1351 [details]
The .fon file.

Hi, :)

When loading the given .fon file, an error message is returned:
Fatal: Cannot load font from file 'text/fixed8.fon': Couldn't set font size

The same code was previously working, using SDL 1.2 and SDL_TTF 2.0.10.

I'll attach the .fon file (open licensed) which can also be downloaded from here:
https://github.com/christopho/zsdx/blob/master/data/text/fixed8.fon

We also tried:
TTF_OpenFont()
TTF_OpenFontRW()
TTF_OpenFontIndex()
or
TTF_OpenFontIndexRW()

with corresponding parameters but we couldn't get anything load.

Curious thing, the upstream dev told me that changing the .fon extension to .ttf did the trick(?!?)

This also happens on OSX AFAIK.

Thanks a lot for your help.

Best regards,
Comment 1 Yohann Ferreira 2013-10-02 08:39:38 UTC
Hi again,

More tests followed and the main upstream dev (christopho) told me that changing the .fon file to .ttf doesn't work after all.
Sorry, for the counter-saying.

I'll post a snippet testcase as soon as possible.
Comment 2 Yohann Ferreira 2013-10-02 15:14:46 UTC
Here is the gist of it:

#include "SDL_ttf.h"
#include <stdio.h>

int main(int /*argc*/, char ** /*argv*/)
{
    if (TTF_Init() == -1) {
        printf("TTF_Init: %s\n", TTF_GetError());
        exit(2);
    }

    // load font.ttf at size 16 into font
    TTF_Font *font;
    font = TTF_OpenFont("./fixed8.fon", 16);
    if (!font) {
        printf("TTF_OpenFont: %s\n", TTF_GetError());
        // handle error
        exit(1);
    }

    TTF_CloseFont(font);

    TTF_Quit();
}
Comment 3 Sam Lantinga 2013-10-03 08:32:01 UTC
Have you tried debugging SDL_ttf?  As far as I know, nothing in SDL_ttf has changed that would affect that, we're just using a newer version of FreeType.
Comment 4 Yohann Ferreira 2013-10-03 08:47:03 UTC
Hi, :)

Ack. I've requested some test on OSX. I'll do the same on Debian and will tell you whether we find something interesting for you.

Regards,
Comment 5 Yohann Ferreira 2013-11-07 11:19:55 UTC
Just to say I'm still on it. Stay tuned.
Comment 6 Yohann Ferreira 2014-09-24 10:14:33 UTC
Hey,

Seems the following bug is quite similar:
https://bugzilla.libsdl.org/show_bug.cgi?id=2468

Also, it seems that this fix is related to the problem:
http://hg.libsdl.org/SDL_ttf/rev/86aa91bce20c

I'd like to build the latest SDL_ttf with the newest Freetype version to debug several issues I've opened here.

Is there a reason you're still using FreeType 2.4.8?
(Freetype 2.5.x has fixed several issues about glyph metrics, among other things...)

Best regards,

Bertram
Comment 7 Sam Lantinga 2017-09-10 05:51:50 UTC
This is fixed in the latest SDL_ttf version.