aboutsummaryrefslogtreecommitdiff
path: root/graphics/fonts/ttf.h
blob: bd25b69f212437ee39e47694511ea610e696f045 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 */

#ifndef GRAPHICS_FONTS_TTF_H
#define GRAPHICS_FONTS_TTF_H

#include "common/scummsys.h"

#ifdef USE_FREETYPE2

#include "common/stream.h"

namespace Graphics {

class Font;

/**
 * This specifies the mode in which TTF glyphs are rendered. This, for example,
 * allows to render glyphs fully monochrome, i.e. without any anti-aliasing.
 */
enum TTFRenderMode {
	/**
	 * Standard render mode. Equivalent of FreeType2's FT_RENDER_MODE_NORMAL.
	 */
	kTTFRenderModeNormal,

	/**
	 * Use lighter hinting. Equivalent of FreeType2's FT_RENDER_MODE_LIGHT.
	 */
	kTTFRenderModeLight,

	/**
	 * Render fully monochrome. This makes glyph pixels either be fully opaque
	 * or fully transparent.
	 */
	kTTFRenderModeMonochrome
};

/**
 * Loads a TTF font file from a given data stream object.
 *
 * @param stream     Stream object to load font data from.
 * @param size       The point size to load.
 * @param dpi        The dpi to use for size calculations, by default 72dpi
 *                   are used.
 * @param renderMode FreeType2 mode used to render glyphs. @see TTFRenderMode
 * @param mapping    A mapping from code points 0-255 into UTF-32 code points.
 *                   This can be used to support various 8bit character sets.
 *                   In case the msb of the UTF-32 code point is set the font
 *                   loading fails in case no glyph for it is found. When this
 *                   is non-null only characters given in the mapping are
 *                   supported.
 * @return 0 in case loading fails, otherwise a pointer to the Font object.
 */
Font *loadTTFFont(Common::SeekableReadStream &stream, int size, uint dpi = 0, TTFRenderMode renderMode = kTTFRenderModeLight, const uint32 *mapping = 0);

void shutdownTTF();

} // End of namespace Graphics

#endif

#endif