Text has zero width
This is stdout.txt...
I am using ttf to take a .ttf file and then make a bitmap font with it for use with my bitmap-font engine. The only bad part is that it fails with the above message...
This is the code:
#include <SDL/SDL.h>
#include <SDL/SDL_ttf.h>
#include <string>
#include <fstream>
#include <iostream>
using namespace std;
void init() {
SDL_Init(0);
TTF_Init();
}
void deinit() {
TTF_Quit();
SDL_Quit();
}
int main(int argc, char *argv[]) {
init();
ifstream f("data.txt");
string filename;
int size, fr, fg, fb, br, bg, bb;
f >> filename >> size >> fr >> fg >> fb >> br >> bg >> bb;
TTF_Font *font = TTF_OpenFont((filename + ".ttf").c_str(), size);
if (!font) {
cout << TTF_GetError();
return 1;
}
char ascii[256];
for (unsigned i = 0; i < 256; i++)
ascii = (char)i;
SDL_Color foreground = {fr, fg, fb};
SDL_Color background = {br, bg, bb};
SDL_Surface *str = TTF_RenderText_Shaded(
font,
ascii,
foreground,
background
);
if (!str) {
cout << TTF_GetError();
return 1;
}
SDL_SaveBMP(str, (filename + ".bmp").c_str());
SDL_FreeSurface(str);
TTF_CloseFont(font);
deinit();
}
Any ideas? I just hacked this together very quickly, but it
should work...
And yes, data.txt exists as follows:
times 16 255 255 255 0 0 0
And again yes, times.ttf is in there too.
THANKS!