2010-02-04 13:33:47 +02:00
|
|
|
//Advanced SFont by Massimiliano Torromeo (cpp wrapper around SFont)
|
|
|
|
|
|
|
|
#ifndef ASFONT_H
|
|
|
|
#define ASFONT_H
|
|
|
|
|
2011-05-09 05:13:11 +03:00
|
|
|
#include "sfontplus.h"
|
|
|
|
|
2010-02-04 13:33:47 +02:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2011-05-09 05:13:11 +03:00
|
|
|
struct SDL_Surface;
|
|
|
|
class Surface;
|
2010-02-04 13:33:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
class ASFont {
|
|
|
|
public:
|
2011-05-09 06:17:25 +03:00
|
|
|
enum HAlign { HAlignLeft, HAlignRight, HAlignCenter };
|
|
|
|
enum VAlign { VAlignTop, VAlignBottom, VAlignMiddle };
|
|
|
|
|
2010-02-04 13:33:47 +02:00
|
|
|
ASFont(SDL_Surface* font);
|
|
|
|
ASFont(Surface* font);
|
2011-05-09 05:13:11 +03:00
|
|
|
ASFont(const std::string &font);
|
2010-02-04 13:33:47 +02:00
|
|
|
~ASFont();
|
|
|
|
|
|
|
|
bool utf8Code(unsigned char c);
|
|
|
|
|
|
|
|
int getHeight();
|
|
|
|
int getHalfHeight();
|
|
|
|
int getLineHeight();
|
|
|
|
int getHalfLineHeight();
|
|
|
|
int getTextWidth(const char* text);
|
2011-05-09 05:13:11 +03:00
|
|
|
int getTextWidth(const std::string& text);
|
|
|
|
int getTextWidth(std::vector<std::string> *text);
|
2010-02-04 13:33:47 +02:00
|
|
|
void write(SDL_Surface* surface, const char* text, int x, int y);
|
2011-05-09 06:17:25 +03:00
|
|
|
void write(SDL_Surface* surface, const std::string& text, int x, int y, HAlign halign = HAlignLeft, VAlign valign = VAlignTop);
|
|
|
|
void write(SDL_Surface* surface, std::vector<std::string> *text, int x, int y, HAlign halign = HAlignLeft, VAlign valign = VAlignTop);
|
|
|
|
void write(Surface* surface, const std::string& text, int x, int y, HAlign halign = HAlignLeft, VAlign valign = VAlignTop);
|
2010-02-04 13:33:47 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
SFontPlus font;
|
|
|
|
int halfHeight, halfLineHeight;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* ASFONT_H */
|