-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
dd_bitmapfont.h
137 lines (109 loc) · 4.22 KB
/
dd_bitmapfont.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/**\file dd_bitmapfont.h
*\section License
* License: GPL
* Online License Link: http://www.gnu.org/licenses/gpl.html
*
*\author Copyright © 1999-2011 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2006-2011 Daniel Swanson <danij@dengine.net>
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
/**
* Bitmap Fonts.
*/
#ifndef LIBDENG_API_BITMAPFONT_H
#define LIBDENG_API_BITMAPFONT_H
#include "dd_uri.h"
typedef uint32_t fontid_t;
/**
* Find the associated id for a font named @a name, if it cannot be found
* a fatal error is produced.
*
* @param name Name of the font to look up.
* @return Unique id of the found font.
*/
fontid_t FR_FontIdForName(const char* name);
/**
* Same as FR_SafeFontIdForName except does not produce a fatal error if the
* specified font is not found.
*
* @param name Name of the font to look up.
* @return Unique id of the font if found else @c 0
*/
fontid_t FR_SafeFontIdForName(const char* name);
void FR_ResetTypeInTimer(void);
/**
* @defGroup drawTextFlags Draw Text Flags
*/
/*@{*/
#define DTF_ALIGN_LEFT 0x0001
#define DTF_ALIGN_RIGHT 0x0002
#define DTF_ALIGN_TOP 0x0004
#define DTF_ALIGN_BOTTOM 0x0008
#define DTF_NO_TYPEIN 0x0010
#define DTF_NO_SHADOW 0x0020
#define DTF_NO_GLITTER 0x0040
#define DTF_ALIGN_TOPLEFT (DTF_ALIGN_TOP|DTF_ALIGN_LEFT)
#define DTF_ALIGN_BOTTOMLEFT (DTF_ALIGN_BOTTOM|DTF_ALIGN_LEFT)
#define DTF_ALIGN_TOPRIGHT (DTF_ALIGN_TOP|DTF_ALIGN_RIGHT)
#define DTF_ALIGN_BOTTOMRIGHT (DTF_ALIGN_BOTTOM|DTF_ALIGN_RIGHT)
#define DTF_NO_EFFECTS (DTF_NO_TYPEIN|DTF_NO_SHADOW|DTF_NO_GLITTER)
#define DTF_ONLY_SHADOW (DTF_NO_TYPEIN|DTF_NO_GLITTER)
/*@}*/
#define FR_MAX_ATTRIB_STACK_DEPTH (4)
/// Change the current font.
void FR_SetFont(fontid_t font);
/// Push the attribute stack.
void FR_PushAttrib(void);
/// Pop the attribute stack.
void FR_PopAttrib(void);
/// Load the default attributes at the current stack depth.
void FR_LoadDefaultAttrib(void);
void FR_SetTracking(int tracking);
void FR_SetShadowOffset(int offsetX, int offsetY);
void FR_SetShadowStrength(float value);
void FR_SetGlitterStrength(float value);
/// @return Unique identifier associated with the current font.
fontid_t FR_GetCurrentId(void);
/// Current tracking.
int FR_Tracking(void);
/**
* Text: A block of possibly formatted and/or multi-line text.
*/
void FR_DrawText(const char* string, int x, int y, fontid_t defFont, short defFlags, float defLeading, int defTracking, float defRed, float defGreen, float defBlue, float defAlpha, float defGlitter, float defShadow, boolean defCase);
// Utility routines:
void FR_TextDimensions(int* width, int* height, const char* string, fontid_t defFont);
int FR_TextWidth(const char* string, fontid_t defFont);
int FR_TextHeight(const char* string, fontid_t defFont);
/**
* Text fragments: A single line of unformatted text.
*/
void FR_DrawTextFragment(const char* string, int x, int y);
void FR_DrawTextFragment2(const char* string, int x, int y, short flags);
// Utility routines:
void FR_TextFragmentDimensions(int* width, int* height, const char* string);
int FR_TextFragmentWidth(const char* string);
int FR_TextFragmentHeight(const char* string);
/**
* Single character.
*/
void FR_DrawChar(unsigned char ch, int x, int y);
void FR_DrawChar2(unsigned char ch, int x, int y, short flags);
// Utility routines:
void FR_CharDimensions(int* width, int* height, unsigned char ch);
int FR_CharWidth(unsigned char ch);
int FR_CharHeight(unsigned char ch);
#endif /* LIBDENG_API_BITMAPFONT_H */