aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-12-17 15:15:12 +0100
committerWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-12-17 15:15:12 +0100
commit2772bb158f10fc051d35006041303f2e5418e817 (patch)
tree87dc351f3b16e784a1776ca4bb13bc3120c7ab79
parente1e7ead5df44383c78c8da65fc5916be13d111b6 (diff)
make format
-rw-r--r--src/crepe/api/Text.cpp2
-rw-r--r--src/crepe/facade/FontFacade.cpp34
-rw-r--r--src/example/loadfont.cpp2
3 files changed, 18 insertions, 20 deletions
diff --git a/src/crepe/api/Text.cpp b/src/crepe/api/Text.cpp
index 6c632f3..54a4370 100644
--- a/src/crepe/api/Text.cpp
+++ b/src/crepe/api/Text.cpp
@@ -9,4 +9,4 @@ Text::Text(game_object_id_t id, const vec2 & dimensions, const vec2 & offset,
: UIObject(id, dimensions, offset),
text(text),
data(data),
- font_family(font_family){}
+ font_family(font_family) {}
diff --git a/src/crepe/facade/FontFacade.cpp b/src/crepe/facade/FontFacade.cpp
index 5382f1a..5db06d2 100644
--- a/src/crepe/facade/FontFacade.cpp
+++ b/src/crepe/facade/FontFacade.cpp
@@ -1,7 +1,7 @@
#include <fontconfig/fontconfig.h>
-#include <stdexcept>
-#include <memory>
#include <functional>
+#include <memory>
+#include <stdexcept>
#include <string>
#include "FontFacade.h"
@@ -17,39 +17,37 @@ FontFacade::FontFacade() {
FontFacade::~FontFacade() { FcFini(); }
-Asset FontFacade::get_font_asset(const string& font_family) {
- // Create a pattern to search for the font family
- FcPattern* raw_pattern = FcNameParse(reinterpret_cast<const FcChar8*>(font_family.c_str()));
+Asset FontFacade::get_font_asset(const string & font_family) {
+
+ FcPattern * raw_pattern
+ = FcNameParse(reinterpret_cast<const FcChar8 *>(font_family.c_str()));
if (!raw_pattern) {
throw runtime_error("Failed to create font pattern.");
}
- std::unique_ptr<FcPattern, std::function<void(FcPattern*)>> pattern(
- raw_pattern,
- [](FcPattern* p) { FcPatternDestroy(p); }
- );
+ std::unique_ptr<FcPattern, std::function<void(FcPattern *)>> pattern(
+ raw_pattern, [](FcPattern * p) { FcPatternDestroy(p); });
- FcConfig* config = FcConfigGetCurrent();
+ FcConfig * config = FcConfigGetCurrent();
if (!config) {
throw runtime_error("Failed to get current Fontconfig configuration.");
}
FcResult result;
- FcPattern* raw_matched_pattern = FcFontMatch(config, pattern.get(), &result);
+ FcPattern * raw_matched_pattern = FcFontMatch(config, pattern.get(), &result);
if (!raw_matched_pattern) {
throw runtime_error("No matching font found.");
}
- std::unique_ptr<FcPattern, std::function<void(FcPattern*)>> matched_pattern(
- raw_matched_pattern,
- [](FcPattern* p) { FcPatternDestroy(p); }
- );
+ std::unique_ptr<FcPattern, std::function<void(FcPattern *)>> matched_pattern(
+ raw_matched_pattern, [](FcPattern * p) { FcPatternDestroy(p); });
- FcChar8* file_path = nullptr;
- if (FcPatternGetString(matched_pattern.get(), FC_FILE, 0, &file_path) != FcResultMatch || !file_path) {
+ FcChar8 * file_path = nullptr;
+ if (FcPatternGetString(matched_pattern.get(), FC_FILE, 0, &file_path) != FcResultMatch
+ || !file_path) {
throw runtime_error("Failed to get font file path.");
}
- string font_file_path = reinterpret_cast<const char*>(file_path);
+ string font_file_path = reinterpret_cast<const char *>(file_path);
return Asset(font_file_path);
}
diff --git a/src/example/loadfont.cpp b/src/example/loadfont.cpp
index 788fac4..e459332 100644
--- a/src/example/loadfont.cpp
+++ b/src/example/loadfont.cpp
@@ -2,8 +2,8 @@
#include <crepe/api/Asset.h>
#include <crepe/api/Text.h>
#include <crepe/facade/Font.h>
-#include <crepe/facade/SDLContext.h>
#include <crepe/facade/FontFacade.h>
+#include <crepe/facade/SDLContext.h>
#include <crepe/manager/Mediator.h>
#include <crepe/manager/ResourceManager.h>
#include <exception>