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/* SDL3 */
26#include <SDL3/SDL.h>
27#include <SDL3_ttf/SDL_ttf.h>
28
29/* common */
30#include "fc_types.h"
31
32/* gui-sdl3 */
33#include "gui_main.h"
34
35#define SF_CENTER 0x10
36#define SF_CENTER_RIGHT 0x20
37
38/* styles:
39 TTF_STYLE_NORMAL 0
40 TTF_STYLE_BOLD 1
41 TTF_STYLE_ITALIC 2
42 TTF_STYLE_UNDERLINE 4
43 SF_CENTER 0x10 - use with multi string, must be > 0x0f
44 SF_CENTER_RIGHT 0x20 - use with multi string, must be > 0x0f
45*/
46
47typedef struct utf8_str {
51 size_t n_alloc; /* total allocated text memory */
55 char *text;
57
58/* .._PLUS might end up being same as its base size */
68
70 enum font_origin origin);
71utf8_str *create_utf8_str(char *in_text, size_t n_alloc, Uint16 ptsize);
79void change_fonto_utf8(utf8_str *pstr, enum font_origin origin);
80
81void unload_font(Uint16 ptsize);
82void free_font_system(void);
83
84/*
85 * Here we use ordinary free( ... ) because check is made
86 * on start.
87 */
88#define FREEUTF8STR( pstr ) \
89 do { \
90 if (pstr != NULL) { \
91 FC_FREE(pstr->text); \
92 unload_font(pstr->ptsize); \
93 free(pstr); \
94 pstr = NULL; \
95 } \
96} while (FALSE)
97
98#define create_utf8_from_char(string_in, ptsize) \
99 (string_in) == NULL ? \
100 create_utf8_str(NULL, 0, ptsize) : \
101 copy_chars_to_utf8_str(create_utf8_str(NULL, 0, ptsize), string_in)
102
103#define create_utf8_from_char_fonto(string_in, fonto) \
104 (string_in) == NULL ? \
105 create_utf8_str_fonto(NULL, 0, fonto) : \
106 copy_chars_to_utf8_str(create_utf8_str_fonto(NULL, 0, fonto), string_in)
107
108#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