git repos / blockattack-game

blame: source/code/Libs/SDL_FontCache.h

normal view · raw

078900fe sago007 2015-12-05 15:31 1
/*
078900fe sago007 2015-12-05 15:31 2
SDL_FontCache v0.0.1: A font cache for SDL and SDL_ttf
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:
a133dbce sago007 2016-03-26 10:05 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.
a133dbce sago007 2016-03-26 10:05 10
078900fe sago007 2015-12-05 15:31 11
    The long:
078900fe sago007 2015-12-05 15:31 12
Copyright (c) 2015 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 _SDL_FONTCACHE_H__
078900fe sago007 2015-12-05 15:31 34
#define _SDL_FONTCACHE_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
#include "SDL_ttf.h"
078900fe sago007 2015-12-05 15:31 38
078900fe sago007 2015-12-05 15:31 39
#ifdef FC_USE_SDL_GPU
078900fe sago007 2015-12-05 15:31 40
    #include "SDL_gpu.h"
078900fe sago007 2015-12-05 15:31 41
#endif
078900fe sago007 2015-12-05 15:31 42
078900fe sago007 2015-12-05 15:31 43
078900fe sago007 2015-12-05 15:31 44
#include <stdarg.h>
078900fe sago007 2015-12-05 15:31 45
078900fe sago007 2015-12-05 15:31 46
#ifdef __cplusplus
078900fe sago007 2015-12-05 15:31 47
extern "C" {
078900fe sago007 2015-12-05 15:31 48
#endif
078900fe sago007 2015-12-05 15:31 49
078900fe sago007 2015-12-05 15:31 50
078900fe sago007 2015-12-05 15:31 51
// Let's pretend this exists...
078900fe sago007 2015-12-05 15:31 52
#define TTF_STYLE_OUTLINE	16
078900fe sago007 2015-12-05 15:31 53
078900fe sago007 2015-12-05 15:31 54
078900fe sago007 2015-12-05 15:31 55
078900fe sago007 2015-12-05 15:31 56
// Differences between SDL_Renderer and SDL_gpu
078900fe sago007 2015-12-05 15:31 57
#ifdef FC_USE_SDL_GPU
078900fe sago007 2015-12-05 15:31 58
#define FC_Rect GPU_Rect
078900fe sago007 2015-12-05 15:31 59
#define FC_Target GPU_Target
078900fe sago007 2015-12-05 15:31 60
#define FC_Image GPU_Image
078900fe sago007 2015-12-05 15:31 61
#define FC_Log GPU_LogError
078900fe sago007 2015-12-05 15:31 62
#else
078900fe sago007 2015-12-05 15:31 63
#define FC_Rect SDL_Rect
078900fe sago007 2015-12-05 15:31 64
#define FC_Target SDL_Renderer
078900fe sago007 2015-12-05 15:31 65
#define FC_Image SDL_Texture
078900fe sago007 2015-12-05 15:31 66
#define FC_Log SDL_Log
078900fe sago007 2015-12-05 15:31 67
#endif
078900fe sago007 2015-12-05 15:31 68
078900fe sago007 2015-12-05 15:31 69
078900fe sago007 2015-12-05 15:31 70
// SDL_FontCache types
078900fe sago007 2015-12-05 15:31 71
078900fe sago007 2015-12-05 15:31 72
typedef enum
078900fe sago007 2015-12-05 15:31 73
{
078900fe sago007 2015-12-05 15:31 74
    FC_ALIGN_LEFT,
078900fe sago007 2015-12-05 15:31 75
    FC_ALIGN_CENTER,
078900fe sago007 2015-12-05 15:31 76
    FC_ALIGN_RIGHT
078900fe sago007 2015-12-05 15:31 77
} FC_AlignEnum;
078900fe sago007 2015-12-05 15:31 78
078900fe sago007 2015-12-05 15:31 79
typedef enum
078900fe sago007 2015-12-05 15:31 80
{
078900fe sago007 2015-12-05 15:31 81
    FC_FILTER_NEAREST,
078900fe sago007 2015-12-05 15:31 82
    FC_FILTER_LINEAR
078900fe sago007 2015-12-05 15:31 83
} FC_FilterEnum;
078900fe sago007 2015-12-05 15:31 84
078900fe sago007 2015-12-05 15:31 85
typedef struct FC_Scale
078900fe sago007 2015-12-05 15:31 86
{
078900fe sago007 2015-12-05 15:31 87
    float x;
078900fe sago007 2015-12-05 15:31 88
    float y;
a133dbce sago007 2016-03-26 10:05 89
078900fe sago007 2015-12-05 15:31 90
} FC_Scale;
078900fe sago007 2015-12-05 15:31 91
078900fe sago007 2015-12-05 15:31 92
typedef struct FC_Effect
078900fe sago007 2015-12-05 15:31 93
{
078900fe sago007 2015-12-05 15:31 94
    FC_AlignEnum alignment;
078900fe sago007 2015-12-05 15:31 95
    FC_Scale scale;
078900fe sago007 2015-12-05 15:31 96
    SDL_Color color;
a133dbce sago007 2016-03-26 10:05 97
078900fe sago007 2015-12-05 15:31 98
} FC_Effect;
078900fe sago007 2015-12-05 15:31 99
078900fe sago007 2015-12-05 15:31 100
// Opaque type
078900fe sago007 2015-12-05 15:31 101
typedef struct FC_Font FC_Font;
078900fe sago007 2015-12-05 15:31 102
078900fe sago007 2015-12-05 15:31 103
078900fe sago007 2015-12-05 15:31 104
typedef struct FC_GlyphData
078900fe sago007 2015-12-05 15:31 105
{
078900fe sago007 2015-12-05 15:31 106
    SDL_Rect rect;
078900fe sago007 2015-12-05 15:31 107
    int cache_level;
a133dbce sago007 2016-03-26 10:05 108
078900fe sago007 2015-12-05 15:31 109
} FC_GlyphData;
078900fe sago007 2015-12-05 15:31 110
078900fe sago007 2015-12-05 15:31 111
078900fe sago007 2015-12-05 15:31 112
078900fe sago007 2015-12-05 15:31 113
078900fe sago007 2015-12-05 15:31 114
// Object creation
078900fe sago007 2015-12-05 15:31 115
078900fe sago007 2015-12-05 15:31 116
FC_Rect FC_MakeRect(float x, float y, float w, float h);
078900fe sago007 2015-12-05 15:31 117
078900fe sago007 2015-12-05 15:31 118
FC_Scale FC_MakeScale(float x, float y);
078900fe sago007 2015-12-05 15:31 119
078900fe sago007 2015-12-05 15:31 120
SDL_Color FC_MakeColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
078900fe sago007 2015-12-05 15:31 121
078900fe sago007 2015-12-05 15:31 122
FC_Effect FC_MakeEffect(FC_AlignEnum alignment, FC_Scale scale, SDL_Color color);
078900fe sago007 2015-12-05 15:31 123
078900fe sago007 2015-12-05 15:31 124
FC_GlyphData FC_MakeGlyphData(int cache_level, Sint16 x, Sint16 y, Uint16 w, Uint16 h);
078900fe sago007 2015-12-05 15:31 125
078900fe sago007 2015-12-05 15:31 126
078900fe sago007 2015-12-05 15:31 127
078900fe sago007 2015-12-05 15:31 128
// Font object
078900fe sago007 2015-12-05 15:31 129
078900fe sago007 2015-12-05 15:31 130
FC_Font* FC_CreateFont(void);
078900fe sago007 2015-12-05 15:31 131
078900fe sago007 2015-12-05 15:31 132
#ifdef FC_USE_SDL_GPU
078900fe sago007 2015-12-05 15:31 133
Uint8 FC_LoadFont(FC_Font* font, const char* filename_ttf, Uint32 pointSize, SDL_Color color, int style);
078900fe sago007 2015-12-05 15:31 134
078900fe sago007 2015-12-05 15:31 135
Uint8 FC_LoadFontFromTTF(FC_Font* font, TTF_Font* ttf, SDL_Color color);
078900fe sago007 2015-12-05 15:31 136
078900fe sago007 2015-12-05 15:31 137
Uint8 FC_LoadFont_RW(FC_Font* font, SDL_RWops* file_rwops_ttf, Uint8 own_rwops, Uint32 pointSize, SDL_Color color, int style);
078900fe sago007 2015-12-05 15:31 138
#else
078900fe sago007 2015-12-05 15:31 139
Uint8 FC_LoadFont(FC_Font* font, SDL_Renderer* renderer, const char* filename_ttf, Uint32 pointSize, SDL_Color color, int style);
078900fe sago007 2015-12-05 15:31 140
078900fe sago007 2015-12-05 15:31 141
Uint8 FC_LoadFontFromTTF(FC_Font* font, SDL_Renderer* renderer, TTF_Font* ttf, SDL_Color color);
078900fe sago007 2015-12-05 15:31 142
078900fe sago007 2015-12-05 15:31 143
Uint8 FC_LoadFont_RW(FC_Font* font, SDL_Renderer* renderer, SDL_RWops* file_rwops_ttf, Uint8 own_rwops, Uint32 pointSize, SDL_Color color, int style);
078900fe sago007 2015-12-05 15:31 144
#endif
078900fe sago007 2015-12-05 15:31 145
078900fe sago007 2015-12-05 15:31 146
void FC_ClearFont(FC_Font* font);
078900fe sago007 2015-12-05 15:31 147
078900fe sago007 2015-12-05 15:31 148
void FC_FreeFont(FC_Font* font);
078900fe sago007 2015-12-05 15:31 149
078900fe sago007 2015-12-05 15:31 150
078900fe sago007 2015-12-05 15:31 151
078900fe sago007 2015-12-05 15:31 152
// Built-in loading strings
078900fe sago007 2015-12-05 15:31 153
078900fe sago007 2015-12-05 15:31 154
const char* FC_GetStringASCII(void);
078900fe sago007 2015-12-05 15:31 155
078900fe sago007 2015-12-05 15:31 156
const char* FC_GetStringLatin1(void);
078900fe sago007 2015-12-05 15:31 157
078900fe sago007 2015-12-05 15:31 158
const char* FC_GetStringASCII_Latin1(void);
078900fe sago007 2015-12-05 15:31 159
078900fe sago007 2015-12-05 15:31 160
078900fe sago007 2015-12-05 15:31 161
// UTF-8 to SDL_FontCache codepoint conversion
078900fe sago007 2015-12-05 15:31 162
078900fe sago007 2015-12-05 15:31 163
/*!
078900fe sago007 2015-12-05 15:31 164
Returns the Uint32 codepoint (not UTF-32) parsed from the given UTF-8 string.
078900fe sago007 2015-12-05 15:31 165
\param c A pointer to a string of proper UTF-8 character values.
078900fe sago007 2015-12-05 15:31 166
\param advance_pointer If true, the source pointer will be incremented to skip the extra bytes from multibyte codepoints.
078900fe sago007 2015-12-05 15:31 167
*/
078900fe sago007 2015-12-05 15:31 168
Uint32 FC_GetCodepointFromUTF8(const char** c, Uint8 advance_pointer);
078900fe sago007 2015-12-05 15:31 169
078900fe sago007 2015-12-05 15:31 170
/*!
078900fe sago007 2015-12-05 15:31 171
Parses the given codepoint and stores the UTF-8 bytes in 'result'.  The result is NULL terminated.
078900fe sago007 2015-12-05 15:31 172
\param result A memory buffer for the UTF-8 values.  Must be at least 5 bytes long.
078900fe sago007 2015-12-05 15:31 173
\param codepoint The Uint32 codepoint to parse (not UTF-32).
078900fe sago007 2015-12-05 15:31 174
*/
078900fe sago007 2015-12-05 15:31 175
void FC_GetUTF8FromCodepoint(char* result, Uint32 codepoint);
078900fe sago007 2015-12-05 15:31 176
078900fe sago007 2015-12-05 15:31 177
078900fe sago007 2015-12-05 15:31 178
// UTF-8 string operations
078900fe sago007 2015-12-05 15:31 179
078900fe sago007 2015-12-05 15:31 180
/*! Allocates a new string of 'size' bytes that is already NULL-terminated.  The NULL byte counts toward the size limit, as usual.  Returns NULL if size is 0. */
078900fe sago007 2015-12-05 15:31 181
char* U8_alloc(unsigned int size);
078900fe sago007 2015-12-05 15:31 182
078900fe sago007 2015-12-05 15:31 183
/*! Deallocates the given string. */
078900fe sago007 2015-12-05 15:31 184
void U8_free(char* string);
078900fe sago007 2015-12-05 15:31 185
078900fe sago007 2015-12-05 15:31 186
/*! Allocates a copy of the given string. */
078900fe sago007 2015-12-05 15:31 187
char* U8_strdup(const char* string);
078900fe sago007 2015-12-05 15:31 188
078900fe sago007 2015-12-05 15:31 189
/*! Returns the number of UTF-8 characters in the given string. */
078900fe sago007 2015-12-05 15:31 190
int U8_strlen(const char* string);
078900fe sago007 2015-12-05 15:31 191
078900fe sago007 2015-12-05 15:31 192
/*! Returns the number of bytes in the UTF-8 multibyte character pointed at by 'character'. */
078900fe sago007 2015-12-05 15:31 193
int U8_charsize(const char* character);
078900fe sago007 2015-12-05 15:31 194
078900fe sago007 2015-12-05 15:31 195
/*! Copies the source multibyte character into the given buffer without overrunning it.  Returns 0 on failure. */
078900fe sago007 2015-12-05 15:31 196
int U8_charcpy(char* buffer, const char* source, int buffer_size);
078900fe sago007 2015-12-05 15:31 197
078900fe sago007 2015-12-05 15:31 198
/*! Returns a pointer to the next UTF-8 character. */
078900fe sago007 2015-12-05 15:31 199
const char* U8_next(const char* string);
078900fe sago007 2015-12-05 15:31 200
078900fe sago007 2015-12-05 15:31 201
/*! Inserts a UTF-8 string into 'string' at the given position.  Use a position of -1 to append.  Returns 0 when unable to insert the string. */
078900fe sago007 2015-12-05 15:31 202
int U8_strinsert(char* string, int position, const char* source, int max_bytes);
078900fe sago007 2015-12-05 15:31 203
078900fe sago007 2015-12-05 15:31 204
/*! Erases the UTF-8 character at the given position, moving the subsequent characters down. */
078900fe sago007 2015-12-05 15:31 205
void U8_strdel(char* string, int position);
078900fe sago007 2015-12-05 15:31 206
078900fe sago007 2015-12-05 15:31 207
078900fe sago007 2015-12-05 15:31 208
// Internal settings
078900fe sago007 2015-12-05 15:31 209
078900fe sago007 2015-12-05 15:31 210
/*! Sets the string from which to load the initial glyphs.  Use this if you need upfront loading for any reason (such as lack of render-target support). */
078900fe sago007 2015-12-05 15:31 211
void FC_SetLoadingString(FC_Font* font, const char* string);
078900fe sago007 2015-12-05 15:31 212
a133dbce sago007 2016-03-26 10:05 213
/*! Returns the size of the internal buffer which is used for unpacking variadic text data.  This buffer is shared by all FC_Fonts. */
a133dbce sago007 2016-03-26 10:05 214
unsigned int FC_GetBufferSize(void);
a133dbce sago007 2016-03-26 10:05 215
078900fe sago007 2015-12-05 15:31 216
/*! Changes the size of the internal buffer which is used for unpacking variadic text data.  This buffer is shared by all FC_Fonts. */
078900fe sago007 2015-12-05 15:31 217
void FC_SetBufferSize(unsigned int size);
078900fe sago007 2015-12-05 15:31 218
078900fe sago007 2015-12-05 15:31 219
void FC_SetRenderCallback(FC_Rect (*callback)(FC_Image* src, FC_Rect* srcrect, FC_Target* dest, float x, float y, float xscale, float yscale));
078900fe sago007 2015-12-05 15:31 220
078900fe sago007 2015-12-05 15:31 221
FC_Rect FC_DefaultRenderCallback(FC_Image* src, FC_Rect* srcrect, FC_Target* dest, float x, float y, float xscale, float yscale);
078900fe sago007 2015-12-05 15:31 222
078900fe sago007 2015-12-05 15:31 223
078900fe sago007 2015-12-05 15:31 224
// Custom caching
078900fe sago007 2015-12-05 15:31 225
078900fe sago007 2015-12-05 15:31 226
/*! Returns the number of cache levels that are active. */
078900fe sago007 2015-12-05 15:31 227
int FC_GetNumCacheLevels(FC_Font* font);
078900fe sago007 2015-12-05 15:31 228
078900fe sago007 2015-12-05 15:31 229
/*! Returns the cache source texture at the given cache level. */
078900fe sago007 2015-12-05 15:31 230
FC_Image* FC_GetGlyphCacheLevel(FC_Font* font, int cache_level);
078900fe sago007 2015-12-05 15:31 231
078900fe sago007 2015-12-05 15:31 232
// TODO: Specify ownership of the texture (should be shareable)
078900fe sago007 2015-12-05 15:31 233
/*! Sets a cache source texture for rendering.  New cache levels must be sequential. */
078900fe sago007 2015-12-05 15:31 234
Uint8 FC_SetGlyphCacheLevel(FC_Font* font, int cache_level, FC_Image* cache_texture);
078900fe sago007 2015-12-05 15:31 235
078900fe sago007 2015-12-05 15:31 236
/*! Stores the glyph data for the given codepoint in 'result'.  Returns 0 if the codepoint was not found in the cache. */
078900fe sago007 2015-12-05 15:31 237
Uint8 FC_GetGlyphData(FC_Font* font, FC_GlyphData* result, Uint32 codepoint);
078900fe sago007 2015-12-05 15:31 238
078900fe sago007 2015-12-05 15:31 239
/*! Sets the glyph data for the given codepoint.  Duplicates are not checked.  Returns a pointer to the stored data. */
078900fe sago007 2015-12-05 15:31 240
FC_GlyphData* FC_SetGlyphData(FC_Font* font, Uint32 codepoint, FC_GlyphData glyph_data);
078900fe sago007 2015-12-05 15:31 241
078900fe sago007 2015-12-05 15:31 242
078900fe sago007 2015-12-05 15:31 243
// Rendering
078900fe sago007 2015-12-05 15:31 244
078900fe sago007 2015-12-05 15:31 245
FC_Rect FC_Draw(FC_Font* font, FC_Target* dest, float x, float y, const char* formatted_text, ...);
078900fe sago007 2015-12-05 15:31 246
FC_Rect FC_DrawAlign(FC_Font* font, FC_Target* dest, float x, float y, FC_AlignEnum align, const char* formatted_text, ...);
078900fe sago007 2015-12-05 15:31 247
FC_Rect FC_DrawScale(FC_Font* font, FC_Target* dest, float x, float y, FC_Scale scale, const char* formatted_text, ...);
078900fe sago007 2015-12-05 15:31 248
FC_Rect FC_DrawColor(FC_Font* font, FC_Target* dest, float x, float y, SDL_Color color, const char* formatted_text, ...);
078900fe sago007 2015-12-05 15:31 249
FC_Rect FC_DrawEffect(FC_Font* font, FC_Target* dest, float x, float y, FC_Effect effect, const char* formatted_text, ...);
078900fe sago007 2015-12-05 15:31 250
078900fe sago007 2015-12-05 15:31 251
FC_Rect FC_DrawBox(FC_Font* font, FC_Target* dest, FC_Rect box, const char* formatted_text, ...);
078900fe sago007 2015-12-05 15:31 252
FC_Rect FC_DrawBoxAlign(FC_Font* font, FC_Target* dest, FC_Rect box, FC_AlignEnum align, const char* formatted_text, ...);
078900fe sago007 2015-12-05 15:31 253
FC_Rect FC_DrawBoxScale(FC_Font* font, FC_Target* dest, FC_Rect box, FC_Scale scale, const char* formatted_text, ...);
078900fe sago007 2015-12-05 15:31 254
FC_Rect FC_DrawBoxColor(FC_Font* font, FC_Target* dest, FC_Rect box, SDL_Color color, const char* formatted_text, ...);
078900fe sago007 2015-12-05 15:31 255
FC_Rect FC_DrawBoxEffect(FC_Font* font, FC_Target* dest, FC_Rect box, FC_Effect effect, const char* formatted_text, ...);
078900fe sago007 2015-12-05 15:31 256
078900fe sago007 2015-12-05 15:31 257
FC_Rect FC_DrawColumn(FC_Font* font, FC_Target* dest, float x, float y, Uint16 width, const char* formatted_text, ...);
078900fe sago007 2015-12-05 15:31 258
FC_Rect FC_DrawColumnAlign(FC_Font* font, FC_Target* dest, float x, float y, Uint16 width, FC_AlignEnum align, const char* formatted_text, ...);
078900fe sago007 2015-12-05 15:31 259
FC_Rect FC_DrawColumnScale(FC_Font* font, FC_Target* dest, float x, float y, Uint16 width, FC_Scale scale, const char* formatted_text, ...);
078900fe sago007 2015-12-05 15:31 260
FC_Rect FC_DrawColumnColor(FC_Font* font, FC_Target* dest, float x, float y, Uint16 width, SDL_Color color, const char* formatted_text, ...);
078900fe sago007 2015-12-05 15:31 261
FC_Rect FC_DrawColumnEffect(FC_Font* font, FC_Target* dest, float x, float y, Uint16 width, FC_Effect effect, const char* formatted_text, ...);
078900fe sago007 2015-12-05 15:31 262
078900fe sago007 2015-12-05 15:31 263
078900fe sago007 2015-12-05 15:31 264
// Getters
078900fe sago007 2015-12-05 15:31 265
078900fe sago007 2015-12-05 15:31 266
FC_FilterEnum FC_GetFilterMode(FC_Font* font);
078900fe sago007 2015-12-05 15:31 267
Uint16 FC_GetLineHeight(FC_Font* font);
078900fe sago007 2015-12-05 15:31 268
Uint16 FC_GetHeight(FC_Font* font, const char* formatted_text, ...);
078900fe sago007 2015-12-05 15:31 269
Uint16 FC_GetWidth(FC_Font* font, const char* formatted_text, ...);
078900fe sago007 2015-12-05 15:31 270
078900fe sago007 2015-12-05 15:31 271
// Returns a 1-pixel wide box in front of the character in the given position (index)
078900fe sago007 2015-12-05 15:31 272
FC_Rect FC_GetCharacterOffset(FC_Font* font, Uint16 position_index, int column_width, const char* formatted_text, ...);
078900fe sago007 2015-12-05 15:31 273
Uint16 FC_GetColumnHeight(FC_Font* font, Uint16 width, const char* formatted_text, ...);
078900fe sago007 2015-12-05 15:31 274
078900fe sago007 2015-12-05 15:31 275
int FC_GetAscent(FC_Font* font, const char* formatted_text, ...);
078900fe sago007 2015-12-05 15:31 276
int FC_GetDescent(FC_Font* font, const char* formatted_text, ...);
078900fe sago007 2015-12-05 15:31 277
int FC_GetBaseline(FC_Font* font);
078900fe sago007 2015-12-05 15:31 278
int FC_GetSpacing(FC_Font* font);
078900fe sago007 2015-12-05 15:31 279
int FC_GetLineSpacing(FC_Font* font);
078900fe sago007 2015-12-05 15:31 280
Uint16 FC_GetMaxWidth(FC_Font* font);
078900fe sago007 2015-12-05 15:31 281
SDL_Color FC_GetDefaultColor(FC_Font* font);
078900fe sago007 2015-12-05 15:31 282
078900fe sago007 2015-12-05 15:31 283
Uint8 FC_InRect(float x, float y, FC_Rect input_rect);
078900fe sago007 2015-12-05 15:31 284
// Given an offset (x,y) from the text draw position (the upper-left corner), returns the character position (UTF-8 index)
078900fe sago007 2015-12-05 15:31 285
Uint16 FC_GetPositionFromOffset(FC_Font* font, float x, float y, int column_width, FC_AlignEnum align, const char* formatted_text, ...);
078900fe sago007 2015-12-05 15:31 286
078900fe sago007 2015-12-05 15:31 287
// Setters
078900fe sago007 2015-12-05 15:31 288
078900fe sago007 2015-12-05 15:31 289
void FC_SetFilterMode(FC_Font* font, FC_FilterEnum filter);
078900fe sago007 2015-12-05 15:31 290
void FC_SetSpacing(FC_Font* font, int LetterSpacing);
078900fe sago007 2015-12-05 15:31 291
void FC_SetLineSpacing(FC_Font* font, int LineSpacing);
078900fe sago007 2015-12-05 15:31 292
void FC_SetDefaultColor(FC_Font* font, SDL_Color color);
078900fe sago007 2015-12-05 15:31 293
078900fe sago007 2015-12-05 15:31 294
078900fe sago007 2015-12-05 15:31 295
#ifdef __cplusplus
078900fe sago007 2015-12-05 15:31 296
}
078900fe sago007 2015-12-05 15:31 297
#endif
078900fe sago007 2015-12-05 15:31 298
078900fe sago007 2015-12-05 15:31 299
078900fe sago007 2015-12-05 15:31 300
078900fe sago007 2015-12-05 15:31 301
#endif
1970-01-01 00:00 302