aboutsummaryrefslogtreecommitdiff
path: root/src/example/loadfont.cpp
blob: efd5a98989e129209d2b8e39ac3836edf0646508 (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
#include <crepe/api/Text.h>
#include <crepe/facade/Font.h>
#include <crepe/facade/SDLContext.h>
#include <crepe/facade/SDLFontContext.h>
#include <crepe/manager/Mediator.h>
#include <exception>
#include <iostream>
#include <memory>
using namespace crepe;
int main() {

	SDLFontContext font_facade;
	Mediator mediator;
	SDLContext sdl_context{mediator};
	try {
		// Correct way to create a unique pointer for Text
		std::unique_ptr<Text> label
			= std::make_unique<Text>(1, vec2(100, 100), vec2(0, 0), "test test", "OpenSymbol");
		std::unique_ptr<Asset> asset = font_facade.get_font_asset(label->font_family);
		std::cout << "path: " << asset->get_path() << std::endl;
		std::unique_ptr<Font> font = std::make_unique<Font>(*asset, mediator);
	} catch (const std::exception & e) {
		std::cout << "Standard exception thrown: " << e.what() << std::endl;
	}

	return 0;
}