git repos / blockattack-game

blame: source/code/Libs/NFont.h

normal view · raw

078900fe sago007 2015-12-05 15:31 1
/*
34c3d60c sago007 2016-12-23 16:31 2
NFont v5.0.0: A font class for SDL and SDL_Renderer
078900fe sago007 2015-12-05 15:31 3
by Jonathan Dearborn
078900fe sago007 2015-12-05 15:31 4
Dedicated to the memory of Florian Hufsky
078900fe sago007 2015-12-05 15:31 5
078900fe sago007 2015-12-05 15:31 6
License:
078900fe sago007 2015-12-05 15:31 7
    The short:
078900fe sago007 2015-12-05 15:31 8
    Use it however you'd like, but keep the copyright and license notice 
078900fe sago007 2015-12-05 15:31 9
    whenever these files or parts of them are distributed in uncompiled form.
078900fe sago007 2015-12-05 15:31 10
    
078900fe sago007 2015-12-05 15:31 11
    The long:
34c3d60c sago007 2016-12-23 16:31 12
Copyright (c) 2016 Jonathan Dearborn
078900fe sago007 2015-12-05 15:31 13
078900fe sago007 2015-12-05 15:31 14
Permission is hereby granted, free of charge, to any person obtaining a copy
078900fe sago007 2015-12-05 15:31 15
of this software and associated documentation files (the "Software"), to deal
078900fe sago007 2015-12-05 15:31 16
in the Software without restriction, including without limitation the rights
078900fe sago007 2015-12-05 15:31 17
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
078900fe sago007 2015-12-05 15:31 18
copies of the Software, and to permit persons to whom the Software is
078900fe sago007 2015-12-05 15:31 19
furnished to do so, subject to the following conditions:
078900fe sago007 2015-12-05 15:31 20
078900fe sago007 2015-12-05 15:31 21
The above copyright notice and this permission notice shall be included in
078900fe sago007 2015-12-05 15:31 22
all copies or substantial portions of the Software.
078900fe sago007 2015-12-05 15:31 23
078900fe sago007 2015-12-05 15:31 24
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
078900fe sago007 2015-12-05 15:31 25
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
078900fe sago007 2015-12-05 15:31 26
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
078900fe sago007 2015-12-05 15:31 27
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
078900fe sago007 2015-12-05 15:31 28
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
078900fe sago007 2015-12-05 15:31 29
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
078900fe sago007 2015-12-05 15:31 30
THE SOFTWARE.
078900fe sago007 2015-12-05 15:31 31
*/
078900fe sago007 2015-12-05 15:31 32
078900fe sago007 2015-12-05 15:31 33
#ifndef _NFONT_H__
078900fe sago007 2015-12-05 15:31 34
#define _NFONT_H__
078900fe sago007 2015-12-05 15:31 35
078900fe sago007 2015-12-05 15:31 36
#include "SDL.h"
078900fe sago007 2015-12-05 15:31 37
078900fe sago007 2015-12-05 15:31 38
#if defined(FC_USE_SDL_GPU) && !defined(NFONT_USE_SDL_GPU)
078900fe sago007 2015-12-05 15:31 39
#define NFONT_USE_SDL_GPU
078900fe sago007 2015-12-05 15:31 40
#endif
078900fe sago007 2015-12-05 15:31 41
078900fe sago007 2015-12-05 15:31 42
#ifdef NFONT_USE_SDL_GPU
078900fe sago007 2015-12-05 15:31 43
    #include "SDL_gpu.h"
078900fe sago007 2015-12-05 15:31 44
#endif
078900fe sago007 2015-12-05 15:31 45
5e876385 sago007 2016-01-29 22:43 46
#ifndef NFONT_FORMAT
5e876385 sago007 2016-01-29 22:43 47
5e876385 sago007 2016-01-29 22:43 48
#if ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) )
5e876385 sago007 2016-01-29 22:43 49
#define NFONT_FORMAT(X) __attribute__ ((format (printf, X, X+1)))
5e876385 sago007 2016-01-29 22:43 50
#else
5e876385 sago007 2016-01-29 22:43 51
#define NFONT_FORMAT(X)
5e876385 sago007 2016-01-29 22:43 52
#endif
5e876385 sago007 2016-01-29 22:43 53
5e876385 sago007 2016-01-29 22:43 54
#endif 
5e876385 sago007 2016-01-29 22:43 55
078900fe sago007 2015-12-05 15:31 56
#include "stdarg.h"
078900fe sago007 2015-12-05 15:31 57
078900fe sago007 2015-12-05 15:31 58
// Let's pretend this exists...
078900fe sago007 2015-12-05 15:31 59
#ifndef TTF_STYLE_OUTLINE
078900fe sago007 2015-12-05 15:31 60
    #define TTF_STYLE_OUTLINE	16
078900fe sago007 2015-12-05 15:31 61
#endif
078900fe sago007 2015-12-05 15:31 62
078900fe sago007 2015-12-05 15:31 63
struct FC_Font;
078900fe sago007 2015-12-05 15:31 64
078900fe sago007 2015-12-05 15:31 65
typedef struct _TTF_Font TTF_Font;
078900fe sago007 2015-12-05 15:31 66
34c3d60c sago007 2016-12-23 16:31 67
// Differences between SDL_Renderer and SDL_gpu
34c3d60c sago007 2016-12-23 16:31 68
#ifdef NFONT_USE_SDL_GPU
34c3d60c sago007 2016-12-23 16:31 69
#define NFont_Image GPU_Image
34c3d60c sago007 2016-12-23 16:31 70
#else
34c3d60c sago007 2016-12-23 16:31 71
#define NFont_Image SDL_Texture
34c3d60c sago007 2016-12-23 16:31 72
#endif
34c3d60c sago007 2016-12-23 16:31 73
078900fe sago007 2015-12-05 15:31 74
#if defined(NFONT_DLL) || defined(NFONT_DLL_EXPORT)
078900fe sago007 2015-12-05 15:31 75
	#ifdef NFONT_DLL_EXPORT
078900fe sago007 2015-12-05 15:31 76
	#define NFONT_EXPORT __declspec(dllexport)
078900fe sago007 2015-12-05 15:31 77
	#else
078900fe sago007 2015-12-05 15:31 78
	#define NFONT_EXPORT __declspec(dllimport)
078900fe sago007 2015-12-05 15:31 79
	#endif
078900fe sago007 2015-12-05 15:31 80
#else
078900fe sago007 2015-12-05 15:31 81
	#define NFONT_EXPORT
078900fe sago007 2015-12-05 15:31 82
#endif
078900fe sago007 2015-12-05 15:31 83
078900fe sago007 2015-12-05 15:31 84
class NFONT_EXPORT NFont
078900fe sago007 2015-12-05 15:31 85
{
078900fe sago007 2015-12-05 15:31 86
  public:
078900fe sago007 2015-12-05 15:31 87
078900fe sago007 2015-12-05 15:31 88
	class NFONT_EXPORT Color
078900fe sago007 2015-12-05 15:31 89
    {
078900fe sago007 2015-12-05 15:31 90
        public:
078900fe sago007 2015-12-05 15:31 91
        
078900fe sago007 2015-12-05 15:31 92
        Uint8 r, g, b, a;
078900fe sago007 2015-12-05 15:31 93
        
078900fe sago007 2015-12-05 15:31 94
        Color();
078900fe sago007 2015-12-05 15:31 95
        Color(Uint8 r, Uint8 g, Uint8 b);
078900fe sago007 2015-12-05 15:31 96
        Color(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
078900fe sago007 2015-12-05 15:31 97
        Color(const SDL_Color& color);
078900fe sago007 2015-12-05 15:31 98
        
078900fe sago007 2015-12-05 15:31 99
        Color& rgb(Uint8 R, Uint8 G, Uint8 B);
078900fe sago007 2015-12-05 15:31 100
        Color& rgba(Uint8 R, Uint8 G, Uint8 B, Uint8 A);
078900fe sago007 2015-12-05 15:31 101
        Color& color(const SDL_Color& color);
078900fe sago007 2015-12-05 15:31 102
        
078900fe sago007 2015-12-05 15:31 103
        SDL_Color to_SDL_Color() const;
078900fe sago007 2015-12-05 15:31 104
    };
078900fe sago007 2015-12-05 15:31 105
    
078900fe sago007 2015-12-05 15:31 106
	class NFONT_EXPORT Rectf
078900fe sago007 2015-12-05 15:31 107
    {
078900fe sago007 2015-12-05 15:31 108
        public:
078900fe sago007 2015-12-05 15:31 109
        float x, y;
078900fe sago007 2015-12-05 15:31 110
        float w, h;
078900fe sago007 2015-12-05 15:31 111
        
078900fe sago007 2015-12-05 15:31 112
        Rectf();
078900fe sago007 2015-12-05 15:31 113
        Rectf(float x, float y);
078900fe sago007 2015-12-05 15:31 114
        Rectf(float x, float y, float w, float h);
078900fe sago007 2015-12-05 15:31 115
        Rectf(const SDL_Rect& rect);
078900fe sago007 2015-12-05 15:31 116
        
078900fe sago007 2015-12-05 15:31 117
        SDL_Rect to_SDL_Rect() const;
078900fe sago007 2015-12-05 15:31 118
        
078900fe sago007 2015-12-05 15:31 119
        #ifdef NFONT_USE_SDL_GPU
078900fe sago007 2015-12-05 15:31 120
        Rectf(const GPU_Rect& rect);
078900fe sago007 2015-12-05 15:31 121
        GPU_Rect to_GPU_Rect() const;
078900fe sago007 2015-12-05 15:31 122
        #endif
078900fe sago007 2015-12-05 15:31 123
    };
078900fe sago007 2015-12-05 15:31 124
078900fe sago007 2015-12-05 15:31 125
    
078900fe sago007 2015-12-05 15:31 126
    enum AlignEnum {LEFT, CENTER, RIGHT};
078900fe sago007 2015-12-05 15:31 127
    enum FilterEnum {NEAREST, LINEAR};
078900fe sago007 2015-12-05 15:31 128
    
078900fe sago007 2015-12-05 15:31 129
	class NFONT_EXPORT Scale
078900fe sago007 2015-12-05 15:31 130
    {
078900fe sago007 2015-12-05 15:31 131
        public:
078900fe sago007 2015-12-05 15:31 132
        
078900fe sago007 2015-12-05 15:31 133
        float x;
078900fe sago007 2015-12-05 15:31 134
        float y;
078900fe sago007 2015-12-05 15:31 135
        
078900fe sago007 2015-12-05 15:31 136
        enum ScaleTypeEnum {NEAREST};
078900fe sago007 2015-12-05 15:31 137
        ScaleTypeEnum type;
078900fe sago007 2015-12-05 15:31 138
        
078900fe sago007 2015-12-05 15:31 139
        Scale()
078900fe sago007 2015-12-05 15:31 140
            : x(1.0f), y(1.0f), type(NEAREST)
078900fe sago007 2015-12-05 15:31 141
        {}
078900fe sago007 2015-12-05 15:31 142
        Scale(float xy)
078900fe sago007 2015-12-05 15:31 143
            : x(xy), y(xy), type(NEAREST)
078900fe sago007 2015-12-05 15:31 144
        {}
078900fe sago007 2015-12-05 15:31 145
        Scale(float xy, ScaleTypeEnum type)
078900fe sago007 2015-12-05 15:31 146
            : x(xy), y(xy), type(type)
078900fe sago007 2015-12-05 15:31 147
        {}
078900fe sago007 2015-12-05 15:31 148
        Scale(float x, float y)
078900fe sago007 2015-12-05 15:31 149
            : x(x), y(y), type(NEAREST)
078900fe sago007 2015-12-05 15:31 150
        {}
078900fe sago007 2015-12-05 15:31 151
        Scale(float x, float y, ScaleTypeEnum type)
078900fe sago007 2015-12-05 15:31 152
            : x(x), y(y), type(type)
078900fe sago007 2015-12-05 15:31 153
        {}
078900fe sago007 2015-12-05 15:31 154
    };
078900fe sago007 2015-12-05 15:31 155
    
078900fe sago007 2015-12-05 15:31 156
	class NFONT_EXPORT Effect
078900fe sago007 2015-12-05 15:31 157
    {
078900fe sago007 2015-12-05 15:31 158
        public:
078900fe sago007 2015-12-05 15:31 159
        AlignEnum alignment;
078900fe sago007 2015-12-05 15:31 160
        Scale scale;
078900fe sago007 2015-12-05 15:31 161
        bool use_color;
078900fe sago007 2015-12-05 15:31 162
        Color color;
078900fe sago007 2015-12-05 15:31 163
        
078900fe sago007 2015-12-05 15:31 164
        Effect()
078900fe sago007 2015-12-05 15:31 165
            : alignment(LEFT), use_color(false), color(255, 255, 255, 255)
078900fe sago007 2015-12-05 15:31 166
        {}
078900fe sago007 2015-12-05 15:31 167
        
078900fe sago007 2015-12-05 15:31 168
        Effect(const Scale& scale)
078900fe sago007 2015-12-05 15:31 169
            : alignment(LEFT), scale(scale), use_color(false), color(255, 255, 255, 255)
078900fe sago007 2015-12-05 15:31 170
        {}
078900fe sago007 2015-12-05 15:31 171
        Effect(AlignEnum alignment)
078900fe sago007 2015-12-05 15:31 172
            : alignment(alignment), use_color(false), color(255, 255, 255, 255)
078900fe sago007 2015-12-05 15:31 173
        {}
078900fe sago007 2015-12-05 15:31 174
        Effect(const Color& color)
078900fe sago007 2015-12-05 15:31 175
            : alignment(LEFT), use_color(true), color(color)
078900fe sago007 2015-12-05 15:31 176
        {}
078900fe sago007 2015-12-05 15:31 177
        
078900fe sago007 2015-12-05 15:31 178
        Effect(AlignEnum alignment, const Scale& scale)
078900fe sago007 2015-12-05 15:31 179
            : alignment(alignment), scale(scale), use_color(false), color(255, 255, 255, 255)
078900fe sago007 2015-12-05 15:31 180
        {}
078900fe sago007 2015-12-05 15:31 181
        Effect(AlignEnum alignment, const Color& color)
078900fe sago007 2015-12-05 15:31 182
            : alignment(alignment), use_color(true), color(color)
078900fe sago007 2015-12-05 15:31 183
        {}
078900fe sago007 2015-12-05 15:31 184
        Effect(const Scale& scale, const Color& color)
078900fe sago007 2015-12-05 15:31 185
            : alignment(LEFT), scale(scale), use_color(true), color(color)
078900fe sago007 2015-12-05 15:31 186
        {}
078900fe sago007 2015-12-05 15:31 187
        Effect(AlignEnum alignment, const Scale& scale, const Color& color)
078900fe sago007 2015-12-05 15:31 188
            : alignment(alignment), scale(scale), use_color(true), color(color)
078900fe sago007 2015-12-05 15:31 189
        {}
078900fe sago007 2015-12-05 15:31 190
    };
078900fe sago007 2015-12-05 15:31 191
    
078900fe sago007 2015-12-05 15:31 192
    
078900fe sago007 2015-12-05 15:31 193
    // Constructors
078900fe sago007 2015-12-05 15:31 194
    NFont();
078900fe sago007 2015-12-05 15:31 195
    NFont(const NFont& font);
078900fe sago007 2015-12-05 15:31 196
    #ifdef NFONT_USE_SDL_GPU
078900fe sago007 2015-12-05 15:31 197
    NFont(SDL_Surface* src);
078900fe sago007 2015-12-05 15:31 198
    NFont(TTF_Font* ttf);
078900fe sago007 2015-12-05 15:31 199
    NFont(TTF_Font* ttf, const NFont::Color& color);
078900fe sago007 2015-12-05 15:31 200
    NFont(const char* filename_ttf, Uint32 pointSize);
078900fe sago007 2015-12-05 15:31 201
    NFont(const char* filename_ttf, Uint32 pointSize, const NFont::Color& color, int style = 0);
078900fe sago007 2015-12-05 15:31 202
    NFont(SDL_RWops* file_rwops_ttf, Uint8 own_rwops, Uint32 pointSize, const NFont::Color& color, int style = 0);
078900fe sago007 2015-12-05 15:31 203
    #else
078900fe sago007 2015-12-05 15:31 204
    NFont(SDL_Renderer* renderer, SDL_Surface* src);
078900fe sago007 2015-12-05 15:31 205
    NFont(SDL_Renderer* renderer, TTF_Font* ttf);
078900fe sago007 2015-12-05 15:31 206
    NFont(SDL_Renderer* renderer, TTF_Font* ttf, const NFont::Color& color);
078900fe sago007 2015-12-05 15:31 207
    NFont(SDL_Renderer* renderer, const char* filename_ttf, Uint32 pointSize);
078900fe sago007 2015-12-05 15:31 208
    NFont(SDL_Renderer* renderer, const char* filename_ttf, Uint32 pointSize, const NFont::Color& color, int style = 0);
078900fe sago007 2015-12-05 15:31 209
    NFont(SDL_Renderer* renderer, SDL_RWops* file_rwops_ttf, Uint8 own_rwops, Uint32 pointSize, const NFont::Color& color, int style = 0);
078900fe sago007 2015-12-05 15:31 210
    #endif
078900fe sago007 2015-12-05 15:31 211
    
078900fe sago007 2015-12-05 15:31 212
    ~NFont();
078900fe sago007 2015-12-05 15:31 213
    
078900fe sago007 2015-12-05 15:31 214
    NFont& operator=(const NFont& font);
078900fe sago007 2015-12-05 15:31 215
078900fe sago007 2015-12-05 15:31 216
    // Loading
078900fe sago007 2015-12-05 15:31 217
    void setLoadingString(const char* str);
078900fe sago007 2015-12-05 15:31 218
    
078900fe sago007 2015-12-05 15:31 219
    #ifdef NFONT_USE_SDL_GPU
078900fe sago007 2015-12-05 15:31 220
    bool load(SDL_Surface* FontSurface);
078900fe sago007 2015-12-05 15:31 221
    bool load(TTF_Font* ttf);
078900fe sago007 2015-12-05 15:31 222
    bool load(TTF_Font* ttf, const NFont::Color& color);
078900fe sago007 2015-12-05 15:31 223
    bool load(const char* filename_ttf, Uint32 pointSize);
078900fe sago007 2015-12-05 15:31 224
    bool load(const char* filename_ttf, Uint32 pointSize, const NFont::Color& color, int style = 0);
078900fe sago007 2015-12-05 15:31 225
    bool load(SDL_RWops* file_rwops_ttf, Uint8 own_rwops, Uint32 pointSize, const NFont::Color& color, int style = 0);
078900fe sago007 2015-12-05 15:31 226
    #else
078900fe sago007 2015-12-05 15:31 227
    bool load(SDL_Renderer* renderer, SDL_Surface* FontSurface);
078900fe sago007 2015-12-05 15:31 228
    bool load(SDL_Renderer* renderer, TTF_Font* ttf);
078900fe sago007 2015-12-05 15:31 229
    bool load(SDL_Renderer* renderer, TTF_Font* ttf, const NFont::Color& color);
078900fe sago007 2015-12-05 15:31 230
    bool load(SDL_Renderer* renderer, const char* filename_ttf, Uint32 pointSize);
078900fe sago007 2015-12-05 15:31 231
    bool load(SDL_Renderer* renderer, const char* filename_ttf, Uint32 pointSize, const NFont::Color& color, int style = 0);
078900fe sago007 2015-12-05 15:31 232
    bool load(SDL_Renderer* renderer, SDL_RWops* file_rwops_ttf, Uint8 own_rwops, Uint32 pointSize, const NFont::Color& color, int style = 0);
078900fe sago007 2015-12-05 15:31 233
    #endif
078900fe sago007 2015-12-05 15:31 234
    
078900fe sago007 2015-12-05 15:31 235
    void free();
078900fe sago007 2015-12-05 15:31 236
078900fe sago007 2015-12-05 15:31 237
    // Drawing
078900fe sago007 2015-12-05 15:31 238
    #ifdef NFONT_USE_SDL_GPU
5e876385 sago007 2016-01-29 22:43 239
    Rectf draw(GPU_Target* dest, float x, float y, const char* formatted_text, ...) NFONT_FORMAT(5);
5e876385 sago007 2016-01-29 22:43 240
    Rectf draw(GPU_Target* dest, float x, float y, AlignEnum align, const char* formatted_text, ...) NFONT_FORMAT(6);
5e876385 sago007 2016-01-29 22:43 241
    Rectf draw(GPU_Target* dest, float x, float y, const Scale& scale, const char* formatted_text, ...) NFONT_FORMAT(6);
5e876385 sago007 2016-01-29 22:43 242
    Rectf draw(GPU_Target* dest, float x, float y, const Color& color, const char* formatted_text, ...) NFONT_FORMAT(6);
5e876385 sago007 2016-01-29 22:43 243
    Rectf draw(GPU_Target* dest, float x, float y, const Effect& effect, const char* formatted_text, ...) NFONT_FORMAT(6);
078900fe sago007 2015-12-05 15:31 244
    
5e876385 sago007 2016-01-29 22:43 245
    Rectf drawBox(GPU_Target* dest, const Rectf& box, const char* formatted_text, ...) NFONT_FORMAT(4);
5e876385 sago007 2016-01-29 22:43 246
    Rectf drawBox(GPU_Target* dest, const Rectf& box, AlignEnum align, const char* formatted_text, ...) NFONT_FORMAT(5);
5e876385 sago007 2016-01-29 22:43 247
    Rectf drawBox(GPU_Target* dest, const Rectf& box, const Scale& scale, const char* formatted_text, ...) NFONT_FORMAT(5);
5e876385 sago007 2016-01-29 22:43 248
    Rectf drawBox(GPU_Target* dest, const Rectf& box, const Color& color, const char* formatted_text, ...) NFONT_FORMAT(5);
5e876385 sago007 2016-01-29 22:43 249
    Rectf drawBox(GPU_Target* dest, const Rectf& box, const Effect& effect, const char* formatted_text, ...) NFONT_FORMAT(5);
078900fe sago007 2015-12-05 15:31 250
    
5e876385 sago007 2016-01-29 22:43 251
    Rectf drawColumn(GPU_Target* dest, float x, float y, Uint16 width, const char* formatted_text, ...) NFONT_FORMAT(6);
5e876385 sago007 2016-01-29 22:43 252
    Rectf drawColumn(GPU_Target* dest, float x, float y, Uint16 width, AlignEnum align, const char* formatted_text, ...) NFONT_FORMAT(7);
5e876385 sago007 2016-01-29 22:43 253
    Rectf drawColumn(GPU_Target* dest, float x, float y, Uint16 width, const Scale& scale, const char* formatted_text, ...) NFONT_FORMAT(7);
5e876385 sago007 2016-01-29 22:43 254
    Rectf drawColumn(GPU_Target* dest, float x, float y, Uint16 width, const Color& color, const char* formatted_text, ...) NFONT_FORMAT(7);
5e876385 sago007 2016-01-29 22:43 255
    Rectf drawColumn(GPU_Target* dest, float x, float y, Uint16 width, const Effect& effect, const char* formatted_text, ...) NFONT_FORMAT(7);
078900fe sago007 2015-12-05 15:31 256
    #else
5e876385 sago007 2016-01-29 22:43 257
    Rectf draw(SDL_Renderer* dest, float x, float y, const char* formatted_text, ...) NFONT_FORMAT(5);
5e876385 sago007 2016-01-29 22:43 258
    Rectf draw(SDL_Renderer* dest, float x, float y, AlignEnum align, const char* formatted_text, ...) NFONT_FORMAT(6);
5e876385 sago007 2016-01-29 22:43 259
    Rectf draw(SDL_Renderer* dest, float x, float y, const Scale& scale, const char* formatted_text, ...) NFONT_FORMAT(6);
5e876385 sago007 2016-01-29 22:43 260
    Rectf draw(SDL_Renderer* dest, float x, float y, const Color& color, const char* formatted_text, ...) NFONT_FORMAT(6);
5e876385 sago007 2016-01-29 22:43 261
    Rectf draw(SDL_Renderer* dest, float x, float y, const Effect& effect, const char* formatted_text, ...) NFONT_FORMAT(6);
078900fe sago007 2015-12-05 15:31 262
    
5e876385 sago007 2016-01-29 22:43 263
    Rectf drawBox(SDL_Renderer* dest, const Rectf& box, const char* formatted_text, ...) NFONT_FORMAT(4);
5e876385 sago007 2016-01-29 22:43 264
    Rectf drawBox(SDL_Renderer* dest, const Rectf& box, AlignEnum align, const char* formatted_text, ...) NFONT_FORMAT(5);
5e876385 sago007 2016-01-29 22:43 265
    Rectf drawBox(SDL_Renderer* dest, const Rectf& box, const Scale& scale, const char* formatted_text, ...) NFONT_FORMAT(5);
5e876385 sago007 2016-01-29 22:43 266
    Rectf drawBox(SDL_Renderer* dest, const Rectf& box, const Color& color, const char* formatted_text, ...) NFONT_FORMAT(5);
5e876385 sago007 2016-01-29 22:43 267
    Rectf drawBox(SDL_Renderer* dest, const Rectf& box, const Effect& effect, const char* formatted_text, ...) NFONT_FORMAT(5);
078900fe sago007 2015-12-05 15:31 268
    
5e876385 sago007 2016-01-29 22:43 269
    Rectf drawColumn(SDL_Renderer* dest, float x, float y, Uint16 width, const char* formatted_text, ...) NFONT_FORMAT(6);
5e876385 sago007 2016-01-29 22:43 270
    Rectf drawColumn(SDL_Renderer* dest, float x, float y, Uint16 width, AlignEnum align, const char* formatted_text, ...) NFONT_FORMAT(7);
5e876385 sago007 2016-01-29 22:43 271
    Rectf drawColumn(SDL_Renderer* dest, float x, float y, Uint16 width, const Scale& scale, const char* formatted_text, ...) NFONT_FORMAT(7);
5e876385 sago007 2016-01-29 22:43 272
    Rectf drawColumn(SDL_Renderer* dest, float x, float y, Uint16 width, const Color& color, const char* formatted_text, ...) NFONT_FORMAT(7);
5e876385 sago007 2016-01-29 22:43 273
    Rectf drawColumn(SDL_Renderer* dest, float x, float y, Uint16 width, const Effect& effect, const char* formatted_text, ...) NFONT_FORMAT(7);
078900fe sago007 2015-12-05 15:31 274
    #endif
078900fe sago007 2015-12-05 15:31 275
    
078900fe sago007 2015-12-05 15:31 276
    // Getters
078900fe sago007 2015-12-05 15:31 277
    FilterEnum getFilterMode() const;
078900fe sago007 2015-12-05 15:31 278
    Uint16 getHeight() const;
5e876385 sago007 2016-01-29 22:43 279
    Uint16 getHeight(const char* formatted_text, ...) const NFONT_FORMAT(2);
5e876385 sago007 2016-01-29 22:43 280
    Uint16 getWidth(const char* formatted_text, ...) NFONT_FORMAT(2);
5e876385 sago007 2016-01-29 22:43 281
    Rectf getCharacterOffset(Uint16 position_index, int column_width, const char* formatted_text, ...) NFONT_FORMAT(4);
a133dbce sago007 2016-03-26 10:05 282
    Uint16 getPositionFromOffset(float x, float y, int column_width, NFont::AlignEnum align, const char* formatted_text, ...) NFONT_FORMAT(6);
5e876385 sago007 2016-01-29 22:43 283
    Uint16 getColumnHeight(Uint16 width, const char* formatted_text, ...) NFONT_FORMAT(3);
078900fe sago007 2015-12-05 15:31 284
    int getSpacing() const;
078900fe sago007 2015-12-05 15:31 285
    int getLineSpacing() const;
078900fe sago007 2015-12-05 15:31 286
    Uint16 getBaseline() const;
078900fe sago007 2015-12-05 15:31 287
    int getAscent() const;
078900fe sago007 2015-12-05 15:31 288
    int getAscent(const char character);
5e876385 sago007 2016-01-29 22:43 289
    int getAscent(const char* formatted_text, ...) NFONT_FORMAT(2);
078900fe sago007 2015-12-05 15:31 290
    int getDescent() const;
078900fe sago007 2015-12-05 15:31 291
    int getDescent(const char character);
5e876385 sago007 2016-01-29 22:43 292
    int getDescent(const char* formatted_text, ...) NFONT_FORMAT(2);
078900fe sago007 2015-12-05 15:31 293
    Uint16 getMaxWidth() const;
078900fe sago007 2015-12-05 15:31 294
    Color getDefaultColor() const;
078900fe sago007 2015-12-05 15:31 295
    
34c3d60c sago007 2016-12-23 16:31 296
    int getNumCacheLevels() const;
34c3d60c sago007 2016-12-23 16:31 297
    NFont_Image* getCacheLevel(int level) const;
34c3d60c sago007 2016-12-23 16:31 298
    
078900fe sago007 2015-12-05 15:31 299
    // Setters
078900fe sago007 2015-12-05 15:31 300
    void setFilterMode(FilterEnum filter);
078900fe sago007 2015-12-05 15:31 301
    void setSpacing(int LetterSpacing);
078900fe sago007 2015-12-05 15:31 302
    void setLineSpacing(int LineSpacing);
078900fe sago007 2015-12-05 15:31 303
    void setBaseline();
078900fe sago007 2015-12-05 15:31 304
    void setBaseline(Uint16 Baseline);
078900fe sago007 2015-12-05 15:31 305
    void setDefaultColor(const Color& color);
078900fe sago007 2015-12-05 15:31 306
    
078900fe sago007 2015-12-05 15:31 307
    void enableTTFOwnership();
078900fe sago007 2015-12-05 15:31 308
    
078900fe sago007 2015-12-05 15:31 309
  private:
078900fe sago007 2015-12-05 15:31 310
    
078900fe sago007 2015-12-05 15:31 311
    static char* buffer;
078900fe sago007 2015-12-05 15:31 312
    FC_Font* font;
078900fe sago007 2015-12-05 15:31 313
    
078900fe sago007 2015-12-05 15:31 314
    void init();  // Common constructor
078900fe sago007 2015-12-05 15:31 315
078900fe sago007 2015-12-05 15:31 316
};
078900fe sago007 2015-12-05 15:31 317
078900fe sago007 2015-12-05 15:31 318
078900fe sago007 2015-12-05 15:31 319
078900fe sago007 2015-12-05 15:31 320
#endif // _NFONT_H__
1970-01-01 00:00 321