-
Notifications
You must be signed in to change notification settings - Fork 7
/
font.h
35 lines (26 loc) · 961 Bytes
/
font.h
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
// Copyright 2015 Red Blob Games <[email protected]>
// License: Apache v2.0 <http://www.apache.org/licenses/LICENSE-2.0.html>
/** Load fonts so that they can be rendered onto an SDL_Surface. */
#ifndef FONT_H
#define FONT_H
#include <memory>
struct SDL_Surface;
struct FontImpl;
class Font {
public:
// The font will be ceil(pixelsize) pixels high. Use xadvance_adjust to
// increase or decrease spacing between characters.
Font(const char* filename, float pixelsize, float xadvance_adjust=0.0);
~Font();
// Draw text at x,y being the baseline. Drawing can happen both
// above and below the baseline. For example, a font with pixelsize=30
// and y=100 might draw starting from y=80 and ending at y=120.
void Draw(SDL_Surface* surface, int x, int y, const char* text) const;
int Height() const;
int Baseline() const;
int Width(const char* text) const;
float pixelsize;
private:
std::unique_ptr<FontImpl> self;
};
#endif