SDL ttf openfont issue

  c++, sdl, sdl-ttf, truetype

I’m currently writing a gui and wanted to implement sdl_ttf to my project, the problem is font loading: no font wants to actually load, TTF_OpenFont errors with Error writing to datastream.

bool gui::initalize()
{

    if (SDL_Init(SDL_INIT_VIDEO) != 0)
    {
        printf("SDL_Init error: %sn", SDL_GetError());
        return 1;
    }
    this->window   = SDL_CreateWindow("Speller", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 800, 0);
    this->renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_SOFTWARE);
    SDL_SetRenderDrawColor(renderer, 22, 26, 29, SDL_ALPHA_OPAQUE);
    SDL_RenderClear(renderer);
    SDL_RenderPresent(renderer);

    if (TTF_Init() == -1)
    {
        printf("TTF_Init error: %sn", TTF_GetError());
        return 1;
    }

    // this->font = TTF_OpenFontRW(SDL_RWFromMem(Heebo_Regular_ttf, Heebo_Regular_ttf_len), 1, 16);
    this->font = TTF_OpenFont("Consolas.ttf", 16);

    if (!this->font)
    {
        printf("TTF_OpenFont error: %sn", TTF_GetError());
        return 1;
    }
 /* removed unrelated code */
}

Source: Windows Questions C++

LEAVE A COMMENT