aboutsummaryrefslogtreecommitdiff
path: root/src/example
diff options
context:
space:
mode:
authorWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-12-16 19:08:22 +0100
committerWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-12-16 19:08:22 +0100
commit55f4aaf179cf723c5b703b0c4d848bf059ae190a (patch)
tree56b7034d665783384415abc1a0e9282c194ae1c3 /src/example
parent7f7f1237532b4318361e69349cc38f34fe981803 (diff)
font family implemented in the text component
Diffstat (limited to 'src/example')
-rw-r--r--src/example/loadfont.cpp21
1 files changed, 6 insertions, 15 deletions
diff --git a/src/example/loadfont.cpp b/src/example/loadfont.cpp
index dae64bc..0ea6d86 100644
--- a/src/example/loadfont.cpp
+++ b/src/example/loadfont.cpp
@@ -1,7 +1,6 @@
#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>
@@ -9,26 +8,18 @@
using namespace crepe;
int main() {
- SDLFontContext font_facade;
+ // 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", Text::Data{});
- 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);
- // Get the TTF_Font from the Font object
- TTF_Font * ttf_font = font->get_font();
- //example if the asset is not correct for font
- //std::unique_ptr<Font> fontThrow = std::make_unique<Font>(Asset("../help.txt"), mediator);
- // Check if the font is loaded properly
- if (ttf_font != nullptr) {
- std::cout << "Font successfully loaded!" << std::endl;
- } else {
- std::cout << "Failed to load font." << std::endl;
- }
+ std::cout << "Path: " << label->font.get_path() << std::endl;
+
+ std::unique_ptr<Text> label2 = std::make_unique<Text>(
+ 1, vec2(100, 100), vec2(0, 0), "test test", "fsaafdafsdafsdafsdasfdds", Text::Data{});
+ std::cout << "Path: " << label2->font.get_path() << std::endl;
} catch (const std::exception & e) {
std::cout << "Standard exception thrown: " << e.what() << std::endl;
}