ScummVM API documentation
ttf_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_TTF_FONT_RENDERER_H
23#define AGS_SHARED_FONT_TTF_FONT_RENDERER_H
24
25#include "common/std/map.h"
26#include "ags/shared/font/ags_font_renderer.h"
27#include "ags/shared/util/string.h"
28
29namespace AGS3 {
30
31struct ALFONT_FONT;
32
34public:
35 virtual ~TTFFontRenderer() {}
36
37 // IAGSFontRenderer implementation
38 bool LoadFromDisk(int fontNumber, int fontSize) override;
39 void FreeMemory(int fontNumber) override;
40 bool SupportsExtendedCharacters(int /*fontNumber*/) override {
41 return true;
42 }
43 int GetTextWidth(const char *text, int fontNumber) override;
44 int GetTextHeight(const char *text, int fontNumber) override;
45 void RenderText(const char *text, int fontNumber, BITMAP *destination, int x, int y, int colour) override;
46 void AdjustYCoordinateForFont(int *ycoord, int fontNumber) override;
47 void EnsureTextValidForFont(char *text, int fontNumber) override;
48
49 // IAGSFontRenderer2 implementation
50 int GetVersion() override { return 26; /* first compatible engine API version */ }
51 const char *GetRendererName() override { return "TTFFontRenderer"; }
52 const char *GetFontName(int fontNumber) override;
53 int GetFontHeight(int fontNumber) override;
54 int GetLineSpacing(int fontNumber) override { return 0; /* no specific spacing */ }
55
56 // IAGSFontRendererInternal implementation
57 bool IsBitmapFont() override;
58 bool LoadFromDiskEx(int fontNumber, int fontSize, AGS::Shared::String *src_filename,
59 const FontRenderParams *params, FontMetrics *metrics) override;
60 void GetFontMetrics(int fontNumber, FontMetrics *metrics) override;
61 void AdjustFontForAntiAlias(int fontNumber, bool aa_mode) override;
62
63 //
64 // Utility functions
65 //
66 // Try load the TTF font using provided point size, and report its metrics
67 static bool MeasureFontOfPointSize(const AGS::Shared::String &filename, int size_pt, FontMetrics *metrics);
68 // Try load the TTF font, find the point size which results in pixel height
69 // as close to the requested as possible; report its metrics
70 static bool MeasureFontOfPixelHeight(const AGS::Shared::String &filename, int pixel_height, FontMetrics *metrics);
71
72private:
73 struct FontData {
74 ALFONT_FONT *AlFont;
75 FontRenderParams Params;
76 };
78};
79
80} // namespace AGS3
81
82#endif
Definition: string.h:60
Definition: surface.h:32
Definition: ags_font_renderer.h:107
Definition: ttf_font_renderer.h:33
Definition: ags_font_renderer.h:82
Definition: ags_font_renderer.h:75