kettek2/wiki/games/newsboy/Newsboy_0x00/engine/Text.h

49 lines
1.2 KiB
C

#ifndef TEXT_H
#define TEXT_H
#include <SDL2/SDL_ttf.h>
#include <SDL2/SDL_opengl.h>
struct Text {
TTF_Font *font;
char *string;
int width;
int height;
GLuint texture;
SDL_Color color;
};
struct Text *newText(TTF_Font *font, const char *string);
int freeText(struct Text *text);
int updateText(struct Text *text); // recreates Texture
int setTextColor(struct Text *text, SDL_Color color);
int changeText(struct Text *text, const char *string, ...);
int renderText(struct Text *text, int x, int y);
// direct
int renderString(TTF_Font *font, SDL_Color color, const char *string, int x, int y);
/* glyphs */
struct Glyphs {
GLuint texture;
int w;
int h;
TTF_Font *font;
int offsetx[108];
int minx[108];
int miny[108];
int maxx[108];
int maxy[108];
int ch_w[108];
int ch_h[108];
int advance[108];
};
int loadGlyphs(struct Glyphs *glyphs, TTF_Font *font);
int getGlyphStringW(struct Glyphs *glyphs, const char *string);
int renderGlyph(struct Glyphs *glyphs, SDL_Color color, char ch, int x, int y);
int renderGlyphString(struct Glyphs *glyphs, SDL_Color color, int x, int y, const char *string);
int renderGlyphStringF(struct Glyphs *glyphs, SDL_Color color, int x, int y, const char *string, ...);
#endif