| 1 |
/** |
| 2 |
* Fonts |
| 3 |
|
| 4 |
* Copyright (C) 2007, 2008 Sylvain Beucler |
| 5 |
|
| 6 |
* This file is part of GNU FreeDink |
| 7 |
|
| 8 |
* GNU FreeDink is free software; you can redistribute it and/or |
| 9 |
* modify it under the terms of the GNU General Public License as |
| 10 |
* published by the Free Software Foundation; either version 3 of the |
| 11 |
* License, or (at your option) any later version. |
| 12 |
|
| 13 |
* GNU FreeDink is distributed in the hope that it will be useful, but |
| 14 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 |
* General Public License for more details. |
| 17 |
|
| 18 |
* You should have received a copy of the GNU General Public License |
| 19 |
* along with this program. If not, see |
| 20 |
* <http://www.gnu.org/licenses/>. |
| 21 |
*/ |
| 22 |
|
| 23 |
#ifndef _GFX_FONTS_H |
| 24 |
#define _GFX_FONTS_H |
| 25 |
|
| 26 |
#include "SDL_ttf.h" |
| 27 |
#include "IOGfxSurface.h" |
| 28 |
#include "rect.h" |
| 29 |
#include <vector> |
| 30 |
|
| 31 |
struct TextCommand { |
| 32 |
SDL_Surface* img; |
| 33 |
SDL_Rect src; |
| 34 |
SDL_Rect dst; |
| 35 |
}; |
| 36 |
|
| 37 |
typedef enum enum_font |
| 38 |
{ |
| 39 |
FONT_DIALOG = 0, |
| 40 |
FONT_SYSTEM, |
| 41 |
} FONT_TYPE; |
| 42 |
|
| 43 |
/* Default size was 18 in the original game, but it refers to a |
| 44 |
different part of the font glyph (see doc/fonts.txt for |
| 45 |
details). 16 matches that size with SDL_ttf (possibly only for |
| 46 |
LiberationSans). */ |
| 47 |
#define FONT_SIZE 16 |
| 48 |
|
| 49 |
|
| 50 |
// D-Mod-defined font colors |
| 51 |
extern struct SDL_Color font_colors[16]; |
| 52 |
|
| 53 |
|
| 54 |
extern int gfx_fonts_init(void); |
| 55 |
extern void gfx_fonts_init_colors(void); |
| 56 |
extern void gfx_fonts_quit(void); |
| 57 |
extern void setup_font(TTF_Font *font); |
| 58 |
|
| 59 |
extern void FONTS_SetTextColor(Uint8 r, Uint8 g, Uint8 b); |
| 60 |
extern int print_text_wrap(char *str, rect * box, /*bool*/int hcenter, int calc_only, FONT_TYPE font_type); |
| 61 |
extern void print_text_cmds(std::vector<TextCommand>* cmds); |
| 62 |
extern int print_text_wrap_getcmds(char *str, rect * box, /*bool*/int hcenter, int calc_only, FONT_TYPE font_type, std::vector<TextCommand>* cmds); |
| 63 |
extern void print_text_wrap_debug(const char *str, int x, int y); |
| 64 |
extern IOGfxSurface* print_text_flatten_cmds(std::vector<TextCommand>* cmds); |
| 65 |
extern void print_text_cache(IOGfxSurface* surf, SDL_Rect dst, int x, int y); |
| 66 |
|
| 67 |
|
| 68 |
extern void SaySmall(char thing[500], int px, int py, int r, int g, int b); |
| 69 |
extern void Say(char thing[500], int px, int py); |
| 70 |
|
| 71 |
/* DinkC binding */ |
| 72 |
extern int initfont(char* fontname); |
| 73 |
extern void set_font_color(int no, int red, int green, int blue); |
| 74 |
#endif |