1 //=============================================================================
2 //
3 // Adventure Game Studio (AGS)
4 //
5 // Copyright (C) 1999-2011 Chris Jones and 2011-20xx others
6 // The full list of copyright holders can be found in the Copyright.txt
7 // file, which is part of this source code distribution.
8 //
9 // The AGS source code is provided under the Artistic License 2.0.
10 // A copy of this license can be found in the file License.txt and at
11 // http://www.opensource.org/licenses/artistic-license-2.0.php
12 //
13 //=============================================================================
14 
15 #ifndef __AC_FONT_H
16 #define __AC_FONT_H
17 
18 #include "gfx/bitmap.h"
19 
20 // TODO: we need to make some kind of TextManager class of this module
21 
22 using namespace AGS;
23 
24 class IAGSFontRenderer;
25 class IAGSFontRenderer2;
26 struct GameSetupStruct;
27 
28 // Various font parameters, defining and extending font rendering behavior.
29 // While FontRenderer object's main goal is to render single line of text at
30 // the strictly determined position on canvas, FontInfo may additionally
31 // provide instructions on adjusting drawing position, as well as arranging
32 // multiple lines, and similar cases.
33 struct FontInfo
34 {
35     // General font's loading and rendering flags
36     unsigned char Flags;
37     // Font size, in points (basically means pixels in AGS)
38     int           SizePt;
39     // Outlining font index, or auto-outline flag
40     char          Outline;
41     // Custom vertical render offset, used mainly for fixing broken fonts
42     int           YOffset;
43     // custom line spacing between two lines of text (0 = use font height)
44     int           LineSpacing;
45 
46     FontInfo();
47 };
48 
49 // Font render params, mainly for dealing with various compatibility issues and
50 // broken fonts. NOTE: currently left empty as a result of rewrite, but may be
51 // used again in the future.
52 struct FontRenderParams {};
53 
54 void init_font_renderer();
55 void shutdown_font_renderer();
56 void adjust_y_coordinate_for_text(int* ypos, int fontnum);
57 IAGSFontRenderer* font_replace_renderer(int fontNumber, IAGSFontRenderer* renderer);
58 bool font_first_renderer_loaded();
59 bool font_supports_extended_characters(int fontNumber);
60 void ensure_text_valid_for_font(char *text, int fontnum);
61 int wgettextwidth(const char *texx, int fontNumber);
62 // Calculates actual height of a line of text
63 int wgettextheight(const char *text, int fontNumber);
64 // Get font's height (maximal height of any line of text printed with this font)
65 int getfontheight(int fontNumber);
66 // Get font's line spacing
67 int getfontlinespacing(int fontNumber);
68 // Get is font is meant to use default line spacing
69 bool use_default_linespacing(int fontNumber);
70 int  get_font_outline(int font_number);
71 void set_font_outline(int font_number, int outline_type);
72 // Outputs a single line of text on the defined position on bitmap, using defined font, color and parameters
73 int getfontlinespacing(int fontNumber);
74 void wouttextxy(Common::Bitmap *ds, int xxx, int yyy, int fontNumber, color_t text_color, const char *texx);
75 // Fills in FontInfo structure from the GameSetupStruct data
76 void make_fontinfo(const GameSetupStruct &game, int fontNumber, FontInfo &font_info);
77 // Assigns FontInfo to the font
78 void set_fontinfo(int fontNumber, const FontInfo &finfo);
79 // Loads a font from disk
80 bool wloadfont_size(int fontNumber, const FontInfo &font_info, const FontRenderParams *params = NULL);
81 void wgtprintf(Common::Bitmap *ds, int xxx, int yyy, int fontNumber, color_t text_color, char *fmt, ...);
82 void wfreefont(int fontNumber);
83 
84 extern int wtext_multiply;
85 
86 #endif // __AC_FONT_H
87