-
Notifications
You must be signed in to change notification settings - Fork 2
/
font.h
97 lines (74 loc) · 3.09 KB
/
font.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/* --------------------------------------------------------------------
EXTREME TUXRACER
Copyright (C) 1999-2001 Jasmin F. Patry (Tuxracer)
Copyright (C) 2004-2005 Volker Stroebel (Planetpenguin Racer)
Copyright (C) 2010 Extreme Tuxracer Team
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
---------------------------------------------------------------------*/
#ifndef FONT_H
#define FONT_H
#include "bh.h"
#include "ft_font.h"
#include "spx.h"
// --------------------------------------------------------------------
// CFont
// --------------------------------------------------------------------
#define MAX_FONTS 36
class CFont {
private:
FTFont *fonts[MAX_FONTS];
int numFonts;
string fontindex;
int forientation;
int curr_font;
TColor curr_col;
float curr_size;
float curr_fact; // the length factor
wchar_t *UnicodeStr (const char* s);
void UnicodeStr (wchar_t* buff, const char* string);
public:
CFont ();
~CFont ();
void Clear ();
int LoadFont (string name, const char *dir, const char *filename);
int LoadFont (string name, const char *path);
bool LoadFontlist ();
int GetFontIdx (const string &name);
// properties
void SetProps (const string &fontname, float size, TColor col);
void SetProps (const string &fontname, float size);
void SetColor (float r, float g, float b, float a);
void SetColor (TColor col);
void SetSize (float size);
void SetFont (string fontname);
// auto
int AutoSizeN (int rel_val); // rel_val = relative size, return: autosize
int AutoDistanceN (int rel_val); // rel_val = relative dist
// draw
void DrawText (float x, float y, const char *text); // normal char*
void DrawText (float x, float y, const wchar_t *text); // wide char*
void DrawString (float x, float y, const string &s); // string class
void DrawText (float x, float y, const char *text, const string &fontname, float size);
void DrawText (float x, float y, const wchar_t *text, const string &fontname, float size);
void DrawString (float x, float y, const string &s, const string &fontname, float size);
// metrics
void GetTextSize (const char *text, float &x, float &y);
void GetTextSize (const char *text, float &x, float &y, const string &fontname, float size);
float GetTextWidth (const char *text);
float GetTextWidth (const string text);
float GetTextWidth (const wchar_t *text);
float GetTextWidth (const char *text, const string &fontname, float size);
float GetTextWidth (const wchar_t *text, const string &fontname, float size);
float CenterX (const char *text);
void SetOrientation (int orientation);
void MakeLineList (const char *source, CSPList *dest, float width);
};
extern CFont FT;
#endif