-
Notifications
You must be signed in to change notification settings - Fork 0
/
font.cpp
42 lines (34 loc) · 900 Bytes
/
font.cpp
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
#include "font.h"
#include "Glyph.h"
Font::Font()
{
}
Font::Font(std::string &fontPath, int fs)
{
loadFont(fontPath, fs);
}
Font::~Font()
{
}
void Font::loadFont(const std::string &fontPath, int fs)
{
mFont.loadFromFile(fontPath);
}
Glyph Font::getGlyph(uint32_t codePoint, unsigned int characterSize, bool bold, float outlineThickness) const
{
return Glyph(mFont.getGlyph(codePoint, characterSize, bold, outlineThickness));
}
float Font::getUnderlineSpacing(const int fontSize) const
{
return mFont.getUnderlinePosition(fontSize);
}
int Font::getWidth(const std::string message, const int fontSize)
{
sf::Text text(message, mFont, fontSize);
return (int)text.getGlobalBounds().width;
}
int Font::getHeight(const std::string message, const int fontSize)
{
sf::Text text(message, mFont, fontSize);
return (int)text.getGlobalBounds().height;
}