1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-09-30 09:22:55 +03:00
gmenu2x/src/font.h
Maarten ter Huurne d4344c7960 Revert "Removed support for multi-line text drawing"
This reverts commit 0908aa7bb7.

It turns out there are multi-line text messages in use: Nebuleon found
one in the confirmation message when deleting a section.
2014-07-23 02:22:27 +02:00

52 lines
1.0 KiB
C++

// Original font class was replaced by an SDL_ttf based one by Paul Cercueil.
// License: GPL version 2 or later.
#ifndef FONT_H
#define FONT_H
#include <SDL_ttf.h>
#include <string>
class Surface;
class Font {
public:
enum HAlign { HAlignLeft, HAlignRight, HAlignCenter };
enum VAlign { VAlignTop, VAlignBottom, VAlignMiddle };
/**
* Returns a newly created Font object for the default font,
* or nullptr if there was a problem creating it.
*/
static Font *defaultFont();
Font(const std::string &path, unsigned int size);
~Font();
int getTextWidth(const char *text);
int getTextWidth(const std::string& text)
{
return getTextWidth(text.c_str());
}
int getLineSpacing()
{
return lineSpacing;
}
void write(Surface *surface,
const std::string &text, int x, int y,
HAlign halign = HAlignLeft, VAlign valign = VAlignTop);
private:
Font(TTF_Font *font);
void writeLine(Surface *surface, std::string const& text,
int x, int y, HAlign halign, VAlign valign);
TTF_Font *font;
int lineSpacing;
};
#endif /* FONT_H */