ScummVM API documentation
ags_font_renderer.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef AGS_SHARED_FONT_AGS_FONT_RENDERER_H
23 #define AGS_SHARED_FONT_AGS_FONT_RENDERER_H
24 
25 namespace AGS3 {
26 
27 class BITMAP;
28 
30 public:
31  virtual bool LoadFromDisk(int fontNumber, int fontSize) = 0;
32  virtual void FreeMemory(int fontNumber) = 0;
33  virtual bool SupportsExtendedCharacters(int fontNumber) = 0;
34  virtual int GetTextWidth(const char *text, int fontNumber) = 0;
35  // Get actual height of the given line of text
36  virtual int GetTextHeight(const char *text, int fontNumber) = 0;
37  virtual void RenderText(const char *text, int fontNumber, BITMAP *destination, int x, int y, int colour) = 0;
38  virtual void AdjustYCoordinateForFont(int *ycoord, int fontNumber) = 0;
39  virtual void EnsureTextValidForFont(char *text, int fontNumber) = 0;
40 protected:
41  IAGSFontRenderer() {}
42  ~IAGSFontRenderer() {}
43 };
44 
45 // Extended font renderer interface.
46 // WARNING: this interface is exposed for plugins and declared for the second time in agsplugin.h
48 public:
49  // Returns engine API version this font renderer complies to.
50  // Must not be lower than 26 (this interface was added at API v26).
51  virtual int GetVersion() = 0;
52  // Returns an arbitrary renderer name; this is for informational
53  // purposes only.
54  virtual const char *GetRendererName() = 0;
55  // Returns given font's name (if available).
56  virtual const char *GetFontName(int fontNumber) = 0;
57  // Returns the given font's height: that is the maximal vertical size
58  // that the font glyphs may occupy.
59  virtual int GetFontHeight(int fontNumber) = 0;
60  // Returns the given font's linespacing;
61  // is allowed to return 0, telling that no specific linespacing
62  // is assigned for this font.
63  virtual int GetLineSpacing(int fontNumber) = 0;
64 
65 protected:
67  ~IAGSFontRenderer2() {}
68 };
69 
70 // Font render params, mainly for dealing with various compatibility issues.
72  // Font's render multiplier
73  int SizeMultiplier = 1;
74  int LoadMode = 0; // contains font flags from FFLG_LOADMODEMASK
75 };
76 
77 // Describes loaded font's properties
78 struct FontMetrics {
79  int Height = 0; // formal font height value
80  int RealHeight = 0; // real graphical height of a font
81  int CompatHeight = 0; // either formal or real height, depending on compat settings
82 };
83 
84 // The strictly internal font renderer interface, not to use in plugin API.
85 // Contains methods necessary for built-in font renderers.
87 public:
88  // Tells if this is a bitmap font (otherwise it's a vector font)
89  virtual bool IsBitmapFont() = 0;
90  // Load font, applying extended font rendering parameters
91  virtual bool LoadFromDiskEx(int fontNumber, int fontSize, const FontRenderParams *params,
92  FontMetrics *metrics) = 0;
93  // Fill FontMetrics struct; note that it may be left cleared if this is not supported
94  virtual void GetFontMetrics(int fontNumber, FontMetrics *metrics) = 0;
95  // Perform any necessary adjustments when the AA mode is toggled
96  virtual void AdjustFontForAntiAlias(int fontNumber, bool aa_mode) = 0;
97 
98 protected:
101 };
102 
103 } // namespace AGS3
104 
105 #endif
Definition: surface.h:32
Definition: ags_font_renderer.h:71
Definition: ags_font_renderer.h:86
Definition: ags_font_renderer.h:47
Definition: ags_font_renderer.h:78
Definition: ags.h:40
Definition: ags_font_renderer.h:29