Freeciv-3.2
Loading...
Searching...
No Matches
gui_string.h
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14/***********************************************************************
15 gui_string.h - description
16 -------------------
17 begin : Thu May 30 2002
18 copyright : (C) 2002 by Rafał Bursig
19 email : Rafał Bursig <bursig@poczta.fm>
20***********************************************************************/
21
22#ifndef FC__GUISTRING_H
23#define FC__GUISTRING_H
24
25/* SDL2 */
26#ifdef SDL2_PLAIN_INCLUDE
27#include <SDL.h>
28#include <SDL_ttf.h>
29#else /* SDL2_PLAIN_INCLUDE */
30#include <SDL2/SDL.h>
31#include <SDL2/SDL_ttf.h>
32#endif /* SDL2_PLAIN_INCLUDE */
33
34/* common */
35#include "fc_types.h"
36
37/* gui-sdl2 */
38#include "gui_main.h"
39
40#define SF_CENTER 0x10
41#define SF_CENTER_RIGHT 0x20
42
43/* styles:
44 TTF_STYLE_NORMAL 0
45 TTF_STYLE_BOLD 1
46 TTF_STYLE_ITALIC 2
47 TTF_STYLE_UNDERLINE 4
48 SF_CENTER 0x10 - use with multi string, must be > 0x0f
49 SF_CENTER_RIGHT 0x20 - use with multi string, must be > 0x0f
50*/
51
52typedef struct utf8_str {
56 size_t n_alloc; /* total allocated text memory */
60 char *text;
62
63/* .._PLUS might end up being same as its base size */
73
75 enum font_origin origin);
76utf8_str *create_utf8_str(char *in_text, size_t n_alloc, Uint16 ptsize);
84void change_fonto_utf8(utf8_str *pstr, enum font_origin origin);
85
86void unload_font(Uint16 ptsize);
87void free_font_system(void);
88
89/*
90 * Here we use ordinary free( ... ) because check is made
91 * on start.
92 */
93#define FREEUTF8STR( pstr ) \
94 do { \
95 if (pstr != NULL) { \
96 FC_FREE(pstr->text); \
97 unload_font(pstr->ptsize); \
98 free(pstr); \
99 pstr = NULL; \
100 } \
101} while (FALSE)
102
103#define create_utf8_from_char(string_in, ptsize) \
104 (string_in) == NULL ? \
105 create_utf8_str(NULL, 0, ptsize) : \
106 copy_chars_to_utf8_str(create_utf8_str(NULL, 0, ptsize), string_in)
107
108#define create_utf8_from_char_fonto(string_in, fonto) \
109 (string_in) == NULL ? \
110 create_utf8_str_fonto(NULL, 0, fonto) : \
111 copy_chars_to_utf8_str(create_utf8_str_fonto(NULL, 0, fonto), string_in)
112
113#endif /* FC__GUISTRING_H */
#define n_alloc
Definition astring.c:78
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
char * incite_cost
Definition comments.c:75
void change_ptsize_utf8(utf8_str *pstr, Uint16 new_ptsize)
Definition gui_string.c:559
struct utf8_str utf8_str
void utf8_str_size(utf8_str *pstr, SDL_Rect *fill)
Definition gui_string.c:106
utf8_str * copy_chars_to_utf8_str(utf8_str *pstr, const char *pchars)
Definition gui_string.c:251
SDL_Surface * create_text_surf_from_utf8(utf8_str *pstr)
Definition gui_string.c:425
void change_fonto_utf8(utf8_str *pstr, enum font_origin origin)
Definition gui_string.c:584
void unload_font(Uint16 ptsize)
Definition gui_string.c:653
utf8_str * create_utf8_str(char *in_text, size_t n_alloc, Uint16 ptsize)
Definition gui_string.c:206
utf8_str * create_utf8_str_fonto(char *in_text, size_t n_alloc, enum font_origin origin)
Definition gui_string.c:241
int write_utf8(SDL_Surface *dest, Sint16 x, Sint16 y, utf8_str *pstr)
Definition gui_string.c:276
bool convert_utf8_str_to_const_surface_width(utf8_str *pstr, int width)
Definition gui_string.c:449
font_origin
Definition gui_string.h:64
@ FONTO_HEADING
Definition gui_string.h:69
@ FONTO_DEFAULT
Definition gui_string.h:65
@ FONTO_DEFAULT_PLUS
Definition gui_string.h:66
@ FONTO_BIG
Definition gui_string.h:70
@ FONTO_ATTENTION
Definition gui_string.h:67
@ FONTO_ATTENTION_PLUS
Definition gui_string.h:68
@ FONTO_MAX
Definition gui_string.h:71
void free_font_system(void)
Definition gui_string.c:698
SDL_Surface * create_text_surf_smaller_than_w(utf8_str *pstr, int w)
Definition gui_string.c:539
struct sprite int int y
Definition sprite_g.h:31
struct sprite int x
Definition sprite_g.h:31
Uint8 style
Definition gui_string.h:53
TTF_Font * font
Definition gui_string.h:59
Uint16 ptsize
Definition gui_string.h:55
SDL_Color bgcol
Definition gui_string.h:58
SDL_Color fgcol
Definition gui_string.h:57
size_t n_alloc
Definition gui_string.h:56
char * text
Definition gui_string.h:60
Uint8 render
Definition gui_string.h:54