-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
convert renderttf functions to TTFRenderer methods for #199
- Loading branch information
Showing
2 changed files
with
47 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,17 @@ | ||
extern bool initttf(); | ||
extern TTF_Font* openfont(const char * path, int size); | ||
extern void renderttf(TTF_Font* f, const char* message, SDL_Color col, int x, int y, float scale = 1.f); | ||
struct _TTF_Font; | ||
typedef struct _TTF_Font TTF_Font; | ||
|
||
class TTFRenderer | ||
{ | ||
public: | ||
bool initttf(); | ||
void openfont(const char * path, int size); | ||
void renderttf(const char* message, SDL_Color col, int x, int y, float scale = 1.f); | ||
void fontsize(int pts = 12); | ||
private: | ||
TTF_Font* f; //the current working font | ||
std::map<int, TTF_Font *> fontcache; //different sizes of the font are cached in a map which maps them to their size in pt | ||
const char * path; | ||
}; | ||
|
||
extern TTFRenderer ttr; |