#include "KFont.hpp" ➔ class KFont

KFont

A class that holds a font to render text.

#include "KSurface.hpp"
#include "KColor.hpp"

class KFont {};

Constructor

KFont(std::string file, int size);

Loads a font from a ttf file.
size will be the pixel size of the rendered characters.

Method

bool open(const std::string& file, int size);
void close();
bool is_opened() const;
bool is_closed() const;

Loads, closes and test whether the font is opened or not.

Operator

KSurface operator()(std::string text, KColor color);

Renders the specified text with the specified color on the returned KSurface.
This function is useless if a KText is used (as shown in the example).

Example

KFont font("font.ttf", 32);

if (font.is_opened()) {
    KText text("hello world", font, KColor(40, 40, 40));
    text.save("text.bmp");
}